The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
gui2::twml_message_ Class Reference

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

#include <wml_message.hpp>

Inheritance diagram for gui2::twml_message_:
Inheritance graph

Public Member Functions

 twml_message_ (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< twml_message_option > &option_list, int *chosen_option)
 Sets the option list. More...
 
- Public Member Functions inherited from gui2::tdialog
 tdialog ()
 
virtual ~tdialog ()
 
bool show (CVideo &video, const unsigned auto_close_time=0)
 Shows the window. More...
 
int get_retval () const
 
void set_always_save_fields (const bool always_save_fields)
 
void set_restore (const bool restore)
 

Private Member Functions

void pre_show (twindow &window)
 Inherited from tdialog. More...
 
void post_show (twindow &window)
 Inherited from tdialog. 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::stringinput_text_
 The text input. More...
 
unsigned input_maximum_length_
 The maximum length of the input text. More...
 
std::vector< twml_message_optionoption_list_
 The list of options the user can choose. More...
 
intchosen_option_
 The chosen option. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gui2::tdialog
tfield_boolregister_bool (const std::string &id, const bool mandatory, const std::function< bool()> &callback_load_value=std::function< bool()>(), const std::function< void(const bool)> &callback_save_value=std::function< void(const bool)>(), const std::function< void(twidget &)> &callback_change=std::function< void(twidget &)>())
 Creates a new boolean field. More...
 
tfield_boolregister_bool (const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(twidget &)> &callback_change=std::function< void(twidget &)>())
 Creates a new boolean field. More...
 
tfield_integerregister_integer (const std::string &id, const bool mandatory, const std::function< int()> &callback_load_value=std::function< int()>(), const std::function< void(const int)> &callback_save_value=std::function< void(const int)>())
 Creates a new integer field. More...
 
tfield_integerregister_integer (const std::string &id, const bool mandatory, int &linked_variable)
 Creates a new integer field. More...
 
tfield_textregister_text (const std::string &id, const bool mandatory, const std::function< std::string()> &callback_load_value=std::function< std::string()>(), const std::function< void(const std::string &)> &callback_save_value=std::function< void(const std::string &)>(), const bool capture_focus=false)
 Creates a new text field. More...
 
tfield_textregister_text (const std::string &id, const bool mandatory, std::string &linked_variable, const bool capture_focus=false)
 Creates a new text field. More...
 
tfield_labelregister_label (const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false)
 Registers a new control as a label. More...
 
tfield_labelregister_image (const std::string &id, const bool mandatory, const std::string &filename)
 Registers a new control as image. 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

gui2::twml_message_::twml_message_ ( 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

void gui2::twml_message_::post_show ( twindow window)
privatevirtual

Inherited from tdialog.

Reimplemented from gui2::tdialog.

Definition at line 135 of file wml_message.cpp.

References chosen_option_, has_input_, input_text_, and option_list_.

void gui2::twml_message_::pre_show ( twindow window)
privatevirtual

Inherited from tdialog.

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::tdialog.

Definition at line 62 of file wml_message.cpp.

References gui2::tlistbox::add_row(), gui2::tcontrol::canvas(), chosen_option_, has_input_, input_caption_, input_maximum_length_, input_text_, gui2::twidget::tvisible::invisible, message_, mirror_, option_list_, preferences::options(), portrait_, gui2::tlistbox::select_row(), gui2::tlabel::set_can_wrap(), gui2::tcontrol::set_label(), gui2::tdialog::set_restore(), gui2::tcontrol::set_use_markup(), gui2::twidget::set_visible(), and title_.

void gui2::twml_message_::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 34 of file wml_message.cpp.

References has_input_, input_caption_, input_maximum_length_, and input_text_.

void gui2::twml_message_::set_option_list ( const std::vector< twml_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 46 of file wml_message.cpp.

References chosen_option_, and option_list_.

Member Data Documentation

int* gui2::twml_message_::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().

bool gui2::twml_message_::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().

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

std::string gui2::twml_message_::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().

unsigned gui2::twml_message_::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().

std::string* gui2::twml_message_::input_text_
private

The text input.

Definition at line 114 of file wml_message.hpp.

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

std::string gui2::twml_message_::message_
private

The message to show to the user.

Definition at line 100 of file wml_message.hpp.

Referenced by pre_show().

bool gui2::twml_message_::mirror_
private

Mirror the portrait?

Definition at line 105 of file wml_message.hpp.

Referenced by pre_show().

std::vector<twml_message_option> gui2::twml_message_::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().

std::string gui2::twml_message_::portrait_
private

Filename of the portrait.

Definition at line 102 of file wml_message.hpp.

Referenced by pre_show().

std::string gui2::twml_message_::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: