The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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:
Inheritance graph

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 (CVideo &video, 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...
 
- 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
 Inherited from modal_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...
 
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...
 

Detailed Description

Base class for the wml generated messages.

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

Definition at line 46 of file wml_message.hpp.

Constructor & Destructor Documentation

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 49 of file wml_message.hpp.

Member Function Documentation

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

Inherited from modal_dialog.

Reimplemented from gui2::dialogs::modal_dialog.

Definition at line 137 of file wml_message.cpp.

References chosen_option_, has_input_, input_text_, and option_list_.

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

Inherited from modal_dialog.

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 64 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().

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 36 of file wml_message.cpp.

References has_input_, input_caption_, input_maximum_length_, and input_text_.

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 48 of file wml_message.cpp.

References chosen_option_, and option_list_.

Member Data Documentation

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

The chosen option.

Definition at line 124 of file wml_message.hpp.

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

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

Do we need to show an input box?

Definition at line 109 of file wml_message.hpp.

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

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 98 of file wml_message.hpp.

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

The caption to show for the input text.

Definition at line 112 of file wml_message.hpp.

Referenced by pre_show(), and set_input().

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

The maximum length of the input text.

Definition at line 118 of file wml_message.hpp.

Referenced by pre_show(), and set_input().

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

The text input.

Definition at line 115 of file wml_message.hpp.

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

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

The message to show to the user.

Definition at line 101 of file wml_message.hpp.

Referenced by pre_show().

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

Mirror the portrait?

Definition at line 106 of file wml_message.hpp.

Referenced by pre_show().

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

The list of options the user can choose.

Definition at line 121 of file wml_message.hpp.

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

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

Filename of the portrait.

Definition at line 103 of file wml_message.hpp.

Referenced by pre_show().

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

The title for the dialog.

Definition at line 91 of file wml_message.hpp.

Referenced by pre_show().


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