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:45
Class to store the position or size of a widget.
Definition Layout.hpp:313
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)
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
TGUI_NODISCARD Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
static TGUI_NODISCARD MessageBox::Ptr copy(const MessageBox::ConstPtr &messageBox)
Makes a copy of another message box.
TGUI_NODISCARD const String & getText() const
Returns the text of the message box.
void updateTextSize() override
Called when the text size is changed (either by setTextSize or via the renderer)
TGUI_NODISCARD HorizontalAlignment getLabelAlignment() const
Returns where the label is located inside the window (left side, centered or right side)
std::shared_ptr< const MessageBox > ConstPtr
Shared constant widget pointer.
Definition MessageBox.hpp:47
MessageBox(const MessageBox ©)
Copy constructor.
void setText(const String &text)
Changes the text of the message box.
TGUI_NODISCARD MessageBoxRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
static TGUI_NODISCARD MessageBox::Ptr create(const String &title="", const String &text="", const std::vector< String > &buttons={})
Creates a new message box widget.
TGUI_NODISCARD HorizontalAlignment getButtonAlignment() const
Returns where the buttons are located inside the window (left side, centered or right side)
TGUI_NODISCARD 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.
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
TGUI_NODISCARD MessageBoxRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void addButton(const String &buttonCaption)
Adds a button to the message box.
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.
TGUI_NODISCARD std::vector< String > getButtons() const
Returns the caption of the buttons.
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition MessageBoxRenderer.hpp:35
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:61