TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Scrollbar.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_SCROLLBAR_INCLUDED_
27 #define _TGUI_SCROLLBAR_INCLUDED_
28 
30 
31 namespace tgui
32 {
34 
35  struct TGUI_API Scrollbar : public Slider
36  {
40  Scrollbar();
41 
42 
46  Scrollbar(const Scrollbar& copy);
47 
48 
52  virtual ~Scrollbar();
53 
54 
58  Scrollbar& operator= (const Scrollbar& right);
59 
60 
64  virtual Scrollbar* clone();
65 
66 
82  virtual bool load(const std::string& pathname);
83 
84 
91  virtual void setMinimum(unsigned int minimum);
92 
93 
99  virtual void setValue(unsigned int value);
100 
101 
109  virtual void setLowValue(unsigned int lowValue);
110 
111 
117  virtual unsigned int getLowValue() const;
118 
119 
121  // These functions are used to receive callback from the EventManager.
122  // You normally don't need them, but you can use them to simulate an event.
124  virtual bool mouseOnObject(float x, float y);
125  virtual void leftMousePressed(float x, float y);
126  virtual void leftMouseReleased(float x, float y);
127  virtual void mouseMoved(float x, float y);
128 
129 
131  protected:
132 
134  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
135  // This function will be called and it will draw the scrollbar on the render target.
137  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
138 
139 
141  public:
142 
144  bool autoHide;
145 
146 
148  protected:
149 
150  // Maximum should be above this value before the scrollbar is needed
151  unsigned int m_LowValue;
152 
153  // Did the mouse went down on one of the arrows?
154  bool m_MouseDownOnArrow;
155 
156  sf::Texture* m_TextureArrowNormal;
157  sf::Texture* m_TextureArrowHover;
158 
159  sf::Sprite m_SpriteArrowNormal;
160  sf::Sprite m_SpriteArrowHover;
161 
162 
163  // ListBox, ComboBox and TextBox can access the scrollbar directly
164  friend struct ListBox;
165  friend struct ComboBox;
166  friend struct TextBox;
167  friend struct ChatBox;
168 
170 
171  };
172 
174 }
175 
177 
178 #endif //_TGUI_SCROLLBAR_INCLUDED_
Definition: Scrollbar.hpp:35
Definition: TextBox.hpp:44
Definition: ListBox.hpp:37
Definition: ChatBox.hpp:37
bool autoHide
When true (default), the scrollbar will not be drawn when the maximum is below the low value...
Definition: Scrollbar.hpp:144
Definition: Slider.hpp:35
Definition: ComboBox.hpp:35