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.

265 lines
8.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VGUI_FRAME_H
  8. #define VGUI_FRAME_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/vgui.h>
  13. #include <vgui/Dar.h>
  14. #include <vgui_controls/Panel.h>
  15. #include <vgui_controls/EditablePanel.h>
  16. #include <vgui_controls/FocusNavGroup.h>
  17. namespace vgui
  18. {
  19. class FrameButton;
  20. class FrameSystemButton;
  21. //-----------------------------------------------------------------------------
  22. // Purpose: Windowed frame
  23. //-----------------------------------------------------------------------------
  24. class Frame : public EditablePanel
  25. {
  26. DECLARE_CLASS_SIMPLE( Frame, EditablePanel );
  27. public:
  28. Frame(Panel *parent, const char *panelName, bool showTaskbarIcon = true, bool bPopup = true );
  29. virtual ~Frame();
  30. // Set the text in the title bar. Set surfaceTitle=true if you want this to be the taskbar text as well.
  31. virtual void SetTitle(const char *title, bool surfaceTitle);
  32. virtual void SetTitle(const wchar_t *title, bool surfaceTitle);
  33. // Bring the frame to the front and requests focus, ensures it's not minimized
  34. virtual void Activate();
  35. // activates the dialog; if dialog is not currently visible it starts it minimized and flashing in the taskbar
  36. virtual void ActivateMinimized();
  37. // closes the dialog
  38. MESSAGE_FUNC( Close, "Close" );
  39. MESSAGE_FUNC( CloseModal, "CloseModal" );
  40. // sets the dialog to delete self on close
  41. virtual void SetDeleteSelfOnClose( bool state );
  42. // Move the dialog to the center of the screen
  43. virtual void MoveToCenterOfScreen();
  44. // Set the movability of the panel
  45. virtual void SetMoveable(bool state);
  46. // Check the movability of the panel
  47. virtual bool IsMoveable();
  48. // Set the resizability of the panel
  49. virtual void SetSizeable(bool state);
  50. // Check the resizability of the panel
  51. virtual bool IsSizeable();
  52. // Toggle visibility of the system menu button
  53. virtual void SetMenuButtonVisible(bool state);
  54. void SetMenuButtonResponsive(bool state);
  55. // Toggle visibility of the minimize button
  56. virtual void SetMinimizeButtonVisible(bool state);
  57. // Toggle visibility of the maximize button
  58. virtual void SetMaximizeButtonVisible(bool state);
  59. // Toggles visibility of the minimize-to-systray icon (defaults to false)
  60. virtual void SetMinimizeToSysTrayButtonVisible(bool state);
  61. // Toggle visibility of the close button
  62. virtual void SetCloseButtonVisible(bool state);
  63. // returns true if the dialog is currently minimized
  64. virtual bool IsMinimized();
  65. // Flash the window system tray button until the frame gets focus
  66. virtual void FlashWindow();
  67. // Stops any window flashing
  68. virtual void FlashWindowStop();
  69. // command handling
  70. virtual void OnCommand(const char *command);
  71. // Get the system menu
  72. virtual Menu *GetSysMenu();
  73. // Set the system menu
  74. virtual void SetSysMenu(Menu *menu);
  75. // Set the system menu images
  76. void SetImages( const char *pEnabledImage, const char *pDisabledImage = NULL );
  77. // set whether the title bar should be rendered
  78. virtual void SetTitleBarVisible( bool state );
  79. // When moving via caption, don't let any part of window go outside parent's bounds
  80. virtual void SetClipToParent( bool state );
  81. virtual bool GetClipToParent() const;
  82. // Set to true to make the caption height small
  83. virtual void SetSmallCaption( bool state );
  84. virtual bool IsSmallCaption() const;
  85. virtual int GetDraggerSize();
  86. virtual int GetCornerSize();
  87. virtual int GetBottomRightSize();
  88. virtual int GetCaptionHeight();
  89. /* CUSTOM MESSAGE HANDLING
  90. "SetTitle"
  91. input: "text" - string to set the title to be
  92. */
  93. // Load the control settings
  94. virtual void LoadControlSettings( const char *dialogResourceName, const char *pathID = NULL, KeyValues *pPreloadedKeyValues = NULL, KeyValues *pConditions = NULL );
  95. void SetChainKeysToParent( bool state );
  96. bool CanChainKeysToParent() const;
  97. // Shows the dialog in a modal fashion
  98. virtual void DoModal();
  99. void PlaceUnderCursor( );
  100. // Disables the fade-in/out-effect even if configured in the scheme settings
  101. void DisableFadeEffect( void );
  102. // Temporarily enables or disables the fade effect rather than zeroing the fade times as done in DisableFadeEffect
  103. void SetFadeEffectDisableOverride( bool disabled );
  104. virtual void OnGripPanelMoved( int nNewX, int nNewY, int nNewW, int nNewH );
  105. virtual void OnGripPanelMoveFinished() {}
  106. protected:
  107. // Respond to mouse presses
  108. virtual void OnMousePressed(MouseCode code);
  109. // Respond to Key typing
  110. virtual void OnKeyCodeTyped(KeyCode code);
  111. virtual void OnKeyTyped(wchar_t unichar);
  112. // Respond to Key releases
  113. virtual void OnKeyCodeReleased(KeyCode code);
  114. // Respond to Key focus ticks
  115. virtual void OnKeyFocusTicked();
  116. virtual void ApplySchemeSettings(IScheme *pScheme);
  117. // Recalculate the position of all items
  118. virtual void PerformLayout();
  119. // Respond when a close message is recieved. Can be called directly to close a frame.
  120. virtual void OnClose();
  121. // Respond to a window finishing its closure. i.e. when a fading window has fully finished its fadeout.
  122. virtual void OnFinishedClose();
  123. // Minimize the window on the taskbar.
  124. MESSAGE_FUNC( OnMinimize, "Minimize" );
  125. // Called when minimize-to-systray button is pressed (does nothing by default)
  126. virtual void OnMinimizeToSysTray();
  127. // the frame close button was pressed
  128. MESSAGE_FUNC( OnCloseFrameButtonPressed, "CloseFrameButtonPressed" );
  129. // Add the child to the focus nav group
  130. virtual void OnChildAdded(VPANEL child);
  131. // settings
  132. virtual void ApplySettings(KeyValues *inResourceData);
  133. // records the settings into the resource data
  134. virtual void GetSettings(KeyValues *outResourceData);
  135. virtual const char *GetDescription( void );
  136. // gets the default position and size on the screen to appear the first time (defaults to centered)
  137. virtual bool GetDefaultScreenPosition(int &x, int &y, int &wide, int &tall);
  138. // painting
  139. virtual void PaintBackground();
  140. // per-frame thinking, used for transition effects
  141. virtual void OnThink();
  142. // screen size
  143. virtual void OnScreenSizeChanged(int iOldWide, int iOldTall);
  144. // Get the size of the panel inside the frame edges.
  145. virtual void GetClientArea(int &x, int &y, int &wide, int &tall);
  146. // user configuration settings
  147. // this is used for any control details the user wants saved between sessions
  148. // eg. dialog positions, last directory opened, list column width
  149. virtual void ApplyUserConfigSettings(KeyValues *userConfig);
  150. // returns user config settings for this control
  151. virtual void GetUserConfigSettings(KeyValues *userConfig);
  152. // optimization, return true if this control has any user config settings
  153. virtual bool HasUserConfigSettings();
  154. virtual void GetSizerClientArea(int &x, int &y, int &wide, int &tall);
  155. private:
  156. MESSAGE_FUNC_CHARPTR( InternalSetTitle, "SetTitle", text );
  157. MESSAGE_FUNC( InternalFlashWindow, "FlashWindow" );
  158. MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables );
  159. void SetupResizeCursors();
  160. void LayoutProportional( FrameButton *bt);
  161. void FinishClose();
  162. void OnFrameFocusChanged(bool bHasFocus);
  163. Color _titleBarBgColor;
  164. Color _titleBarDisabledBgColor;
  165. Color _titleBarFgColor;
  166. Color _titleBarDisabledFgColor;
  167. Color m_InFocusBgColor;
  168. Color m_OutOfFocusBgColor;
  169. TextImage *_title;
  170. #if !defined( _GAMECONSOLE )
  171. Panel *_topGrip;
  172. Panel *_bottomGrip;
  173. Panel *_leftGrip;
  174. Panel *_rightGrip;
  175. Panel *_topLeftGrip;
  176. Panel *_topRightGrip;
  177. Panel *_bottomLeftGrip;
  178. Panel *_bottomRightGrip;
  179. Panel *_captionGrip;
  180. FrameButton *_minimizeButton;
  181. FrameButton *_maximizeButton;
  182. FrameButton *_minimizeToSysTrayButton;
  183. FrameButton *_closeButton;
  184. FrameSystemButton *_menuButton;
  185. Menu *_sysMenu;
  186. #endif
  187. float m_flTransitionEffectTime;
  188. float m_flFocusTransitionEffectTime;
  189. int m_iClientInsetX;
  190. int m_iClientInsetY;
  191. int m_iTitleTextInsetX;
  192. int m_nGripperWidth;
  193. VPANEL m_hPreviousModal;
  194. HFont m_hCustomTitleFont;
  195. bool _sizeable : 1;
  196. bool _moveable : 1;
  197. bool m_bHasFocus : 1;
  198. bool _flashWindow : 1;
  199. bool _nextFlashState : 1;
  200. bool _drawTitleBar : 1;
  201. bool m_bPreviouslyVisible : 1;
  202. bool m_bFadingOut : 1;
  203. bool m_bDeleteSelfOnClose : 1;
  204. bool m_bDisableFadeEffect : 1;
  205. bool m_bClipToParent : 1;
  206. bool m_bSmallCaption : 1;
  207. bool m_bChainKeysToParent : 1;
  208. bool m_bPrimed : 1;
  209. bool m_iClientInsetXOverridden : 1;
  210. CPanelAnimationVarAliasType( int, m_iTitleTextInsetXOverride, "titletextinsetX", "0", "proportional_int" );
  211. CPanelAnimationVarAliasType( int, m_iTitleTextInsetYOverride, "titletextinsetY", "0", "proportional_int" );
  212. };
  213. } // namespace vgui
  214. #endif // VGUI_FRAME_H