TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
SpinButton.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012 Bruno Van de Velde (VDV_B@hotmail.com)
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_INCLUDED_
27 #define _TGUI_SPIN_BUTTON_INCLUDED_
28 
30 
31 namespace tgui
32 {
34 
35  struct TGUI_API SpinButton : public OBJECT
36  {
40  SpinButton();
41 
42 
46  SpinButton(const SpinButton& copy);
47 
48 
52  virtual ~SpinButton();
53 
54 
58  SpinButton& operator= (const SpinButton& right);
59 
60 
64  virtual SpinButton* clone();
65 
66 
81  virtual bool load(const std::string& pathname);
82 
83 
91  virtual void setSize(float width, float height);
92 
93 
97  virtual Vector2u getSize() const;
98 
99 
103  virtual Vector2f getScaledSize() const;
104 
105 
111  virtual std::string getLoadedPathname() const;
112 
113 
120  virtual void setMinimum(unsigned int minimum);
121 
122 
129  virtual void setMaximum(unsigned int maximum);
130 
131 
137  virtual void setValue(unsigned int value);
138 
139 
145  virtual unsigned int getMinimum() const;
146 
147 
153  virtual unsigned int getMaximum() const;
154 
155 
159  virtual unsigned int getValue() const;
160 
161 
163  // These functions are used to receive callback from the EventManager.
164  // You normally don't need them, but you can use them to simulate an event.
166  virtual bool mouseOnObject(float x, float y);
167  virtual void leftMousePressed(float x, float y);
168  virtual void leftMouseReleased(float x, float y);
169  virtual void mouseMoved(float x, float y);
170  virtual void objectFocused();
171 
172 
174  protected:
175 
177  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
178  // This function will be called and it will draw the spin button on the render target.
180  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
181 
182 
184  public:
185 
189 
190  protected:
191 
192  Vector2f m_Size;
193 
194  unsigned int m_Minimum;
195  unsigned int m_Maximum;
196  unsigned int m_Value;
197 
198  // Is there a separate hover image, or is it a semi-transparent image that is drawn on top of the others?
199  bool m_SeparateHoverImage;
200 
201  // On which arrow is the mouse?
202  bool m_MouseHoverOnTopArrow;
203  bool m_MouseDownOnTopArrow;
204 
205  sf::Texture* m_TextureNormal;
206  sf::Texture* m_TextureHover;
207 
208  sf::Sprite m_SpriteNormal;
209  sf::Sprite m_SpriteHover;
210 
211  // The pathname used to load the spin button
212  std::string m_LoadedPathname;
213  };
214 
216 }
217 
219 
220 #endif //_TGUI_SPIN_BUTTON_INCLUDED_
The parent struct for every object.
Definition: Objects.hpp:36
Definition: SpinButton.hpp:35
bool verticalScroll
Definition: SpinButton.hpp:188