ComponentEvent.hpp
1 /*
2  * Copyright © 2013 mathdu07
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program 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 Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef COMPONENT_EVENT_H_
19 #define COMPONENT_EVENT_H_
20 
21 #include <SFML/Window.hpp>
22 #include <SFML/UI/Format/Format.hpp>
23 
24 #include <SFML/UI/Component.hpp>
25 #include <SFML/UI/Focusable.hpp>
26 #include <SFML/UI/AbstractButton.hpp>
27 #include <SFML/UI/CheckBox.hpp>
28 #include <SFML/UI/TextField.hpp>
29 #include <SFML/UI/FormattedTextField.hpp>
30 #include <SFML/UI/KeyField.hpp>
31 
32 namespace sf
33 {
34 namespace ui
35 {
36 
38 {
39 public:
46  {
47  AbstractButton* source;
48  sf::Mouse::Button button;
49  int x;
50  int y;
51  };
52 
59  {
60  AbstractButton* source;
61  unsigned int finger;
62  int x;
63  int y;
64  };
65 
72  {
73  CheckBox* source;
74  bool selected;
75  };
76 
77 
83  struct FocusedEvent
84  {
85  Focusable* source;
86  bool focused;
87  };
88 
95  {
96  FormattedTextField* source;
97  Format* format;
98  };
99 
107  {
108  KeyField* source;
109  sf::Keyboard::Key key;
110  };
111 
118  struct TextEvent
119  {
120  TextField* source;
121  sf::Uint32 text;
122  unsigned int position;
123  };
124 
131  {
132  ButtonClicked,
133  ButtonTouched,
134  CheckBoxChanged,
135  FocusGained,
136  FocusLost,
137  FormattedValueEntered,
138  KeyFieldSet,
139  TextEntered,
140  TextDeleted
141  };
142 
143  ComponentEventType type;
144  Component* source;
145 
146  union
147  {
148  ButtonClickedEvent buttonClick;
149  ButtonTouchedEvent buttonTouch;
150  CheckBoxChangeEvent checkBoxChange;
151  FocusedEvent focus;
152  FormattedValueEnteredEvent formattedValueEnter;
153  KeyFieldSetEvent keyFieldSet;
154  TextEvent text;
155  };
156 
157 };
158 
159 
160 }
161 }
162 
163 #endif
164 
An event that is triggered each time a button is fired.
A box which can be checked or not.
Definition: CheckBox.hpp:29
The base class for all UI components that can be focused.
Definition: Focusable.hpp:28
An event that is triggered each time a component change its focus status.
An event that is triggered each time a check box switch from unselected to selected, and vice-versa.
A formatted text field which stores a value defined by a sf::ui::Format It can be a sf::Int64...
The base class for all UI components.
Definition: Component.hpp:29
An event related to a formatted value entered (e.g on sf::ui::FormattedTextField) ...
An event generate by a component.
A text field which stores a text.
Definition: TextField.hpp:30
An event that is triggered each time a key is set.
An event that is triggered each time a button is fired, touched (on mobile OSs)
Abstract class for all component that are button-like.
ComponentEventType
Enumeration of component events.
The abstract class that defines format of various types, such as ints, double, objects ...
Definition: Format.hpp:28
A field that stores a keyboard's key Not supported on mobile platforms.
Definition: KeyField.hpp:30
An event that is triggered each time a text is entered/deleted Triggered only with TextField...