Line data Source code
1 : /* Copyright (C) 2025 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #ifndef INCLUDED_SGUIMESSAGE
19 : #define INCLUDED_SGUIMESSAGE
20 :
21 : #include "lib/code_annotation.h"
22 : #include "ps/CStr.h"
23 :
24 : /**
25 : * Message types.
26 : * @see SGUIMessage
27 : */
28 : enum EGUIMessageType
29 : {
30 : GUIM_MOUSE_OVER,
31 : GUIM_MOUSE_ENTER,
32 : GUIM_MOUSE_LEAVE,
33 : GUIM_MOUSE_PRESS_LEFT,
34 : GUIM_MOUSE_PRESS_LEFT_ITEM,
35 : GUIM_MOUSE_PRESS_RIGHT,
36 : GUIM_MOUSE_DOWN_LEFT,
37 : GUIM_MOUSE_DOWN_RIGHT,
38 : GUIM_MOUSE_DBLCLICK_LEFT,
39 : GUIM_MOUSE_DBLCLICK_LEFT_ITEM, // Triggered when doubleclicking on a list item.
40 : GUIM_MOUSE_DBLCLICK_RIGHT,
41 : GUIM_MOUSE_RELEASE_LEFT,
42 : GUIM_MOUSE_RELEASE_RIGHT,
43 : GUIM_MOUSE_WHEEL_UP,
44 : GUIM_MOUSE_WHEEL_DOWN,
45 : GUIM_MOUSE_WHEEL_LEFT,
46 : GUIM_MOUSE_WHEEL_RIGHT,
47 : GUIM_SETTINGS_UPDATED, // SGUIMessage.m_Value = name of setting.
48 : GUIM_PRESSED,
49 : GUIM_KEYDOWN,
50 : GUIM_RELEASED,
51 : GUIM_DOUBLE_PRESSED,
52 : GUIM_MOUSE_MOTION,
53 : GUIM_LOAD, // Called after all objects were added to the GUI.
54 : GUIM_GOT_FOCUS,
55 : GUIM_LOST_FOCUS,
56 : GUIM_PRESSED_MOUSE_RIGHT,
57 : GUIM_PRESSED_MOUSE_RIGHT_DISABLED,
58 : GUIM_DOUBLE_PRESSED_MOUSE_RIGHT,
59 : GUIM_PRESSED_MOUSE_RELEASE,
60 : GUIM_PRESSED_MOUSE_RELEASE_RIGHT,
61 : GUIM_TAB, // Used by CInput.
62 : GUIM_TEXTEDIT,
63 : GUIM_CHILD_RESIZED, // SGUIMessage.m_Value = name of the object that changed size, used for inform to parent.
64 : GUIM_CHILD_TOGGLE_VISIBILITY, // SGUIMessage.m_Value = name of the object that changed visibility used for inform to parent.
65 : };
66 :
67 : /**
68 : * Message send to IGUIObject::HandleMessage() in order
69 : * to give life to Objects manually with
70 : * a derived HandleMessage().
71 : */
72 22 : struct SGUIMessage
73 : {
74 : // This should be passed as a const reference or pointer.
75 : NONCOPYABLE(SGUIMessage);
76 :
77 17 : SGUIMessage(EGUIMessageType _type) : type(_type), skipped(false) {}
78 5 : SGUIMessage(EGUIMessageType _type, const CStr& _value) : type(_type), value(_value), skipped(false) {}
79 :
80 : /**
81 : * This method can be used to allow other event handlers to process this GUI event,
82 : * by default an event is not skipped (only the first handler will process it).
83 : *
84 : * @param skip true to allow further event handling, false to prevent it
85 : */
86 0 : void Skip(bool skip = true) { skipped = skip; }
87 :
88 : /**
89 : * Describes what the message regards
90 : */
91 : EGUIMessageType type;
92 :
93 : /**
94 : * Optional data
95 : */
96 : CStr value;
97 :
98 : /**
99 : * Flag that specifies if object skipped handling the event
100 : */
101 : bool skipped;
102 : };
103 :
104 : #endif // INCLUDED_SGUIMESSAGE
|