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.

93 lines
2.8 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ATTRIBUTEWIDGETFACTORY_H
  7. #define ATTRIBUTEWIDGETFACTORY_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier0/platform.h"
  12. //-----------------------------------------------------------------------------
  13. // Forward declarations
  14. //-----------------------------------------------------------------------------
  15. class CDmElement;
  16. class CMovieDoc;
  17. class IDmNotify;
  18. class CDmeEditorAttributeInfo;
  19. class CDmeEditorTypeDictionary;
  20. class CDmAttribute;
  21. namespace vgui
  22. {
  23. class EditablePanel;
  24. class Panel;
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Info about the attribute being edited, and how the editor should look
  28. //-----------------------------------------------------------------------------
  29. struct AttributeWidgetInfo_t
  30. {
  31. AttributeWidgetInfo_t()
  32. {
  33. m_nArrayIndex = -1;
  34. m_bShowUniqueID = true;
  35. }
  36. CDmElement *m_pElement;
  37. const char *m_pAttributeName;
  38. int m_nArrayIndex;
  39. CDmeEditorTypeDictionary *m_pEditorTypeDictionary;
  40. CDmeEditorAttributeInfo *m_pEditorInfo;
  41. IDmNotify *m_pNotify;
  42. bool m_bAutoApply;
  43. bool m_bShowMemoryUsage;
  44. bool m_bShowUniqueID;
  45. };
  46. //-----------------------------------------------------------------------------
  47. // Interface used to create an attribute widget
  48. //-----------------------------------------------------------------------------
  49. class IAttributeWidgetFactory
  50. {
  51. public:
  52. virtual vgui::Panel *Create( vgui::Panel *pParent, const AttributeWidgetInfo_t &info ) = 0;
  53. };
  54. //-----------------------------------------------------------------------------
  55. // Templatized class used to create widget factories
  56. //-----------------------------------------------------------------------------
  57. class IAttributeWidgetFactoryList
  58. {
  59. public:
  60. // Returns a named widget factory
  61. virtual IAttributeWidgetFactory *GetWidgetFactory( const char *pWidgetName ) = 0;
  62. // Returns a factory used to create widget for the attribute passed in
  63. virtual IAttributeWidgetFactory *GetWidgetFactory( CDmElement *object, CDmAttribute *pAttribute, CDmeEditorTypeDictionary *pTypeDictionary ) = 0;
  64. // Returns a factory used to create widgets for entries in an attribute array
  65. virtual IAttributeWidgetFactory *GetArrayWidgetFactory( CDmElement *object, CDmAttribute *pAttribute, CDmeEditorTypeDictionary *pTypeDictionary ) = 0;
  66. // Applies changes to a widget
  67. virtual void ApplyChanges( vgui::Panel *pWidget, vgui::Panel *pSender = NULL ) = 0;
  68. // Refreshes a widget when attributes change
  69. virtual void Refresh( vgui::Panel *pWidget, vgui::Panel *pSender = NULL ) = 0;
  70. };
  71. extern IAttributeWidgetFactoryList *attributewidgetfactorylist;
  72. #endif // ATTRIBUTEWIDGETFACTORY_H