TGUI  v0.6.10
MessageBox.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_MESSAGE_BOX_HPP
27 #define TGUI_MESSAGE_BOX_HPP
28 
29 
30 #include <TGUI/Label.hpp>
31 #include <TGUI/Button.hpp>
32 #include <TGUI/ChildWindow.hpp>
33 
35 
36 namespace tgui
37 {
39 
40  class TGUI_API MessageBox : public ChildWindow
41  {
42  public:
43 
45 
46 
51  MessageBox();
52 
53 
60  MessageBox(const MessageBox& copy);
61 
62 
67  virtual ~MessageBox();
68 
69 
78  MessageBox& operator= (const MessageBox& right);
79 
80 
82  // Makes a copy of the widget by calling the copy constructor.
83  // This function calls new and if you use this function then you are responsible for calling delete.
85  virtual MessageBox* clone();
86 
87 
97  bool load(const std::string& configFileFilename, const std::string& sectionName = "MessageBox");
98 
99 
109  void setText(const sf::String& text);
110 
111 
118  sf::String getText() const;
119 
120 
130  void setTextFont(const sf::Font& font);
131 
132 
139  const sf::Font* getTextFont() const;
140 
141 
148  void setTextColor(const sf::Color& color);
149 
150 
157  const sf::Color& getTextColor() const;
158 
159 
168  void setTextSize(unsigned int size);
169 
170 
177  unsigned int getTextSize() const;
178 
179 
189  void addButton(const sf::String& buttonCaption);
190 
191 
194  // This function is a (slow) way to set properties on the widget, no matter what type it is.
195  // When the requested property doesn't exist in the widget then the functions will return false.
197  virtual bool setProperty(std::string property, const std::string& value);
198 
201  // This function is a (slow) way to get properties of the widget, no matter what type it is.
202  // When the requested property doesn't exist in the widget then the functions will return false.
204  virtual bool getProperty(std::string property, std::string& value) const;
205 
206 
209  // Returns a list of all properties that can be used in setProperty and getProperty.
210  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
212  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
213 
214 
216  protected:
217 
219  // Makes sure all widgets lie within the window and places them on the correct position.
221  void rearrange();
222 
223 
225  // Callback functions for the buttons
227  void ButtonClickedCallbackFunction(const Callback& callback);
228 
229 
231  public:
232 
237  {
238  ButtonClicked = ChildWindowCallbacksCount * 1,
239  AllMessageBoxCallbacks = ChildWindowCallbacksCount * 2 - 1,
240  MessageBoxCallbacksCount = ChildWindowCallbacksCount * 2
241  };
242 
243 
245  protected:
246 
247  std::string m_LoadedConfigFile;
248  std::string m_ButtonConfigFileFilename;
249 
250  std::vector<Button::Ptr> m_Buttons;
251 
252  Label::Ptr m_Label;
253 
254  unsigned int m_TextSize;
255  };
256 
258 }
259 
261 
262 #endif // TGUI_MESSAGE_BOX_HPP
263 
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
MessageBoxCallbacks
Defines specific triggers to MessageBox.
Definition: MessageBox.hpp:236
Movable Panel with title bar.
Definition: ChildWindow.hpp:41
Definition: Callback.hpp:45
Definition: MessageBox.hpp:40
Definition: SharedWidgetPtr.hpp:44