The Battle for Wesnoth  1.17.0-dev
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
gui2::dialogs::wml_message_base Class Reference

Base class for the wml generated messages. More...

#include <wml_message.hpp>

Inheritance diagram for gui2::dialogs::wml_message_base:

Public Member Functions

 wml_message_base (const std::string &title, const std::string &message, const std::string &portrait, const bool mirror)
 
void set_input (const std::string &caption, std::string *text, const unsigned maximum_length)
 Sets the input text variables. More...
 
void set_option_list (const std::vector< wml_message_option > &option_list, int *chosen_option)
 Sets the option list. More...
 
- 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
 Returns the cached window exit code. More...
 
void set_retval (int retval)
 Convenience wrapper to set the window's exit code. More...
 
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
 
- 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 void post_show (window &window) override
 Actions to be taken after the window has been shown. 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...
 
std::string portrait_
 Filename of the portrait. More...
 
bool mirror_
 Mirror the portrait? More...
 
bool has_input_
 Do we need to show an input box? More...
 
std::string input_caption_
 The caption to show for the input text. More...
 
std::string * input_text_
 The text input. More...
 
unsigned input_maximum_length_
 The maximum length of the input text. More...
 
std::vector< wml_message_optionoption_list_
 The list of options the user can choose. More...
 
int * chosen_option_
 The chosen option. More...
 

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

Base class for the wml generated messages.

We have a separate sub class for left and right images.

Definition at line 45 of file wml_message.hpp.

Constructor & Destructor Documentation

◆ wml_message_base()

gui2::dialogs::wml_message_base::wml_message_base ( const std::string &  title,
const std::string &  message,
const std::string &  portrait,
const bool  mirror 
)
inline

Definition at line 48 of file wml_message.hpp.

Member Function Documentation

◆ post_show()

void gui2::dialogs::wml_message_base::post_show ( window window)
overrideprivatevirtual

Actions to be taken after the window has been shown.

At this point the registered fields already stored their values (if the OK has been pressed).

Parameters
windowThe window which has been shown.

Reimplemented from gui2::dialogs::modal_dialog.

Definition at line 132 of file wml_message.cpp.

References chosen_option_, has_input_, input_text_, and option_list_.

◆ pre_show()

void gui2::dialogs::wml_message_base::pre_show ( window window)
overrideprotectedvirtual
Todo:
This function enables the wml markup for all items, but the interface is a bit hacky.

Especially the fiddling in the internals of the listbox is ugly. There needs to be a clean interface to set whether a widget has a markup and what kind of markup. These fixes will be post 1.6.

Reimplemented from gui2::dialogs::modal_dialog.

Reimplemented in gui2::dialogs::wml_message_double.

Definition at line 59 of file wml_message.cpp.

References gui2::listbox::add_row(), chosen_option_, gui2::styled_widget::get_canvas(), has_input_, input_caption_, input_maximum_length_, input_text_, gui2::widget::invisible, message_, mirror_, option_list_, preferences::options(), portrait_, gui2::listbox::select_row(), gui2::label::set_can_wrap(), gui2::styled_widget::set_label(), gui2::dialogs::modal_dialog::set_restore(), gui2::styled_widget::set_use_markup(), gui2::canvas::set_variable(), gui2::widget::set_visible(), and title_.

Referenced by gui2::dialogs::wml_message_double::pre_show().

◆ set_input()

void gui2::dialogs::wml_message_base::set_input ( const std::string &  caption,
std::string *  text,
const unsigned  maximum_length 
)

Sets the input text variables.

Parameters
captionThe caption for the label.
[in,out]textThe initial text, after showing the final text.
maximum_lengthThe maximum length of the text.

Definition at line 31 of file wml_message.cpp.

References has_input_, input_caption_, input_maximum_length_, and input_text_.

◆ set_option_list()

void gui2::dialogs::wml_message_base::set_option_list ( const std::vector< wml_message_option > &  option_list,
int *  chosen_option 
)

Sets the option list.

Parameters
option_listThe list of options to display.
[in,out]chosen_optionPointer to the index of the initially selected option; after showing, the chosen option.

Definition at line 43 of file wml_message.cpp.

References chosen_option_, and option_list_.

Member Data Documentation

◆ chosen_option_

int* gui2::dialogs::wml_message_base::chosen_option_
private

The chosen option.

Definition at line 123 of file wml_message.hpp.

Referenced by post_show(), pre_show(), and set_option_list().

◆ has_input_

bool gui2::dialogs::wml_message_base::has_input_
private

Do we need to show an input box?

Definition at line 108 of file wml_message.hpp.

Referenced by post_show(), pre_show(), and set_input().

◆ image_

std::string gui2::dialogs::wml_message_base::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 97 of file wml_message.hpp.

◆ input_caption_

std::string gui2::dialogs::wml_message_base::input_caption_
private

The caption to show for the input text.

Definition at line 111 of file wml_message.hpp.

Referenced by pre_show(), and set_input().

◆ input_maximum_length_

unsigned gui2::dialogs::wml_message_base::input_maximum_length_
private

The maximum length of the input text.

Definition at line 117 of file wml_message.hpp.

Referenced by pre_show(), and set_input().

◆ input_text_

std::string* gui2::dialogs::wml_message_base::input_text_
private

The text input.

Definition at line 114 of file wml_message.hpp.

Referenced by post_show(), pre_show(), and set_input().

◆ message_

std::string gui2::dialogs::wml_message_base::message_
private

The message to show to the user.

Definition at line 100 of file wml_message.hpp.

Referenced by pre_show().

◆ mirror_

bool gui2::dialogs::wml_message_base::mirror_
private

Mirror the portrait?

Definition at line 105 of file wml_message.hpp.

Referenced by pre_show().

◆ option_list_

std::vector<wml_message_option> gui2::dialogs::wml_message_base::option_list_
private

The list of options the user can choose.

Definition at line 120 of file wml_message.hpp.

Referenced by post_show(), pre_show(), and set_option_list().

◆ portrait_

std::string gui2::dialogs::wml_message_base::portrait_
private

Filename of the portrait.

Definition at line 102 of file wml_message.hpp.

Referenced by pre_show().

◆ title_

std::string gui2::dialogs::wml_message_base::title_
private

The title for the dialog.

Definition at line 90 of file wml_message.hpp.

Referenced by pre_show().


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