The Battle for Wesnoth  1.15.2+dev
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
gui2::dialogs::message Class Reference

Main class to show messages to the user. More...

#include <message.hpp>

Inheritance diagram for gui2::dialogs::message:
Inheritance graph

Classes

struct  button_status
 

Public Types

enum  button_id {
  left_1 = 0, cancel, ok, right_1,
  count
}
 
enum  button_style {
  auto_close, ok_button, close_button, ok_cancel_buttons,
  cancel_button, yes_no_buttons
}
 Selects the style of the buttons to be shown. More...
 

Public Member Functions

 message (const std::string &title, const std::string &message, const bool auto_close, const bool message_use_markup, const bool title_use_markup)
 
void set_button_caption (const button_id button, const std::string &caption)
 
void set_button_visible (const button_id button, const widget::visibility visible)
 
void set_button_retval (const button_id button, const int retval)
 
void set_title (const std::string &title)
 
void set_image (const std::string &image)
 
void set_message (const std::string &message)
 
void set_auto_close (const bool auto_close)
 
- Public Member Functions inherited from gui2::dialogs::modal_dialog
 modal_dialog ()
 
virtual ~modal_dialog ()
 
bool show (const unsigned auto_close_time=0)
 Shows the window. More...
 
windowget_window () const
 Returns a pointer to the dialog's window. More...
 
int get_retval () const
 
void set_always_save_fields (const bool always_save_fields)
 
void set_restore (const bool restore)
 
void set_allow_plugin_skip (const bool allow_plugin_skip)
 
void set_show_even_without_video (const bool show_even_without_video)
 

Protected Member Functions

virtual void pre_show (window &window) override
 Inherited from modal_dialog. More...
 
virtual void post_show (window &window) override
 Inherited from modal_dialog. More...
 
- Protected Member Functions inherited from gui2::dialogs::modal_dialog
field_boolregister_bool (const std::string &id, const bool mandatory, const std::function< bool()> callback_load_value=nullptr, const std::function< void(bool)> callback_save_value=nullptr, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false)
 Creates a new boolean field. More...
 
field_boolregister_bool (const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false)
 Creates a new boolean field. More...
 
field_integerregister_integer (const std::string &id, const bool mandatory, const std::function< int()> callback_load_value=nullptr, const std::function< void(int)> callback_save_value=nullptr)
 Creates a new integer field. More...
 
field_integerregister_integer (const std::string &id, const bool mandatory, int &linked_variable)
 Creates a new integer field. More...
 
field_textregister_text (const std::string &id, const bool mandatory, const std::function< std::string()> callback_load_value=nullptr, const std::function< void(const std::string &)> callback_save_value=nullptr, const bool capture_focus=false)
 Creates a new text field. More...
 
field_textregister_text (const std::string &id, const bool mandatory, std::string &linked_variable, const bool capture_focus=false)
 Creates a new text field. More...
 
field_labelregister_label (const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false)
 Registers a new styled_widget as a label. More...
 
field_labelregister_image (const std::string &id, const bool mandatory, const std::string &filename)
 Registers a new styled_widget as image. More...
 

Private Member Functions

virtual const std::string & window_id () const override
 Inherited from modal_dialog, implemented by REGISTER_DIALOG. More...
 

Private Attributes

std::string title_
 The title for the dialog. More...
 
std::string image_
 The image which is shown in the dialog. More...
 
std::string message_
 The message to show to the user. More...
 
bool auto_close_
 Does the window need to use click_dismiss when the dialog doesn't need a scrollbar. More...
 
bool message_use_markup_
 Whether to enable formatting markup for the dialog message. More...
 
bool title_use_markup_
 Whether to enable formatting markup for the dialog title. More...
 
std::vector< button_statusbuttons_
 Holds a pointer to the buttons. More...
 

Friends

struct message_implementation
 

Additional Inherited Members

- Protected Attributes inherited from gui2::dialogs::modal_dialog
std::unique_ptr< windowwindow_
 The window object build for this dialog. More...
 

Detailed Description

Main class to show messages to the user.

It can be used to show a message or ask a result from the user. For the most common usage cases there are helper functions defined.

Definition at line 34 of file message.hpp.

Member Enumeration Documentation

◆ button_id

Enumerator
left_1 
cancel 
ok 
right_1 
count 

Definition at line 54 of file message.hpp.

◆ button_style

Selects the style of the buttons to be shown.

These values are not directly implemented in this class but are used by our helper functions.

Enumerator
auto_close 

Enables auto close.

ok_button 

Shows an ok button.

close_button 

Shows a close button.

ok_cancel_buttons 

Shows an ok and cancel button.

cancel_button 

Shows a cancel button.

yes_no_buttons 

Shows a yes and no button.

Definition at line 68 of file message.hpp.

Constructor & Destructor Documentation

◆ message()

gui2::dialogs::message::message ( const std::string &  title,
const std::string &  message,
const bool  auto_close,
const bool  message_use_markup,
const bool  title_use_markup 
)
inline

Definition at line 39 of file message.hpp.

Referenced by set_message().

Member Function Documentation

◆ post_show()

void gui2::dialogs::message::post_show ( window window)
overrideprotectedvirtual

Inherited from modal_dialog.

Reimplemented from gui2::dialogs::modal_dialog.

Definition at line 106 of file message.cpp.

References buttons_, and gui2::dialogs::message::button_status::ptr.

Referenced by set_auto_close().

◆ pre_show()

void gui2::dialogs::message::pre_show ( window window)
overrideprotectedvirtual

◆ set_auto_close()

void gui2::dialogs::message::set_auto_close ( const bool  auto_close)
inline

Definition at line 107 of file message.hpp.

References auto_close, auto_close_, post_show(), and pre_show().

◆ set_button_caption()

void gui2::dialogs::message::set_button_caption ( const button_id  button,
const std::string &  caption 
)

Definition at line 114 of file message.cpp.

References buttons_.

Referenced by gui2::show_message().

◆ set_button_retval()

void gui2::dialogs::message::set_button_retval ( const button_id  button,
const int  retval 
)

Definition at line 132 of file message.cpp.

References buttons_.

◆ set_button_visible()

void gui2::dialogs::message::set_button_visible ( const button_id  button,
const widget::visibility  visible 
)

Definition at line 123 of file message.cpp.

References buttons_.

Referenced by gui2::show_message().

◆ set_image()

void gui2::dialogs::message::set_image ( const std::string &  image)
inline

Definition at line 97 of file message.hpp.

References image_.

◆ set_message()

void gui2::dialogs::message::set_message ( const std::string &  message)
inline

Definition at line 102 of file message.hpp.

References message(), and message_.

◆ set_title()

void gui2::dialogs::message::set_title ( const std::string &  title)
inline

Definition at line 92 of file message.hpp.

References title_.

◆ window_id()

virtual const std::string& gui2::dialogs::message::window_id ( ) const
overrideprivatevirtual

Inherited from modal_dialog, implemented by REGISTER_DIALOG.

Implements gui2::dialogs::modal_dialog.

Friends And Related Function Documentation

◆ message_implementation

friend struct message_implementation
friend

Definition at line 36 of file message.hpp.

Member Data Documentation

◆ auto_close_

bool gui2::dialogs::message::auto_close_
private

Does the window need to use click_dismiss when the dialog doesn't need a scrollbar.

Definition at line 137 of file message.hpp.

Referenced by pre_show(), and set_auto_close().

◆ buttons_

std::vector<button_status> gui2::dialogs::message::buttons_
private

Holds a pointer to the buttons.

Definition at line 156 of file message.hpp.

Referenced by post_show(), pre_show(), set_button_caption(), set_button_retval(), and set_button_visible().

◆ image_

std::string gui2::dialogs::message::image_
private

The image which is shown in the dialog.

This image can be an icon or portrait or any other image.

Definition at line 128 of file message.hpp.

Referenced by pre_show(), and set_image().

◆ message_

std::string gui2::dialogs::message::message_
private

The message to show to the user.

Definition at line 131 of file message.hpp.

Referenced by pre_show(), and set_message().

◆ message_use_markup_

bool gui2::dialogs::message::message_use_markup_
private

Whether to enable formatting markup for the dialog message.

Definition at line 140 of file message.hpp.

Referenced by pre_show().

◆ title_

std::string gui2::dialogs::message::title_
private

The title for the dialog.

Definition at line 121 of file message.hpp.

Referenced by pre_show(), and set_title().

◆ title_use_markup_

bool gui2::dialogs::message::title_use_markup_
private

Whether to enable formatting markup for the dialog title.

Definition at line 143 of file message.hpp.

Referenced by pre_show().


The documentation for this class was generated from the following files: