forked from sears2424/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuItem.h
136 lines (97 loc) · 3.77 KB
/
MenuItem.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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef MENUITEM_H
#define MENUITEM_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/VGUI.h>
#include <vgui_controls/Button.h>
#include <vgui_controls/Menu.h>
namespace vgui
{
class IBorder;
class TextImage;
class Menu;
class Image;
//-----------------------------------------------------------------------------
// Purpose: The items in a menu
// MenuItems MUST have the Menu class as parents.
//-----------------------------------------------------------------------------
class MenuItem : public Button
{
DECLARE_CLASS_SIMPLE( MenuItem, Button );
public:
MenuItem(Menu *parent, const char *panelName, const char *text, Menu *cascadeMenu = NULL, bool checkable = false);
MenuItem(Menu *parent, const char *panelName, const wchar_t *wszText, Menu *cascadeMenu = NULL, bool checkable = false);
~MenuItem();
virtual void Paint();
// Activate the menu item as if it had been selected by the user
virtual void FireActionSignal();
virtual bool CanBeDefaultButton(void);
// Handle mouse cursor entering a MenuItem.
void OnCursorEntered();
// Handle mouse cursor exiting a MenuItem.
void OnCursorExited();
// Close the cascading menu if we have one.
void CloseCascadeMenu();
// Pass kill focus events up to parent on loss of focus
MESSAGE_FUNC( OnKillFocus, "MenuClose" );
// Return true if this item triggers a cascading menu
bool HasMenu();
// Set the size of the text portion of the label.
void SetTextImageSize(int wide, int tall);
//Return the size of the text portion of the label.
void GetTextImageSize(int &wide, int &tall);
// Return the size of the arrow portion of the label.
void GetArrowImageSize(int &wide, int &tall);
// Return the size of the check portion of the label.
void GetCheckImageSize(int &wide, int &tall);
// Return the menu that this menuItem contains
Menu *GetMenu();
virtual void PerformLayout();
// Respond to cursor movement
void OnCursorMoved(int x, int y);
// Highlight item
MESSAGE_FUNC( ArmItem, "ArmItem" );
// Unhighlight item.
MESSAGE_FUNC( DisarmItem, "DisarmItem" );
// is the item highlighted?
bool IsItemArmed();
// Open cascading menu if there is one.
void OpenCascadeMenu();
bool IsCheckable();
bool IsChecked();
// Set a checkable menuItem checked or unchecked.
void SetChecked(bool state);
KeyValues *GetUserData();
void SetUserData(const KeyValues *kv);
int GetActiveItem() { if ( m_pCascadeMenu ) { return m_pCascadeMenu->GetActiveItem(); } else { return 0; }}
Menu *GetParentMenu();
void SetCurrentKeyBinding( char const *keyName );
virtual void GetContentSize( int& cw, int &ch );
protected:
void OnKeyCodeReleased(KeyCode code);
void OnMenuClose();
MESSAGE_FUNC( OnKeyModeSet, "KeyModeSet" );
// vgui overrides
virtual void Init( void );
virtual void ApplySchemeSettings(IScheme *pScheme);
virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
private:
enum { CHECK_INSET = 6 };
Menu *m_pCascadeMenu; // menu triggered to open upon selecting this menu item
bool m_bCheckable; // can this menu item have a little check to the left of it when you select it?
bool m_bChecked; // whether item is checked or not.
TextImage *m_pCascadeArrow; // little arrow that appears to the right of menuitems that open a menu
Image *m_pCheck; // the check that appears to the left of checked menu items
TextImage *m_pBlankCheck; // a blank image same size as the check for when items are not checked.
TextImage *m_pCurrentKeyBinding; // An optional indicator for the key currently bound to this menu item
KeyValues *m_pUserData;
};
} // namespace vgui
#endif // MENUITEM_H