TGUI  v0.6.10
LoadingBar.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_LOADING_BAR_HPP
27 #define TGUI_LOADING_BAR_HPP
28 
29 
30 #include <TGUI/ClickableWidget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API LoadingBar : public ClickableWidget
39  {
40  public:
41 
43 
44 
49  LoadingBar();
50 
51 
58  LoadingBar(const LoadingBar& copy);
59 
60 
65  virtual ~LoadingBar();
66 
67 
76  LoadingBar& operator= (const LoadingBar& 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 LoadingBar* clone();
84 
85 
95  bool load(const std::string& configFileFilename, const std::string& sectionName = "LoadingBar");
96 
97 
105  const std::string& getLoadedConfigFile() const;
106 
107 
115  void setSize(float width, float height);
116 
117 
126  void setMinimum(unsigned int minimum);
127 
128 
137  void setMaximum(unsigned int maximum);
138 
139 
148  void setValue(unsigned int value);
149 
150 
157  unsigned int getMinimum() const;
158 
159 
166  unsigned int getMaximum() const;
167 
168 
175  unsigned int getValue() const;
176 
177 
186  unsigned int incrementValue();
187 
188 
197  void setText(const sf::String& text);
198 
199 
206  sf::String getText() const;
207 
208 
218  void setTextFont(const sf::Font& font);
219 
220 
227  const sf::Font* getTextFont() const;
228 
229 
236  void setTextColor(const sf::Color& color);
237 
238 
245  const sf::Color& getTextColor() const;
246 
247 
255  void setTextSize(unsigned int size);
256 
257 
264  unsigned int getTextSize() const;
265 
266 
277  virtual void setTransparency(unsigned char transparency);
278 
279 
282  // This function is a (slow) way to set properties on the widget, no matter what type it is.
283  // When the requested property doesn't exist in the widget then the functions will return false.
285  virtual bool setProperty(std::string property, const std::string& value);
286 
289  // This function is a (slow) way to get properties of the widget, no matter what type it is.
290  // When the requested property doesn't exist in the widget then the functions will return false.
292  virtual bool getProperty(std::string property, std::string& value) const;
293 
294 
297  // Returns a list of all properties that can be used in setProperty and getProperty.
298  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
300  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
301 
302 
304  protected:
305 
307  // This function is called when the widget is added to a container.
309  virtual void initialize(Container *const container);
310 
311 
313  // When the value changes, or when the minimum/maximum limits change then a smaller of bigger piece of the front image
314  // must be drawn. This function is called to calculate the size of the piece to draw.
316  void recalculateSize();
317 
318 
320  // Draws the widget on the render target.
322  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
323 
324 
326  public:
327 
332  {
333  ValueChanged = ClickableWidgetCallbacksCount * 1,
334  LoadingBarFull = ClickableWidgetCallbacksCount * 2,
335  AllLoadingBarCallbacks = ClickableWidgetCallbacksCount * 4 - 1,
336  LoadingBarCallbacksCount = ClickableWidgetCallbacksCount * 4
337  };
338 
339 
341  protected:
342 
343  std::string m_LoadedConfigFile;
344 
345  unsigned int m_Minimum;
346  unsigned int m_Maximum;
347  unsigned int m_Value;
348 
349  // If this is true then the L, M and R images will be used.
350  // If it is false then the button is just one big image that will be stored in the M image.
351  bool m_SplitImage;
352 
353  Texture m_TextureBack_L;
354  Texture m_TextureBack_M;
355  Texture m_TextureBack_R;
356  Texture m_TextureFront_L;
357  Texture m_TextureFront_M;
358  Texture m_TextureFront_R;
359 
360  // The text that is (optionally) drawn on top of the loading bar
361  sf::Text m_Text;
362  unsigned int m_TextSize;
363  };
364 
366 }
367 
369 
370 #endif // TGUI_LOADING_BAR_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
Definition: TextureManager.hpp:52
Definition: ClickableWidget.hpp:38
Definition: LoadingBar.hpp:38
Parent class for widgets that store multiple widgets.
Definition: Container.hpp:43
LoadingBarCallbacks
Defines specific triggers to LoadingBar.
Definition: LoadingBar.hpp:331
Definition: SharedWidgetPtr.hpp:44