TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
ChildWindow.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_CHILD_WINDOW_INCLUDED_
27 #define _TGUI_CHILD_WINDOW_INCLUDED_
28 
30 
31 namespace tgui
32 {
36  struct TGUI_API ChildWindow : public Panel, OBJECT_BORDERS
37  {
38 
39  // Layouts
40  enum Layout
41  {
42  LayoutLeft,
43  LayoutRight
44  };
45 
46  // Title alignments
47  enum TitleAlignment
48  {
49  TitleAlignmentLeft,
50  TitleAlignmentCentered,
51  TitleAlignmentRight
52  };
53 
54 
58  ChildWindow();
59 
60 
64  ChildWindow(const ChildWindow& copy);
65 
66 
70  virtual ~ChildWindow();
71 
72 
76  ChildWindow& operator= (const ChildWindow& right);
77 
78 
82  virtual ChildWindow* clone();
83 
84 
100  virtual bool load(float width, float height, const sf::Color& backgroundColor, const std::string& pathname);
101 
102 
108  virtual std::string getLoadedPathname() const;
109 
110 
117  virtual bool setBackgroundImage(const std::string& filename = "");
118 
119 
125  virtual void setTitlebarHeight(unsigned int height);
126 
127 
131  virtual unsigned int getTitleBarHeight() const;
132 
133 
142  virtual void setTransparency(unsigned char transparency);
143 
144 
148  virtual unsigned char getTransparency() const;
149 
150 
159  virtual void setBorders(unsigned int leftBorder = 0,
160  unsigned int topBorder = 0,
161  unsigned int rightBorder = 0,
162  unsigned int bottomBorder = 0);
163 
164 
166  // With this function, the child window will tell the EventManager if the mouse is on top of it or not.
168  virtual bool mouseOnObject(float x, float y);
169 
170 
172  protected:
173 
175  // Send the event to all underlying objects.
177  virtual void handleEvent(sf::Event& event, float mouseX = 0, float mouseY = 0);
178 
179 
181  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
182  // This function will be called and it will draw the child window on the render target.
184  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
185 
186 
188  public:
189 
191  Layout layout;
192 
194  TitleAlignment titleAlignment;
195 
197  unsigned int distanceToSide;
198 
200  sf::Color borderColor;
201 
203  sf::String title;
204 
206  protected:
207 
208  unsigned int m_TitleBarHeight;
209  std::string m_LoadedPathname;
210  bool m_SplitImage;
211  Vector2f m_DraggingPosition;
212  unsigned char m_Opacity;
213 
214  sf::Texture* m_TextureTitleBar_L;
215  sf::Texture* m_TextureTitleBar_M;
216  sf::Texture* m_TextureTitleBar_R;
217 
218  sf::Sprite m_SpriteTitleBar_L;
219  sf::Sprite m_SpriteTitleBar_M;
220  sf::Sprite m_SpriteTitleBar_R;
221 
222  tgui::Button* m_CloseButton;
223 
225  };
226 
228 }
229 
231 
232 #endif //_TGUI_CHILD_WINDOW_INCLUDED_
Layout layout
Should the close button be on the right side or on the left side of the title bar?
Definition: ChildWindow.hpp:191
Movable Panel with title bar.
Definition: ChildWindow.hpp:36
sf::String title
The title of the window.
Definition: ChildWindow.hpp:203
Parent struct for every object that has borders.
Definition: Objects.hpp:299
sf::Color borderColor
The color that is used to draw the borders of the window.
Definition: ChildWindow.hpp:200
TitleAlignment titleAlignment
Should the text be on the left or the right or should it be centered?
Definition: ChildWindow.hpp:194
Definition: Button.hpp:35
A static group of objects. The background color can be solid or transparent.
Definition: Panel.hpp:36
unsigned int distanceToSide
The distance between the side of the title bar and the close button.
Definition: ChildWindow.hpp:197