TGUI  v0.6.10
SpinButton.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_SPIN_BUTTON_HPP
27 #define TGUI_SPIN_BUTTON_HPP
28 
29 
30 #include <TGUI/ClickableWidget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API SpinButton : public ClickableWidget
39  {
40  public:
41 
43 
44 
49  SpinButton();
50 
51 
58  SpinButton(const SpinButton& copy);
59 
60 
65  virtual ~SpinButton();
66 
67 
76  SpinButton& operator= (const SpinButton& right);
77 
78 
80  // Makes a copy of the widget by calling the copy constructor.
81  // This function calls new and if you use this function then you are responsible for calling delete.
83  virtual SpinButton* clone();
84 
85 
95  bool load(const std::string& configFileFilename, const std::string& sectionName = "SpinButton");
96 
97 
105  const std::string& getLoadedConfigFile() const;
106 
107 
115  void setSize(float width, float height);
116 
117 
127  void setMinimum(unsigned int minimum);
128 
129 
139  void setMaximum(unsigned int maximum);
140 
141 
151  void setValue(unsigned int value);
152 
153 
162  unsigned int getMinimum() const;
163 
164 
173  unsigned int getMaximum() const;
174 
175 
184  unsigned int getValue() const;
185 
186 
193  void setVerticalScroll(bool verticallScroll);
194 
195 
202  bool getVerticalScroll() const;
203 
204 
215  virtual void setTransparency(unsigned char transparency);
216 
217 
221  virtual void leftMousePressed(float x, float y);
222 
226  virtual void leftMouseReleased(float x, float y);
227 
231  virtual void mouseMoved(float x, float y);
232 
236  virtual void widgetFocused();
237 
238 
241  // This function is a (slow) way to set properties on the widget, no matter what type it is.
242  // When the requested property doesn't exist in the widget then the functions will return false.
244  virtual bool setProperty(std::string property, const std::string& value);
245 
248  // This function is a (slow) way to get properties of the widget, no matter what type it is.
249  // When the requested property doesn't exist in the widget then the functions will return false.
251  virtual bool getProperty(std::string property, std::string& value) const;
252 
253 
256  // Returns a list of all properties that can be used in setProperty and getProperty.
257  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
259  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
260 
261 
263  protected:
264 
266  // Draws the widget on the render target.
268  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
269 
270 
272  public:
273 
278  {
279  ValueChanged = ClickableWidgetCallbacksCount * 1,
280  AllSpinButtonCallbacks = ClickableWidgetCallbacksCount * 2 - 1,
281  SpinButtonCallbacksCount = ClickableWidgetCallbacksCount * 2
282  };
283 
284 
286  protected:
287 
288  std::string m_LoadedConfigFile;
289 
290  // Is the spin button draw vertically (arrows on top of each other)?
291  bool m_VerticalScroll;
292 
293  unsigned int m_Minimum;
294  unsigned int m_Maximum;
295  unsigned int m_Value;
296 
297  // Is there a separate hover image, or is it a semi-transparent image that is drawn on top of the others?
298  bool m_SeparateHoverImage;
299 
300  // On which arrow is the mouse?
301  bool m_MouseHoverOnTopArrow;
302  bool m_MouseDownOnTopArrow;
303 
304  Texture m_TextureArrowUpNormal;
305  Texture m_TextureArrowUpHover;
306  Texture m_TextureArrowDownNormal;
307  Texture m_TextureArrowDownHover;
308  };
309 
311 }
312 
314 
315 #endif // TGUI_SPIN_BUTTON_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
Definition: TextureManager.hpp:52
SpinButtonCallbacks
Defines specific triggers to SpinButton.
Definition: SpinButton.hpp:277
Definition: ClickableWidget.hpp:38
Definition: SpinButton.hpp:38
Definition: SharedWidgetPtr.hpp:44