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

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

#include <message.hpp>

Inheritance diagram for gui2::tmessage:
Inheritance graph

Classes

struct  tbutton_status
 

Public Types

enum  tbutton_id {
  left_1 = 0, cancel, ok, right_1,
  count
}
 
enum  tbutton_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

 tmessage (const std::string &title, const std::string &message, const bool auto_close, const bool message_use_markup)
 
void set_button_caption (const tbutton_id button, const std::string &caption)
 
void set_button_visible (const tbutton_id button, const twidget::tvisible::scoped_enum visible)
 
void set_button_retval (const tbutton_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::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)
 

Protected Member Functions

void pre_show (twindow &window)
 Inherited from tdialog. More...
 
void post_show (twindow &window)
 Inherited from tdialog. More...
 
- 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...
 

Private Member Functions

virtual const std::stringwindow_id () const
 Inherited from tdialog, 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...
 
std::vector< tbutton_statusbuttons_
 Holds a pointer to the buttons. More...
 

Friends

struct tmessage_implementation
 

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 32 of file message.hpp.

Member Enumeration Documentation

Enumerator
left_1 
cancel 
ok 
right_1 
count 

Definition at line 50 of file message.hpp.

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 64 of file message.hpp.

Constructor & Destructor Documentation

gui2::tmessage::tmessage ( const std::string title,
const std::string message,
const bool  auto_close,
const bool  message_use_markup 
)
inline

Definition at line 37 of file message.hpp.

Member Function Documentation

void gui2::tmessage::post_show ( twindow window)
protectedvirtual

Inherited from tdialog.

Reimplemented from gui2::tdialog.

Definition at line 101 of file message.cpp.

References buttons_.

void gui2::tmessage::pre_show ( twindow window)
protectedvirtual
void gui2::tmessage::set_auto_close ( const bool  auto_close)
inline

Definition at line 103 of file message.hpp.

References auto_close, and auto_close_.

void gui2::tmessage::set_button_caption ( const tbutton_id  button,
const std::string caption 
)

Definition at line 109 of file message.cpp.

References buttons_.

Referenced by gui2::show_message().

void gui2::tmessage::set_button_retval ( const tbutton_id  button,
const int  retval 
)

Definition at line 127 of file message.cpp.

References buttons_.

void gui2::tmessage::set_button_visible ( const tbutton_id  button,
const twidget::tvisible::scoped_enum  visible 
)

Definition at line 118 of file message.cpp.

References buttons_.

Referenced by gui2::show_message().

void gui2::tmessage::set_image ( const std::string image)
inline

Definition at line 93 of file message.hpp.

References image_.

void gui2::tmessage::set_message ( const std::string message)
inline

Definition at line 98 of file message.hpp.

References message_.

void gui2::tmessage::set_title ( const std::string title)
inline

Definition at line 88 of file message.hpp.

References title_.

virtual const std::string& gui2::tmessage::window_id ( ) const
privatevirtual

Inherited from tdialog, implemented by REGISTER_DIALOG.

Implements gui2::tdialog.

Friends And Related Function Documentation

friend struct tmessage_implementation
friend

Definition at line 34 of file message.hpp.

Member Data Documentation

bool gui2::tmessage::auto_close_
private

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

Definition at line 133 of file message.hpp.

Referenced by pre_show(), and set_auto_close().

std::vector<tbutton_status> gui2::tmessage::buttons_
private

Holds a pointer to the buttons.

Definition at line 149 of file message.hpp.

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

std::string gui2::tmessage::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 124 of file message.hpp.

Referenced by pre_show(), and set_image().

std::string gui2::tmessage::message_
private

The message to show to the user.

Definition at line 127 of file message.hpp.

Referenced by pre_show(), and set_message().

bool gui2::tmessage::message_use_markup_
private

Whether to enable formatting markup for the dialog message.

Definition at line 136 of file message.hpp.

Referenced by pre_show().

std::string gui2::tmessage::title_
private

The title for the dialog.

Definition at line 117 of file message.hpp.

Referenced by pre_show(), and set_title().


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