TGUI  v0.6.10
Panel.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_PANEL_HPP
27 #define TGUI_PANEL_HPP
28 
29 
30 #include <TGUI/Container.hpp>
31 
33 
34 namespace tgui
35 {
39  class TGUI_API Panel : public Container
40  {
41  public:
42 
44 
45 
50  Panel();
51 
52 
59  Panel(const Panel& copy);
60 
61 
66  virtual ~Panel();
67 
68 
77  Panel& operator= (const Panel& right);
78 
79 
81  // Makes a copy of the widget by calling the copy constructor.
82  // This function calls new and if you use this function then you are responsible for calling delete.
84  virtual Panel* clone();
85 
86 
94  void setSize(float width, float height);
95 
96 
103  virtual sf::Vector2f getSize() const;
104 
105 
117  void setBackgroundTexture(sf::Texture *const texture = nullptr);
118 
119 
127  sf::Texture* getBackgroundTexture();
128 
129 
136  void setBackgroundColor(const sf::Color& backgroundColor);
137 
138 
145  const sf::Color& getBackgroundColor() const;
146 
147 
158  virtual void setTransparency(unsigned char transparency);
159 
160 
164  virtual bool mouseOnWidget(float x, float y);
165 
169  virtual void leftMousePressed(float x, float y);
170 
174  virtual void leftMouseReleased(float x, float y);
175 
179  virtual void mouseMoved(float x, float y);
180 
181 
184  // This function is a (slow) way to set properties on the widget, no matter what type it is.
185  // When the requested property doesn't exist in the widget then the functions will return false.
187  virtual bool setProperty(std::string property, const std::string& value);
188 
191  // This function is a (slow) way to get properties of the widget, no matter what type it is.
192  // When the requested property doesn't exist in the widget then the functions will return false.
194  virtual bool getProperty(std::string property, std::string& value) const;
195 
196 
199  // Returns a list of all properties that can be used in setProperty and getProperty.
200  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
202  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
203 
204 
206  protected:
207 
209  // Draws the widget on the render target.
211  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
212 
213 
215  public:
216 
221  {
222  LeftMousePressed = WidgetCallbacksCount * 1,
223  LeftMouseReleased = WidgetCallbacksCount * 2,
224  LeftMouseClicked = WidgetCallbacksCount * 4,
225  AllPanelCallbacks = WidgetCallbacksCount * 8 - 1,
226  PanelCallbacksCount = WidgetCallbacksCount * 8
227  };
228 
229 
231  protected:
232 
233  sf::Vector2f m_Size;
234 
235  sf::Color m_BackgroundColor;
236 
237  sf::Texture* m_Texture;
238  sf::Sprite m_Sprite;
239 
241 
242 
243  friend class Container;
244 
246  };
247 
249 }
250 
252 
253 #endif // TGUI_PANEL_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
A static container of widgets. The background color can be solid or transparent.
Definition: Panel.hpp:39
PanelCallbacks
Defines specific triggers to Panel.
Definition: Panel.hpp:220
Parent class for widgets that store multiple widgets.
Definition: Container.hpp:43
Definition: SharedWidgetPtr.hpp:44