Team Fortress 2 Source Code as on 22/4/2020
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.

209 lines
6.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PROPERTYSHEET_H
  8. #define PROPERTYSHEET_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vgui/VGUI.h"
  13. #include "vgui_controls/EditablePanel.h"
  14. #include "vgui_controls/PHandle.h"
  15. #include "utlvector.h"
  16. namespace vgui
  17. {
  18. class PageTab;
  19. class ImagePanel;
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Tabbed property sheet. Holds and displays a set of Panel's
  22. //-----------------------------------------------------------------------------
  23. class PropertySheet : public EditablePanel
  24. {
  25. DECLARE_CLASS_SIMPLE( PropertySheet, EditablePanel );
  26. public:
  27. PropertySheet(Panel *parent, const char *panelName, bool draggableTabs = false );
  28. PropertySheet(Panel *parent, const char *panelName,ComboBox *combo);
  29. ~PropertySheet();
  30. virtual bool IsDraggableTab() const;
  31. void SetDraggableTabs( bool state );
  32. // Adds a page to the sheet. The first page added becomes the active sheet.
  33. virtual void AddPage(Panel *page, const char *title, char const *imageName = NULL, bool showContextMenu = false );
  34. // sets the current page
  35. virtual void SetActivePage(Panel *page);
  36. // sets the width, in pixels, of the page tab buttons.
  37. virtual void SetTabWidth(int pixels);
  38. // Gets a pointer to the currently active page.
  39. virtual Panel *GetActivePage();
  40. // Removes (but doesn't delete) all pages
  41. virtual void RemoveAllPages();
  42. // Removes all the pages and marks all the pages for deletion.
  43. virtual void DeleteAllPages();
  44. // reloads the data in all the property page
  45. virtual void ResetAllData();
  46. // writes out any changed data to the doc
  47. virtual void ApplyChanges();
  48. // focus handling - passed on to current active page
  49. virtual void RequestFocus(int direction = 0);
  50. virtual bool RequestFocusPrev(VPANEL panel = NULL);
  51. virtual bool RequestFocusNext(VPANEL panel = NULL);
  52. // returns the ith panel
  53. virtual Panel *GetPage(int i);
  54. // deletes this panel from the sheet
  55. virtual void DeletePage(Panel *panel);
  56. // removes this panel from the sheet, sets its parent to NULL, but does not delete it
  57. virtual void RemovePage(Panel *panel);
  58. // returns the current activated tab
  59. virtual Panel *GetActiveTab();
  60. // returns the title text of the tab
  61. virtual void GetActiveTabTitle( char *textOut, int bufferLen );
  62. // returns the title of tab "i"
  63. virtual bool GetTabTitle( int i, char *textOut, int bufferLen );
  64. // sets the title of tab "i"
  65. virtual bool SetTabTitle( int i, char *pchTitle );
  66. // returns the index of the active page
  67. virtual int GetActivePageNum();
  68. // returns the number of pages in the sheet
  69. virtual int GetNumPages();
  70. // disable the page with title "title"
  71. virtual void DisablePage(const char *title);
  72. // enable the page with title "title"
  73. virtual void EnablePage(const char *title);
  74. virtual void SetSmallTabs( bool state );
  75. virtual bool IsSmallTabs() const;
  76. /* MESSAGES SENT TO PAGES
  77. "PageShow" - sent when a page is shown
  78. "PageHide" - sent when a page is hidden
  79. "ResetData" - sent when the data should be reloaded from doc
  80. "ApplyChanges" - sent when data should be written to doc
  81. */
  82. virtual void OnPanelDropped( CUtlVector< KeyValues * >& msglist );
  83. virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist );
  84. // Mouse is now over a droppable panel
  85. virtual void OnDroppablePanelPaint( CUtlVector< KeyValues * >& msglist, CUtlVector< Panel * >& dragPanels );
  86. void ShowContextButtons( bool state );
  87. bool ShouldShowContextButtons() const;
  88. int FindPage( Panel *page ) const;
  89. bool PageHasContextMenu( Panel *page ) const;
  90. void SetKBNavigationEnabled( bool state );
  91. bool IsKBNavigationEnabled() const;
  92. virtual bool HasUserConfigSettings() { return true; }
  93. protected:
  94. virtual void PaintBorder();
  95. virtual void PerformLayout();
  96. virtual Panel *HasHotkey(wchar_t key);
  97. virtual void ChangeActiveTab(int index);
  98. virtual void OnKeyCodePressed(KeyCode code);
  99. virtual void OnCommand(const char *command);
  100. virtual void ApplySchemeSettings(IScheme *pScheme);
  101. virtual void ApplySettings(KeyValues *inResourceData);
  102. // internal message handlers
  103. MESSAGE_FUNC_PTR( OnTabPressed, "TabPressed", panel );
  104. MESSAGE_FUNC_PTR_WCHARPTR( OnTextChanged, "TextChanged", panel, text );
  105. MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", params );
  106. MESSAGE_FUNC( OnApplyButtonEnable, "ApplyButtonEnable" );
  107. // called when default button has been set
  108. MESSAGE_FUNC_HANDLE( OnDefaultButtonSet, "DefaultButtonSet", button );
  109. // called when the current default button has been set
  110. MESSAGE_FUNC_HANDLE( OnCurrentDefaultButtonSet, "CurrentDefaultButtonSet", button);
  111. MESSAGE_FUNC( OnFindDefaultButton, "FindDefaultButton" );
  112. private:
  113. // enable/disable the page with title "title"
  114. virtual void SetPageEnabled(const char *title,bool state);
  115. struct Page_t
  116. {
  117. Page_t() :
  118. page( 0 ),
  119. contextMenu( false )
  120. {
  121. }
  122. Panel *page;
  123. bool contextMenu;
  124. };
  125. CUtlVector<Page_t> m_Pages;
  126. CUtlVector<PageTab *> m_PageTabs;
  127. Panel *_activePage;
  128. PageTab *_activeTab;
  129. int _tabWidth;
  130. int _activeTabIndex;
  131. ComboBox *_combo;
  132. bool _showTabs;
  133. bool _tabFocus;
  134. PHandle m_hPreviouslyActivePage;
  135. float m_flPageTransitionEffectTime;
  136. bool m_bSmallTabs;
  137. HFont m_tabFont;
  138. bool m_bDraggableTabs;
  139. bool m_bContextButton;
  140. bool m_bKBNavigationEnabled;
  141. CPanelAnimationVarAliasType( int, m_iTabXIndent, "tabxindent", "0", "proportional_int" );
  142. CPanelAnimationVarAliasType( int, m_iTabXDelta, "tabxdelta", "0", "proportional_int" );
  143. CPanelAnimationVarAliasType( bool, m_bTabFitText, "tabxfittotext", "1", "bool" );
  144. //=============================================================================
  145. // HPE_BEGIN:
  146. // [tj] These variables have been split into the initially specified size
  147. // and the currently set size. This is so we can always recalculate the
  148. // new value for resolution changes.
  149. //=============================================================================
  150. CPanelAnimationVarAliasType( int, m_iSpecifiedTabHeight, "tabheight", "28", "int" );
  151. CPanelAnimationVarAliasType( int, m_iSpecifiedTabHeightSmall, "tabheight_small", "14", "int" );
  152. int m_iTabHeight;
  153. int m_iTabHeightSmall;
  154. //=============================================================================
  155. // HPE_END
  156. //=============================================================================
  157. KeyValues *m_pTabKV;
  158. };
  159. }; // namespace vgui
  160. #endif // PROPERTYSHEET_H