forked from sears2424/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuButton.h
82 lines (61 loc) · 2.22 KB
/
MenuButton.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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef MENUBUTTON_H
#define MENUBUTTON_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui_controls/Button.h>
#include "vgui_controls/Menu.h"
namespace vgui
{
class Menu;
class TextImage;
//-----------------------------------------------------------------------------
// Purpose: Button that displays a menu when pressed
//-----------------------------------------------------------------------------
class MenuButton : public Button
{
DECLARE_CLASS_SIMPLE( MenuButton, Button );
public:
MenuButton(Panel *parent, const char *panelName, const char *text);
~MenuButton();
// functions designed to be overriden
virtual void OnShowMenu(Menu *menu) {}
virtual void OnHideMenu(Menu *menu) {}
virtual int OnCheckMenuItemCount() { return 0; }
virtual void SetMenu(Menu *menu);
virtual void HideMenu(void);
virtual void DrawFocusBorder(int tx0, int ty0, int tx1, int ty1);
MESSAGE_FUNC( OnMenuClose, "MenuClose" );
MESSAGE_FUNC_PARAMS( OnKillFocus, "KillFocus", kv ); // called after the panel loses the keyboard focus
virtual void DoClick();
virtual void SetOpenOffsetY(int yOffset);
virtual bool CanBeDefaultButton(void);
// sets the direction in which the menu opens from the button, defaults to down
virtual void SetOpenDirection(Menu::MenuDirection_e direction);
virtual void OnKeyCodeTyped(KeyCode code);
virtual void OnCursorEntered();
virtual void Paint();
virtual void PerformLayout();
virtual void ApplySchemeSettings( IScheme *pScheme );
virtual void OnCursorMoved( int x, int y );
// This style is like the IE "back" button where the left side acts like a regular button, the the right side has a little
// combo box dropdown indicator and presents and submenu
void SetDropMenuButtonStyle( bool state );
bool IsDropMenuButtonStyle() const;
Menu *GetMenu();
private:
Menu *m_pMenu;
Menu::MenuDirection_e m_iDirection;
int _openOffsetY; // vertical offset of menu from the menu button
bool m_bDropMenuButtonStyle : 1;
TextImage *m_pDropMenuImage;
int m_nImageIndex;
};
}; // namespace vgui
#endif // MENUBUTTON_H