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