TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Panel.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_PANEL_INCLUDED_
27 #define _TGUI_PANEL_INCLUDED_
28 
30 
31 namespace tgui
32 {
36  struct TGUI_API Panel : public GroupObject
37  {
41  Panel();
42 
43 
47  Panel(const Panel& copy);
48 
49 
53  virtual ~Panel();
54 
55 
59  Panel& operator= (const Panel& right);
60 
61 
65  virtual Panel* clone();
66 
67 
80  virtual bool load(float width, float height, const sf::Color& backgroundColor = sf::Color::Transparent, const std::string& backgroundImageFilename = "");
81 
82 
89  virtual void setSize(float width, float height);
90 
91 
95  virtual Vector2u getSize() const;
96 
97 
101  virtual Vector2f getScaledSize() const;
102 
103 
110  virtual bool setBackgroundImage(const std::string& filename = "");
111 
112 
118  virtual std::string getLoadedBackgroundImageFilename() const;
119 
120 
122  // These functions are used to receive callback from EventManager.
123  // These events are send to the childs of the panel by it's own EventManager.
124  // You normally don't need them, but you can use these functions to simulate an event.
126  virtual bool mouseOnObject(float x, float y);
127  virtual void objectFocused();
128  virtual void objectUnfocused();
129 
130 
132  // The objects inside the panel use this function to send their callbacks.
133  // This function will alert the window (or any other parent of this panel) about the callback.
135  virtual void addCallback(const Callback& callback);
136 
137 
139  protected:
140 
141 
143  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
144  // This function will be called and it will draw the panel on the render target.
146  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
147 
148 
150  public:
151 
153  sf::Color backgroundColor;
154 
155 
157  protected:
158 
159  Vector2f m_Size;
160 
161  sf::Texture* m_Texture;
162  sf::Sprite m_Sprite;
163 
164  std::string m_LoadedBackgroundImageFilename;
165 
167 
168 
169  friend struct Group;
170 
172  };
173 
175 }
176 
178 
179 #endif //_TGUI_PANEL_INCLUDED_
Definition: GroupObject.hpp:35
When you receive an action callback from an object then this struct will be passed as parameter...
Definition: Objects.hpp:362
Parent struct for objects that store multiple objects.
Definition: Group.hpp:38
sf::Color backgroundColor
The background color of the Panel. The default is a transparent background (sf::Color::Transparent).
Definition: Panel.hpp:153
A static group of objects. The background color can be solid or transparent.
Definition: Panel.hpp:36