Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.8 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef ATTRIBUTEFILEPICKERPANEL_H
  9. #define ATTRIBUTEFILEPICKERPANEL_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "dme_controls/AttributeBasePickerPanel.h"
  14. #include "vgui_controls/phandle.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class CDmElement;
  19. namespace vgui
  20. {
  21. class FileOpenDialog;
  22. }
  23. //-----------------------------------------------------------------------------
  24. // CAttributeFilePickerPanel
  25. //-----------------------------------------------------------------------------
  26. class CAttributeFilePickerPanel : public CAttributeBasePickerPanel
  27. {
  28. DECLARE_CLASS_SIMPLE( CAttributeFilePickerPanel, CAttributeBasePickerPanel );
  29. public:
  30. CAttributeFilePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
  31. ~CAttributeFilePickerPanel();
  32. private:
  33. MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );
  34. virtual void ShowPickerDialog();
  35. virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog ) = 0;
  36. };
  37. //-----------------------------------------------------------------------------
  38. // Macro to quickly make new attribute types
  39. //-----------------------------------------------------------------------------
  40. #define DECLARE_ATTRIBUTE_FILE_PICKER( _className ) \
  41. class _className : public CAttributeFilePickerPanel \
  42. { \
  43. DECLARE_CLASS_SIMPLE( _className, CAttributeFilePickerPanel ); \
  44. public: \
  45. _className( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) : \
  46. BaseClass( parent, info ) {} \
  47. private: \
  48. virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog ); \
  49. }
  50. #define IMPLEMENT_ATTRIBUTE_FILE_PICKER( _className, _popupTitle, _assetType, _assetExt ) \
  51. void _className::SetupFileOpenDialog( vgui::FileOpenDialog *pDialog ) \
  52. { \
  53. pDialog->SetTitle( _popupTitle, true ); \
  54. pDialog->AddFilter( "*." _assetExt, _assetType " (*." _assetExt ")", true ); \
  55. pDialog->AddFilter( "*.*", "All Files (*.*)", false ); \
  56. }
  57. //-----------------------------------------------------------------------------
  58. // File picker types
  59. //-----------------------------------------------------------------------------
  60. DECLARE_ATTRIBUTE_FILE_PICKER( CAttributeDmeFilePickerPanel );
  61. DECLARE_ATTRIBUTE_FILE_PICKER( CAttributeAviFilePickerPanel );
  62. DECLARE_ATTRIBUTE_FILE_PICKER( CAttributeShtFilePickerPanel );
  63. DECLARE_ATTRIBUTE_FILE_PICKER( CAttributeRawFilePickerPanel );
  64. #endif // ATTRIBUTEFILEPICKERPANEL_H