OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
uibutton.h
1/*
2===========================================================================
3Copyright (C) 2024 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25extern Event W_Button_Pressed;
26
27class UIButtonBase : public UIWidget {
28protected:
29 mouseState_t m_mouseState;
30 str m_hoverSound;
31 str m_hoverCommand;
32 str m_mouseExitedCommand;
33
34public:
35 CLASS_PROTOTYPE( UIButtonBase );
36
37protected:
38 void Pressed( Event *ev );
39 void Released( Event *ev );
40 void MouseEntered( Event *ev );
41 void MouseExited( Event *ev );
42 void Dragged( Event *ev );
43 void SetHoverSound( Event *ev );
44 void SetHoverCommand( Event *ev );
45 void SetMouseExitedCommand( Event *ev );
46
47public:
48 UIButtonBase();
49
50 void Action( void );
51};
52
53class UIButton : public UIButtonBase {
54public:
55 CLASS_PROTOTYPE( UIButton );
56
57private:
58 void Draw( void ) override;
59 virtual void DrawPressed( void );
60 virtual void DrawUnpressed( void );
61
62public:
63 UIButton();
64
65 qboolean KeyEvent( int key, unsigned int time ) override;
66};
67
68class ToggleCVar : public USignal {
69protected:
70 str m_cvarname;
71 UIButton *m_button;
72
73protected:
74 CLASS_PROTOTYPE( ToggleCVar );
75
76 void Press( Event *ev );
77
78public:
79 ToggleCVar();
80 ToggleCVar( UIButton *button, const char *cvar );
81
82 void setCVar( const char *cvar );
83 void setButton( UIButton *button );
84};
85
86class ExecCmd : public USignal {
87protected:
88 UIButton *m_button;
89 str m_cmd;
90
91public:
92 CLASS_PROTOTYPE( ExecCmd );
93
94protected:
95 void Press( Event *ev );
96
97public:
98 ExecCmd();
99 ExecCmd( UIButton *button, const char *cmd );
100
101 void setCommand( const char *cmd );
102 void setButton( UIButton *button );
103};
Definition listener.h:246
Definition uibutton.h:53
Definition usignal.h:42
Definition str.h:77