26#ifndef TGUI_MESSAGE_BOX_HPP
27#define TGUI_MESSAGE_BOX_HPP
30#include <TGUI/Widgets/Label.hpp>
31#include <TGUI/Widgets/Button.hpp>
32#include <TGUI/Widgets/ChildWindow.hpp>
33#include <TGUI/Renderers/MessageBoxRenderer.hpp>
39TGUI_MODULE_EXPORT
namespace tgui
48 using Ptr = std::shared_ptr<MessageBox>;
49 using ConstPtr = std::shared_ptr<const MessageBox>;
51 static constexpr const char StaticWidgetType[] =
"MessageBox";
72 MessageBox(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
149 using Widget::setSize;
300 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
306 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
327 void identifyLabelAndButtons();
333 void connectButtonPressSignal(std::size_t buttonIndex);
339 void addButtonImpl(
const String& caption);
353 bool m_autoSize =
true;
354 Alignment m_labelAlignment = Alignment::Left;
355 Alignment m_buttonAlignment = Alignment::Center;
357 std::vector<Button::Ptr> m_buttons;
Child window widget.
Definition ChildWindow.hpp:47
std::shared_ptr< Label > Ptr
Shared widget pointer.
Definition Label.hpp:47
Class to store the position or size of a widget.
Definition Layout.hpp:289
Definition MessageBoxRenderer.hpp:37
Message box widget.
Definition MessageBox.hpp:45
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
void setLabelAlignment(Alignment labelAlignment)
Changes where the label is located inside the window (left side, centered or right side)
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)
std::shared_ptr< const MessageBox > ConstPtr
Shared constant widget pointer.
Definition MessageBox.hpp:49
MessageBox(const MessageBox ©)
Copy constructor.
void setText(const String &text)
Changes the text of the message box.
TGUI_NODISCARD Alignment getLabelAlignment() const
Returns where the label is located inside the window (left side, centered or right side)
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 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.
MessageBox(MessageBox &©) noexcept
Move constructor.
std::shared_ptr< MessageBox > Ptr
Shared widget pointer.
Definition MessageBox.hpp:48
void setButtonAlignment(Alignment buttonAlignment)
Changes where the buttons are located inside the window (left side, centered or right side)
TGUI_NODISCARD Alignment getButtonAlignment() const
Returns where the buttons are located inside the window (left side, centered or right side)
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.
Alignment
The label and button alignment.
Definition MessageBox.hpp:58
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.
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:62
Wrapper class to store strings.
Definition String.hpp:101
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39