TGUI  0.8-dev
MessageBox.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2017 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_MESSAGE_BOX_HPP
27 #define TGUI_MESSAGE_BOX_HPP
28 
29 
30 #include <TGUI/Widgets/Label.hpp>
31 #include <TGUI/Widgets/Button.hpp>
32 #include <TGUI/Widgets/ChildWindow.hpp>
33 #include <TGUI/Renderers/MessageBoxRenderer.hpp>
34 
36 
37 namespace tgui
38 {
50  class TGUI_API MessageBox : public ChildWindow
51  {
52  public:
53 
54  typedef std::shared_ptr<MessageBox> Ptr;
55  typedef std::shared_ptr<const MessageBox> ConstPtr;
56 
57 
59  // Default constructor
61  MessageBox();
62 
63 
70  static MessageBox::Ptr create();
71 
72 
79  MessageBox(const MessageBox& copy);
80 
81 
90  MessageBox& operator= (const MessageBox& right);
91 
92 
101  static MessageBox::Ptr copy(MessageBox::ConstPtr messageBox);
102 
103 
111  {
112  return aurora::downcast<MessageBoxRenderer*>(m_renderer.get());
113  }
114 
115 
125  void setText(const sf::String& text);
126 
127 
134  const sf::String& getText() const;
135 
136 
145  void setTextSize(unsigned int size);
146 
147 
154  unsigned int getTextSize() const;
155 
156 
166  void addButton(const sf::String& buttonCaption);
167 
168 
175  std::vector<sf::String> getButtons() const;
176 
177 
179  protected:
180 
182  // Makes sure all widgets lie within the window and places them on the correct position.
184  void rearrange();
185 
186 
193  virtual void rendererChanged(const std::string& property) override;
194 
195 
197  // Makes a copy of the widget
199  virtual Widget::Ptr clone() const override
200  {
201  return std::make_shared<MessageBox>(*this);
202  }
203 
204 
206  protected:
207 
208  std::string m_loadedThemeFile;
209  std::string m_buttonClassName;
210 
211  std::vector<Button::Ptr> m_buttons;
212 
213  Label::Ptr m_label = Label::create();
214 
215  unsigned int m_textSize = 16;
216  };
217 
219 }
220 
222 
223 #endif // TGUI_MESSAGE_BOX_HPP
224 
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
Definition: MessageBoxRenderer.hpp:36
static Label::Ptr create(sf::String text="")
Creates a new label widget.
Child window widget.
Definition: ChildWindow.hpp:59
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don&#39;t know its exact type.
Definition: MessageBox.hpp:199
std::shared_ptr< const MessageBox > ConstPtr
Shared constant widget pointer.
Definition: MessageBox.hpp:55
std::shared_ptr< Label > Ptr
Shared widget pointer.
Definition: Label.hpp:53
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:76
MessageBoxRenderer * getRenderer() const
Returns the renderer, which gives access to functions that determine how the widget is displayed...
Definition: MessageBox.hpp:110
std::shared_ptr< MessageBox > Ptr
Shared widget pointer.
Definition: MessageBox.hpp:54
Message box widget.
Definition: MessageBox.hpp:50