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 {
42  class TGUI_API MessageBox : public ChildWindow
43  {
44  public:
45 
46  typedef std::shared_ptr<MessageBox> Ptr;
47  typedef std::shared_ptr<const MessageBox> ConstPtr;
48 
49 
51  // Default constructor
53  MessageBox();
54 
55 
65  static MessageBox::Ptr create(sf::String title = "", sf::String text = "", std::vector<sf::String> buttons = {});
66 
67 
71  MessageBox(const MessageBox& copy);
72 
73 
77  MessageBox(MessageBox&& copy);
78 
79 
83  MessageBox& operator= (const MessageBox& right);
84 
85 
89  MessageBox& operator= (MessageBox&& right);
90 
91 
100  static MessageBox::Ptr copy(MessageBox::ConstPtr messageBox);
101 
102 
107  MessageBoxRenderer* getSharedRenderer();
108  const MessageBoxRenderer* getSharedRenderer() const;
109 
115  MessageBoxRenderer* getRenderer();
116  const MessageBoxRenderer* getRenderer() const;
117 
118 
128  void setText(const sf::String& text);
129 
130 
137  const sf::String& getText() const;
138 
139 
148  void setTextSize(unsigned int size);
149 
150 
157  unsigned int getTextSize() const;
158 
159 
169  void addButton(const sf::String& buttonCaption);
170 
171 
178  std::vector<sf::String> getButtons() const;
179 
180 
182  protected:
183 
185  // Makes sure all widgets lie within the window and places them on the correct position.
187  void rearrange();
188 
189 
199  Signal& getSignal(std::string signalName) override;
200 
201 
208  void rendererChanged(const std::string& property) override;
209 
210 
212  // Makes a copy of the widget
214  Widget::Ptr clone() const override
215  {
216  return std::make_shared<MessageBox>(*this);
217  }
218 
219 
221  public:
222 
223  SignalString onButtonPress = {"ButtonPressed"};
224 
225 
227  protected:
228 
229  std::string m_loadedThemeFile;
230  std::string m_buttonClassName;
231 
232  std::vector<Button::Ptr> m_buttons;
233 
234  Label::Ptr m_label = Label::create();
235 
236  unsigned int m_textSize = 16;
237  };
238 
240 }
241 
243 
244 #endif // TGUI_MESSAGE_BOX_HPP
245 
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
Definition: MessageBoxRenderer.hpp:36
static Label::Ptr create(sf::String text="")
Creates a new label widget.
Child window widget.
Definition: ChildWindow.hpp:42
Widget::Ptr clone() const override
Makes a copy of the widget if you don&#39;t know its exact type.
Definition: MessageBox.hpp:214
std::shared_ptr< const MessageBox > ConstPtr
Shared constant widget pointer.
Definition: MessageBox.hpp:47
std::shared_ptr< Label > Ptr
Shared widget pointer.
Definition: Label.hpp:45
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:66
Signal to which the user can subscribe to get callbacks from.
Definition: Signal.hpp:59
std::shared_ptr< MessageBox > Ptr
Shared widget pointer.
Definition: MessageBox.hpp:46
Message box widget.
Definition: MessageBox.hpp:42