TGUI  v0.6.10
Label.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_LABEL_HPP
27 #define TGUI_LABEL_HPP
28 
29 
30 #include <TGUI/ClickableWidget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API Label : public ClickableWidget
39  {
40  public:
41 
43 
44 
49  Label();
50 
51 
56  virtual ~Label();
57 
58 
60  // Makes a copy of the widget by calling the copy constructor.
61  // This function calls new and if you use this function then you are responsible for calling delete.
63  virtual Label* clone();
64 
65 
75  bool load(const std::string& configFileFilename, const std::string& sectionName = "Label");
76 
77 
85  const std::string& getLoadedConfigFile() const;
86 
87 
104  virtual void setSize(float width, float height);
105 
106 
120  virtual void setPosition(float x, float y);
122 
123 
134  void setText(const sf::String& text);
135 
136 
143  const sf::String& getText() const;
144 
145 
155  void setTextFont(const sf::Font& font);
156 
157 
164  const sf::Font* getTextFont() const;
165 
166 
173  void setTextColor(const sf::Color& color);
174 
175 
182  const sf::Color& getTextColor() const;
183 
184 
195  void setTextStyle(sf::Uint32 style);
196 
197 
204  sf::Uint32 getTextStyle() const;
205 
206 
213  void setTextSize(unsigned int size);
214 
215 
222  unsigned int getTextSize() const;
223 
224 
236  void setBackgroundColor(const sf::Color& backgroundColor);
237 
238 
247  const sf::Color& getBackgroundColor() const;
248 
249 
261  virtual void setAutoSize(bool autoSize);
262 
263 
270  virtual bool getAutoSize() const;
271 
272 
275  // This function is a (slow) way to set properties on the widget, no matter what type it is.
276  // When the requested property doesn't exist in the widget then the functions will return false.
278  virtual bool setProperty(std::string property, const std::string& value);
279 
282  // This function is a (slow) way to get properties of 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 getProperty(std::string property, std::string& value) const;
286 
287 
290  // Returns a list of all properties that can be used in setProperty and getProperty.
291  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
293  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
294 
295 
297  protected:
298 
300  // This function is called when the widget is added to a container.
302  virtual void initialize(Container *const container);
303 
304 
306  // Draws the widget on the render target.
308  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
309 
310 
312  public:
313 
318  {
319  AllLabelCallbacks = ClickableWidgetCallbacksCount - 1,
320  LabelCallbacksCount = ClickableWidgetCallbacksCount
321  };
322 
323 
325  protected:
326 
327  std::string m_LoadedConfigFile;
328 
329  sf::RectangleShape m_Background;
330 
331  sf::Text m_Text;
332 
333  bool m_AutoSize;
334 
336  };
337 
339 }
340 
342 
343 #endif // TGUI_LABEL_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
LabelCallbacks
Defines specific triggers to Label.
Definition: Label.hpp:317
virtual void setPosition(float x, float y)
Set the position of the widget.
Definition: Label.hpp:38
Definition: ClickableWidget.hpp:38
Parent class for widgets that store multiple widgets.
Definition: Container.hpp:43