TGUI  v0.6.10
ClickableWidget.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012-2015 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_CLICKABLE_WIDGET_HPP
27 #define TGUI_CLICKABLE_WIDGET_HPP
28 
29 
30 #include <TGUI/Widget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API ClickableWidget : public Widget
39  {
40  public:
41 
43 
44 
50 
51 
58  ClickableWidget(const ClickableWidget& copy);
59 
60 
65  virtual ~ClickableWidget();
66 
67 
76  ClickableWidget& operator= (const ClickableWidget& right);
77 
78 
81  // Makes a copy of the widget by calling the copy constructor.
82  // This function calls new and if you use this function then you are responsible for calling delete.
84  virtual ClickableWidget* clone();
85 
86 
94  virtual void setSize(float width, float height);
95 
96 
103  virtual sf::Vector2f getSize() const;
104 
105 
109  virtual bool mouseOnWidget(float x, float y);
110 
114  virtual void leftMousePressed(float x, float y);
115 
119  virtual void leftMouseReleased(float x, float y);
120 
121 
124  // This function is a (slow) way to set properties on the widget, no matter what type it is.
125  // When the requested property doesn't exist in the widget then the functions will return false.
127  virtual bool setProperty(std::string property, const std::string& value);
128 
131  // This function is a (slow) way to get properties of the widget, no matter what type it is.
132  // When the requested property doesn't exist in the widget then the functions will return false.
134  virtual bool getProperty(std::string property, std::string& value) const;
135 
136 
138  protected:
139 
142  // This function draws nothing.
144  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
145 
146 
148  public:
149 
154  {
155  LeftMousePressed = WidgetCallbacksCount * 1,
156  LeftMouseReleased = WidgetCallbacksCount * 2,
157  LeftMouseClicked = WidgetCallbacksCount * 4,
158  AllClickableWidgetCallbacks = WidgetCallbacksCount * 8 - 1,
159  ClickableWidgetCallbacksCount = WidgetCallbacksCount * 8
160  };
161 
162 
164  protected:
165 
166  // The size of the widget
167  sf::Vector2f m_Size;
168  };
169 
171 }
172 
174 
175 #endif // TGUI_CLICKABLE_WIDGET_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
The parent class for every widget.
Definition: Widget.hpp:45
Definition: ClickableWidget.hpp:38
ClickableWidgetCallbacks
Defines specific triggers to ClickableWidget.
Definition: ClickableWidget.hpp:153
Definition: SharedWidgetPtr.hpp:44