25#ifndef TGUI_MESSAGE_BOX_HPP
26#define TGUI_MESSAGE_BOX_HPP
28#include <TGUI/Widgets/Label.hpp>
29#include <TGUI/Widgets/Button.hpp>
30#include <TGUI/Widgets/ChildWindow.hpp>
31#include <TGUI/Renderers/MessageBoxRenderer.hpp>
37TGUI_MODULE_EXPORT
namespace tgui
46 using Ptr = std::shared_ptr<MessageBox>;
47 using ConstPtr = std::shared_ptr<const MessageBox>;
49 static constexpr const char StaticWidgetType[] =
"MessageBox";
63 MessageBox(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
131 using Widget::setSize;
262 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
267 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
285 void identifyLabelAndButtons();
290 void connectButtonPressSignal(std::size_t buttonIndex);
295 void addButtonImpl(
const String& caption);
307 bool m_autoSize =
true;
311 std::vector<Button::Ptr> m_buttons;
Child window widget.
Definition ChildWindow.hpp:45
std::shared_ptr< Label > Ptr
Shared widget pointer.
Definition Label.hpp:44
Class to store the position or size of a widget.
Definition Layout.hpp:323
Definition MessageBoxRenderer.hpp:35
Message box widget.
Definition MessageBox.hpp:43
void setLabelAlignment(HorizontalAlignment labelAlignment)
Changes where the label is located inside the window (left side, centered or right side)
static MessageBox::Ptr create(const String &title="", const String &text="", const std::vector< String > &buttons={})
Creates a new message box widget.
std::vector< String > getButtons() const
Returns the caption of the buttons.
MessageBoxRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
void updateTextSize() override
Called when the text size is changed (either by setTextSize or via the renderer)
MessageBoxRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
std::shared_ptr< const MessageBox > ConstPtr
Shared constant widget pointer.
Definition MessageBox.hpp:47
std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
MessageBox(const MessageBox ©)
Copy constructor.
void setText(const String &text)
Changes the text of the message box.
const String & getText() const
Returns the text of the message box.
Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
void setButtonAlignment(HorizontalAlignment buttonAlignment)
Changes where the buttons are located inside the window (left side, centered or right side)
MessageBox(MessageBox &©) noexcept
Move constructor.
std::shared_ptr< MessageBox > Ptr
Shared widget pointer.
Definition MessageBox.hpp:46
HorizontalAlignment getLabelAlignment() const
Returns where the label is located inside the window (left side, centered or right side)
void addButton(const String &buttonCaption)
Adds a button to the message box.
static MessageBox::Ptr copy(const MessageBox::ConstPtr &messageBox)
Makes a copy of another message box.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
void changeButtons(const std::vector< String > &buttonCaptions)
Adds, removes, or updates buttons from the message box.
void setSize(const Layout2d &size) override
Changes the size of the message box.
void setClientSize(const Layout2d &size) override
Changes the client size of the child window.
HorizontalAlignment getButtonAlignment() const
Returns where the buttons are located inside the window (left side, centered or right side)
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Wrapper class to store strings.
Definition String.hpp:96
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
HorizontalAlignment
The horizontal alignment.
Definition Layout.hpp:62