TGUI  0.7.4
Callback.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012-2017 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_CALLBACK_HPP
27 #define TGUI_CALLBACK_HPP
28 
29 #include <map>
30 #include <list>
31 #include <functional>
32 
33 #include <TGUI/Global.hpp>
34 
36 
37 namespace tgui
38 {
39  class Widget;
40 
42  // Struct that tells more about the callback that happened.
44  struct TGUI_API Callback
45  {
46  // The callback id that was passed to the widget. It is used to identify from what widget the callback came from.
47  unsigned int id = 0;
48 
49  // How did the callback occur?
50  std::string trigger;
51 
52  // Pointer to the widget
53  Widget* widget = nullptr;
54 
55  // The type of the widget
56  std::string widgetType = "Unknown";
57 
58  // When the mouse has something to do with the callback then this data will be filled
59  sf::Vector2i mouse;
60 
61  // This text is only used by some widgets, but it can be set together with some other member
62  sf::String text;
63 
64  // Used to identify an item
65  sf::String itemId;
66 
67  // Only one of these things can be filled at a given time
68  bool checked = false;
69  int value = 0;
70  unsigned int index = 0;
71  sf::Vector2f value2d;
72  sf::Vector2f position;
73  sf::Vector2f size;
74  };
75 
77 }
78 
80 
81 #endif // TGUI_CALLBACK_HPP
82 
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
The parent class for every widget.
Definition: Widget.hpp:71
Definition: Callback.hpp:44