TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Label.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_LABEL_INCLUDED_
27 #define _TGUI_LABEL_INCLUDED_
28 
30 
31 namespace tgui
32 {
34 
35  struct TGUI_API Label : public OBJECT
36  {
40  Label();
41 
42 
46  virtual void initialize();
47 
48 
52  virtual Label* clone();
53 
54 
63  virtual void load(float width, float height, const sf::Color& bkgColor = sf::Color::Transparent);
64 
65 
75  virtual void setSize(float width, float height);
76 
77 
81  virtual Vector2u getSize() const;
82 
83 
87  virtual Vector2f getScaledSize() const;
88 
89 
97  virtual void setText(const sf::String& text);
98 
99 
103  virtual sf::String getText() const;
104 
105 
112  virtual void setTextFont(const sf::Font& font);
113 
114 
118  virtual const sf::Font* getTextFont() const;
119 
120 
124  virtual void setTextColor(const sf::Color& color);
125 
126 
130  virtual const sf::Color& getTextColor() const;
131 
132 
136  virtual void setTextSize(unsigned int size);
137 
138 
142  virtual unsigned int getTextSize() const;
143 
144 
153  virtual void setAutoSize(bool autoSize);
154 
155 
161  virtual bool getAutoSize() const;
162 
163 
165  // With these function, Label comunicates with EventManager.
166  // You normally don't need them, but you can use them to simulate an event.
168  virtual bool mouseOnObject(float x, float y);
169  virtual void leftMousePressed(float x, float y);
170  virtual void leftMouseReleased(float x, float y);
171 
172 
174  protected:
175 
176 
178  // Because this struct is derived from sf::Drawable, you can just call the Draw function from your sf::RenderTarget.
179  // This function will be called and it will draw the button on the render target.
181  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
182 
183 
185  public:
186 
188  sf::Color backgroundColor;
189 
190 
192  protected:
193 
194  sf::Text m_Text;
195 
196  Vector2f m_Size;
197 
198  bool m_AutoSize;
199 
201  };
202 
204 }
205 
207 
208 #endif //_TGUI_LABEL_INCLUDED_
sf::Color backgroundColor
The background color of the label. Transparent by default.
Definition: Label.hpp:188
The parent struct for every object.
Definition: Objects.hpp:36
Definition: Label.hpp:35