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.

225 lines
6.9 KiB

  1. //========= Copyright � 1996-2005, 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, int nInsertBefore = -1 );
  34. virtual void SetPageTitle( Panel *page, const char *title );
  35. // sets the current page
  36. virtual void SetActivePage(Panel *page);
  37. // sets the width, in pixels, of the page tab buttons.
  38. virtual void SetTabWidth(int pixels);
  39. // Gets a pointer to the currently active page.
  40. virtual Panel *GetActivePage();
  41. // Removes (but doesn't delete) all pages
  42. virtual void RemoveAllPages();
  43. // Removes all the pages and marks all the pages for deletion.
  44. virtual void DeleteAllPages();
  45. // reloads the data in all the property page
  46. virtual void ResetAllData();
  47. // writes out any changed data to the doc
  48. virtual void ApplyChanges();
  49. // focus handling - passed on to current active page
  50. virtual void RequestFocus(int direction = 0);
  51. virtual bool RequestFocusPrev(VPANEL panel = NULL);
  52. virtual bool RequestFocusNext(VPANEL panel = NULL);
  53. // returns the ith panel
  54. virtual Panel *GetPage(int i);
  55. // deletes this panel from the sheet
  56. virtual void DeletePage(Panel *panel);
  57. // removes this panel from the sheet, sets its parent to NULL, but does not delete it
  58. virtual void RemovePage(Panel *panel);
  59. // returns the current activated tab
  60. virtual Panel *GetActiveTab();
  61. // returns the title text of the tab
  62. virtual void GetActiveTabTitle(char *textOut, int bufferLen);
  63. // return tab "i"
  64. virtual Panel *GetTab(int i);
  65. // returns the title of tab "i"
  66. virtual bool GetTabTitle(int i,char *textOut, int bufferLen);
  67. // returns the index of the active page
  68. virtual int GetActivePageNum();
  69. // returns the number of pages in the sheet
  70. virtual int GetNumPages();
  71. // disable the page with title "title"
  72. virtual void DisablePage(const char *title);
  73. // enable the page with title "title"
  74. virtual void EnablePage(const char *title);
  75. virtual void SetSmallTabs( bool state );
  76. virtual bool IsSmallTabs() const;
  77. virtual void SetShowTabs( bool state );
  78. /* MESSAGES SENT TO PAGES
  79. "PageShow" - sent when a page is shown
  80. "PageHide" - sent when a page is hidden
  81. "ResetData" - sent when the data should be reloaded from doc
  82. "ApplyChanges" - sent when data should be written to doc
  83. */
  84. virtual void OnPanelDropped( CUtlVector< KeyValues * >& msglist );
  85. virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist );
  86. // Mouse is now over a droppable panel
  87. virtual void OnDroppablePanelPaint( CUtlVector< KeyValues * >& msglist, CUtlVector< Panel * >& dragPanels );
  88. void ShowContextButtons( bool state );
  89. bool ShouldShowContextButtons() const;
  90. int FindPage( Panel *page ) const;
  91. bool PageHasContextMenu( Panel *page ) const;
  92. void SetKBNavigationEnabled( bool state );
  93. bool IsKBNavigationEnabled() const;
  94. virtual bool HasUserConfigSettings() { return true; }
  95. virtual void OnThink();
  96. protected:
  97. virtual void PaintBorder();
  98. virtual void PerformLayout();
  99. virtual Panel *HasHotkey(wchar_t key);
  100. virtual void ChangeActiveTab(int index);
  101. virtual void OnKeyCodeTyped(KeyCode code);
  102. virtual void OnCommand(const char *command);
  103. virtual void ApplySchemeSettings(IScheme *pScheme);
  104. virtual void ApplySettings(KeyValues *inResourceData);
  105. // internal message handlers
  106. MESSAGE_FUNC_PTR( OnTabPressed, "TabPressed", panel );
  107. MESSAGE_FUNC_PTR_WCHARPTR( OnTextChanged, "TextChanged", panel, text );
  108. MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", params );
  109. MESSAGE_FUNC( OnApplyButtonEnable, "ApplyButtonEnable" );
  110. // called when default button has been set
  111. MESSAGE_FUNC_HANDLE( OnDefaultButtonSet, "DefaultButtonSet", button );
  112. // called when the current default button has been set
  113. MESSAGE_FUNC_HANDLE( OnCurrentDefaultButtonSet, "CurrentDefaultButtonSet", button);
  114. MESSAGE_FUNC( OnFindDefaultButton, "FindDefaultButton" );
  115. virtual void LayoutTabs();
  116. private:
  117. // enable/disable the page with title "title"
  118. virtual void SetPageEnabled(const char *title,bool state);
  119. // Grabs mouse coords and figures out best tab to insert "before" or -1 if insert should be at end of tab section row
  120. PageTab *FindInsertBeforeTab();
  121. void AddPageDropTab( char const *pTabName, Panel *pPage );
  122. void ClearPageDropTab();
  123. struct Page_t
  124. {
  125. Page_t() :
  126. page( 0 ),
  127. contextMenu( false )
  128. {
  129. }
  130. Panel *page;
  131. bool contextMenu;
  132. };
  133. CUtlVector<Page_t> m_Pages;
  134. CUtlVector<PageTab *> m_PageTabs;
  135. Panel *_activePage;
  136. PageTab *_activeTab;
  137. int _tabWidth;
  138. int _activeTabIndex;
  139. ComboBox *_combo;
  140. bool _showTabs;
  141. bool _tabFocus;
  142. PHandle m_hPreviouslyActivePage;
  143. float m_flPageTransitionEffectTime;
  144. bool m_bSmallTabs;
  145. HFont m_tabFont;
  146. bool m_bDraggableTabs;
  147. bool m_bContextButton;
  148. bool m_bKBNavigationEnabled;
  149. CPanelAnimationVarAliasType( int, m_iTabXIndent, "tabxindent", "0", "proportional_int" );
  150. CPanelAnimationVarAliasType( int, m_iTabXDelta, "tabxdelta", "0", "proportional_int" );
  151. CPanelAnimationVarAliasType( bool, m_bTabFitText, "tabxfittotext", "1", "bool" );
  152. //=============================================================================
  153. // HPE_BEGIN:
  154. // [tj] These variables have been split into the initially specified size
  155. // and the currently set size. This is so we can always recalculate the
  156. // new value for resolution changes.
  157. //=============================================================================
  158. CPanelAnimationVarAliasType( int, m_iSpecifiedTabHeight, "tabheight", "28", "int" );
  159. CPanelAnimationVarAliasType( int, m_iSpecifiedTabHeightSmall, "tabheight_small", "14", "int" );
  160. int m_iTabHeight;
  161. int m_iTabHeightSmall;
  162. //=============================================================================
  163. // HPE_END
  164. //=============================================================================
  165. KeyValues *m_pTabKV;
  166. int m_nPageDropTabVisibleTime;
  167. PageTab *m_pDragDropTab;
  168. PageTab *m_pTemporarilyRemoved;
  169. };
  170. }; // namespace vgui
  171. #endif // PROPERTYSHEET_H