25#ifndef TGUI_MESSAGE_BOX_HPP
26#define TGUI_MESSAGE_BOX_HPP
28#include <TGUI/Renderers/MessageBoxRenderer.hpp>
29#include <TGUI/Widgets/Button.hpp>
30#include <TGUI/Widgets/ChildWindow.hpp>
31#include <TGUI/Widgets/Label.hpp>
42 class TGUI_API MessageBox :
public ChildWindow
45 using Ptr = std::shared_ptr<MessageBox>;
46 using ConstPtr = std::shared_ptr<const MessageBox>;
62 explicit MessageBox(
const char* typeName =
StaticWidgetType,
bool initRenderer =
true);
75 const std::vector<String>& buttons = {});
263 [[nodiscard]] std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
268 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
286 void identifyLabelAndButtons();
291 void connectButtonPressSignal(std::size_t buttonIndex);
296 void addButtonImpl(
const String& caption);
308 bool m_autoSize =
true;
312 std::vector<Button::Ptr> m_buttons;
static Label::Ptr create(const String &text="")
Creates a new label widget.
std::shared_ptr< Label > Ptr
Shared widget pointer.
Definition Label.hpp:43
Class to store the position or size of a widget.
Definition Layout.hpp:320
Definition MessageBoxRenderer.hpp:35
SignalString onButtonPress
One of the buttons was pressed. Optional parameter: text of the pressed button.
Definition MessageBox.hpp:301
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:46
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.
HorizontalAlignment Alignment
The label and button alignment.
Definition MessageBox.hpp:53
static constexpr char StaticWidgetType[]
Type name of the widget.
Definition MessageBox.hpp:48
void setText(const String &text)
Changes the text of the message box.
MessageBox & operator=(MessageBox &&other) noexcept
Overload of move assignment operator.
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(const MessageBox &other)
Copy constructor.
std::shared_ptr< MessageBox > Ptr
Shared widget pointer.
Definition MessageBox.hpp:45
HorizontalAlignment getLabelAlignment() const
Returns where the label is located inside the window (left side, centered or right side).
MessageBox(MessageBox &&other) noexcept
Move constructor.
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.
MessageBox & operator=(const MessageBox &other)
Overload of copy assignment operator.
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:59
Wrapper class to store strings.
Definition String.hpp:94
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
HorizontalAlignment
The horizontal alignment.
Definition Layout.hpp:60
@ Center
Center the object horizontally.
Definition Layout.hpp:62
@ Left
Align to the left side.
Definition Layout.hpp:61
SignalTyped< const String & > SignalString
Signal with one "String" as optional unbound parameter.
Definition Signal.hpp:413