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 | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
gui::dialog Class Reference

#include <construct_dialog.hpp>

Inheritance diagram for gui::dialog:
Inheritance graph

Classes

struct  dimension_measurements
 

Public Types

enum  BUTTON_LOCATION {
  BUTTON_STANDARD, BUTTON_EXTRA, BUTTON_EXTRA_LEFT, BUTTON_CHECKBOX,
  BUTTON_CHECKBOX_LEFT, BUTTON_HELP, BUTTON_TOP
}
 
typedef dialog_frame::style style
 

Public Member Functions

 dialog (CVideo &video, const std::string &title="", const std::string &message="", const DIALOG_TYPE type=MESSAGE, const style &dialog_style=default_style)
 
virtual ~dialog ()
 
void set_image (dialog_image *const img)
 
void set_image (surface surf, const std::string &caption="")
 
void set_menu (menu *const m)
 
void set_menu (const std::vector< std::string > &menu_items, menu::sorter *sorter=nullptr)
 
void set_menu_items (const std::vector< std::string > &menu_items, bool keep_selection=false)
 Changes (or sets, if not previously set) the dialog's menu items to the provided list. More...
 
void add_pane (preview_pane *const pp)
 
void set_panes (std::vector< preview_pane * > panes)
 
void set_textbox (dialog_textbox *const box)
 
void set_textbox (const std::string &text_widget_label="", const std::string &text_widget_text="", const int text_widget_max_chars=256, const unsigned int text_box_width=font::relative_size(350))
 
void add_button (dialog_button *const btn, BUTTON_LOCATION loc)
 
void add_button (dialog_button_info btn_info, BUTTON_LOCATION loc=BUTTON_EXTRA)
 
void add_option (const std::string &label, bool checked=false, BUTTON_LOCATION loc=BUTTON_CHECKBOX, const std::string &help_string="")
 
virtual dimension_measurements layout (int xloc=-1, int yloc=-1)
 
void set_layout (dimension_measurements &new_dim)
 
dimension_measurements get_layout () const
 
dialog_frameget_frame ()
 
void set_basic_behavior (DIALOG_TYPE type)
 
int show (int xloc, int yloc)
 
int show ()
 
int result () const
 
menuget_menu ()
 
bool done () const
 
std::string textbox_text () const
 
dialog_textboxget_textbox () const
 
bool option_checked (unsigned int option_index=0)
 
CVideoget_video ()
 

Static Public Member Functions

static void delete_empty_menu ()
 Explicit freeing of class static resources. More...
 

Static Public Attributes

static const styledefault_style = dialog_frame::default_style
 
static const stylemessage_style = dialog_frame::message_style
 
static const style hotkeys_style
 
static const int message_font_size = font::SIZE_PLUS
 
static const int caption_font_size = font::SIZE_LARGE
 
static const int max_menu_width = -1
 
static const size_t left_padding = font::relative_size(10)
 
static const size_t right_padding = font::relative_size(10)
 
static const size_t image_h_pad = font::relative_size( 10)
 
static const size_t top_padding = font::relative_size(10)
 
static const size_t bottom_padding = font::relative_size(10)
 

Protected Member Functions

void set_result (const int result)
 
virtual void action (dialog_process_info &dp_info)
 
void refresh ()
 
labelget_message () const
 

Private Types

typedef std::vector
< preview_pane * >::iterator 
pp_iterator
 
typedef std::vector
< preview_pane * >
::const_iterator 
pp_const_iterator
 
typedef std::vector
< dialog_button * >::iterator 
button_iterator
 
typedef std::vector
< dialog_button * >
::const_iterator 
button_const_iterator
 
typedef std::vector< std::pair
< dialog_button
*, BUTTON_LOCATION >
>::iterator 
button_pool_iterator
 
typedef std::vector< std::pair
< dialog_button
*, BUTTON_LOCATION >
>::const_iterator 
button_pool_const_iterator
 

Private Member Functions

void clear_background ()
 
void draw_frame ()
 
void update_widget_positions ()
 
void draw_contents ()
 
int process (dialog_process_info &info)
 

Static Private Member Functions

static menuget_empty_menu (CVideo &video)
 Provides create-on-use semantics for empty_menu. More...
 

Private Attributes

CVideovideo_
 
dialog_imageimage_
 
std::string title_
 
const stylestyle_
 
labeltitle_widget_
 
labelmessage_
 
DIALOG_TYPE type_
 
gui::menumenu_
 
std::vector< preview_pane * > preview_panes_
 
std::vector< std::pair
< dialog_button
*, BUTTON_LOCATION > > 
button_pool_
 
std::vector< dialog_button * > standard_buttons_
 
std::vector< dialog_button * > extra_buttons_
 
std::vector< dialog_button * > top_buttons_
 
std::vector< button * > frame_buttons_
 
std::string topic_
 
dialog_buttonhelp_button_
 
dialog_textboxtext_widget_
 
dialog_frameframe_
 
dimension_measurements dim_
 
int result_
 

Static Private Attributes

static menuempty_menu = nullptr
 A pointer to this empty menu is used instead of nullptr (for menu_). More...
 

Detailed Description

Definition at line 184 of file construct_dialog.hpp.

Member Typedef Documentation

typedef std::vector<dialog_button *>::const_iterator gui::dialog::button_const_iterator
private

Definition at line 205 of file construct_dialog.hpp.

typedef std::vector<dialog_button *>::iterator gui::dialog::button_iterator
private

Definition at line 204 of file construct_dialog.hpp.

typedef std::vector< std::pair<dialog_button *, BUTTON_LOCATION> >::const_iterator gui::dialog::button_pool_const_iterator
private

Definition at line 207 of file construct_dialog.hpp.

typedef std::vector< std::pair<dialog_button *, BUTTON_LOCATION> >::iterator gui::dialog::button_pool_iterator
private

Definition at line 206 of file construct_dialog.hpp.

typedef std::vector<preview_pane *>::const_iterator gui::dialog::pp_const_iterator
private

Definition at line 203 of file construct_dialog.hpp.

typedef std::vector<preview_pane *>::iterator gui::dialog::pp_iterator
private

Definition at line 202 of file construct_dialog.hpp.

Definition at line 199 of file construct_dialog.hpp.

Member Enumeration Documentation

Enumerator
BUTTON_STANDARD 
BUTTON_EXTRA 
BUTTON_EXTRA_LEFT 
BUTTON_CHECKBOX 
BUTTON_CHECKBOX_LEFT 
BUTTON_HELP 
BUTTON_TOP 

Definition at line 186 of file construct_dialog.hpp.

Constructor & Destructor Documentation

gui::dialog::dialog ( CVideo video,
const std::string title = "",
const std::string message = "",
const DIALOG_TYPE  type = MESSAGE,
const style dialog_style = default_style 
)
gui::dialog::~dialog ( )
virtual

Member Function Documentation

void gui::dialog::action ( dialog_process_info dp_info)
protectedvirtual
void gui::dialog::add_button ( dialog_button *const  btn,
BUTTON_LOCATION  loc 
)
void gui::dialog::add_button ( dialog_button_info  btn_info,
BUTTON_LOCATION  loc = BUTTON_EXTRA 
)
void gui::dialog::add_option ( const std::string label,
bool  checked = false,
BUTTON_LOCATION  loc = BUTTON_CHECKBOX,
const std::string help_string = "" 
)
void gui::dialog::add_pane ( preview_pane *const  pp)
inline

Definition at line 246 of file construct_dialog.hpp.

References preview_panes_.

Referenced by gui::show_dialog().

void gui::dialog::clear_background ( )
private

Definition at line 383 of file construct_dialog.cpp.

References frame_.

Referenced by show().

static void gui::dialog::delete_empty_menu ( )
inlinestatic

Explicit freeing of class static resources.

Must not be called if any instances of this class exist. Should be called if the display goes out of scope. (Currently called by ~game_launcher.)

Definition at line 286 of file construct_dialog.hpp.

References empty_menu.

Referenced by game_launcher::~game_launcher().

bool gui::dialog::done ( ) const
inline

Definition at line 276 of file construct_dialog.hpp.

References gui::CONTINUE_DIALOG, and result_.

Referenced by show().

void gui::dialog::draw_contents ( )
private
void gui::dialog::draw_frame ( )
private

Definition at line 388 of file construct_dialog.cpp.

References gui::dialog_frame::draw(), and get_frame().

Referenced by process(), and show().

menu * gui::dialog::get_empty_menu ( CVideo video)
staticprivate

Provides create-on-use semantics for empty_menu.

This is called by dialog's constructor, so other code can use empty_menu directly.

Definition at line 271 of file construct_dialog.cpp.

References empty_menu, help::empty_string_vector, events::sdl_handler::leave(), and gui::menu::simple_style.

dialog_frame & gui::dialog::get_frame ( )
dimension_measurements gui::dialog::get_layout ( ) const
inline

Definition at line 264 of file construct_dialog.hpp.

References dim_.

Referenced by process().

menu& gui::dialog::get_menu ( )
inline
label& gui::dialog::get_message ( ) const
inlineprotected

Definition at line 296 of file construct_dialog.hpp.

References message_.

Referenced by dialogs::file_dialog::action(), and dialogs::file_dialog::file_dialog().

dialog_textbox& gui::dialog::get_textbox ( ) const
inline
CVideo& gui::dialog::get_video ( )
inline
dialog::dimension_measurements gui::dialog::layout ( int  xloc = -1,
int  yloc = -1 
)
virtual

Reimplemented in dialogs::file_dialog.

Definition at line 465 of file construct_dialog.cpp.

References gui::dialog_frame::bottom_padding(), bottom_padding, BUTTON_CHECKBOX, BUTTON_CHECKBOX_LEFT, BUTTON_EXTRA, BUTTON_EXTRA_LEFT, button_pool_, BUTTON_STANDARD, BUTTON_TOP, gui::ButtonHPadding, gui::dialog::dimension_measurements::buttons, gui::dialog_image::caption(), gui::dialog::dimension_measurements::caption_x, gui::dialog::dimension_measurements::caption_y, DBG_DP, extra_buttons_, get_frame(), gui::dialog_textbox::get_label(), get_menu(), gui::label::get_text(), CVideo::getSurface(), CVideo::getx(), CVideo::gety(), gui::widget::height(), i, image_, image_h_pad, help::image_width(), gui::dialog::dimension_measurements::image_x, gui::dialog::dimension_measurements::image_y, gui::dialog::dimension_measurements::interior, gui::dialog::dimension_measurements::label_x, gui::dialog::dimension_measurements::label_y, left_padding, gui::preview_pane::left_side(), gui::widget::location(), menu_, gui::dialog::dimension_measurements::menu_height, gui::dialog::dimension_measurements::menu_width, gui::dialog::dimension_measurements::menu_x, gui::dialog::dimension_measurements::menu_y, gui::dialog::dimension_measurements::message, message_, message_font_size, gui::dialog::dimension_measurements::panes, preview_panes_, font::relative_size(), right_padding, resources::screen, set_layout(), gui::preview_pane::show_above(), gui::textbox::text(), font::text_area(), text_widget_, gui::dialog::dimension_measurements::textbox, top_buttons_, gui::dialog_frame::top_padding(), top_padding, video_, gui::widget::width(), gui::dialog::dimension_measurements::x, and gui::dialog::dimension_measurements::y.

Referenced by show(), and statistics_dialog::statistics_dialog().

bool gui::dialog::option_checked ( unsigned int  option_index = 0)

Definition at line 177 of file construct_dialog.cpp.

References button_pool_, and i.

Referenced by gui::show_dialog().

int gui::dialog::process ( dialog_process_info info)
private
void gui::dialog::refresh ( )
protected

Definition at line 459 of file construct_dialog.cpp.

References CVideo::delay(), CVideo::flip(), and video_.

Referenced by show().

int gui::dialog::result ( ) const
inline
void gui::dialog::set_basic_behavior ( DIALOG_TYPE  type)
inline

Definition at line 266 of file construct_dialog.hpp.

References type_.

void gui::dialog::set_image ( dialog_image *const  img)
inline

Definition at line 237 of file construct_dialog.hpp.

References image_.

Referenced by set_image(), and gui::show_dialog().

void gui::dialog::set_image ( surface  surf,
const std::string caption = "" 
)

Definition at line 904 of file construct_dialog.cpp.

References caption_font_size, font::NORMAL_COLOR, set_image(), and video_.

void gui::dialog::set_layout ( dimension_measurements new_dim)
void gui::dialog::set_menu ( menu *const  m)
inline
void gui::dialog::set_menu ( const std::vector< std::string > &  menu_items,
menu::sorter sorter = nullptr 
)
void gui::dialog::set_menu_items ( const std::vector< std::string > &  menu_items,
bool  keep_selection = false 
)

Changes (or sets, if not previously set) the dialog's menu items to the provided list.

If keep_selected is true, the selection will remain at the same index if possible (otherwise it gets reset to zero).

Definition at line 254 of file construct_dialog.cpp.

References empty_menu, i, menu_, preview_panes_, gui::menu::selection(), gui::menu::set_items(), and set_menu().

Referenced by statistics_dialog::display_stats(), and gui::filter_textbox::handle_text_changed().

void gui::dialog::set_panes ( std::vector< preview_pane * >  panes)
inline

Definition at line 247 of file construct_dialog.hpp.

References preview_panes_.

Referenced by dialogs::advance_unit_dialog().

void gui::dialog::set_result ( const int  result)
inlineprotected

Definition at line 289 of file construct_dialog.hpp.

References result(), and result_.

Referenced by statistics_dialog::action(), dialogs::file_dialog::action(), action(), and show().

void gui::dialog::set_textbox ( dialog_textbox *const  box)
inline

Definition at line 248 of file construct_dialog.hpp.

References text_widget_.

Referenced by dialogs::file_dialog::file_dialog(), and gui::show_dialog().

void gui::dialog::set_textbox ( const std::string text_widget_label = "",
const std::string text_widget_text = "",
const int  text_widget_max_chars = 256,
const unsigned int  text_box_width = font::relative_size(350) 
)
int gui::dialog::show ( int  xloc,
int  yloc 
)
int gui::dialog::show ( )
std::string gui::dialog::textbox_text ( ) const
inline

Definition at line 277 of file construct_dialog.hpp.

References gui::textbox::text(), and text_widget_.

Referenced by dialogs::file_dialog::action(), and gui::show_dialog().

void gui::dialog::update_widget_positions ( )
private

Member Data Documentation

const size_t gui::dialog::bottom_padding = font::relative_size(10)
static

Definition at line 222 of file construct_dialog.hpp.

Referenced by layout().

std::vector< std::pair<dialog_button*,BUTTON_LOCATION> > gui::dialog::button_pool_
private

Definition at line 321 of file construct_dialog.hpp.

Referenced by add_button(), layout(), option_checked(), process(), and ~dialog().

const int gui::dialog::caption_font_size = font::SIZE_LARGE
static

Definition at line 216 of file construct_dialog.hpp.

Referenced by set_image().

const dialog::style & gui::dialog::default_style = dialog_frame::default_style
static
dimension_measurements gui::dialog::dim_
private

Definition at line 330 of file construct_dialog.hpp.

Referenced by get_layout(), set_layout(), show(), and update_widget_positions().

menu * gui::dialog::empty_menu = nullptr
staticprivate

A pointer to this empty menu is used instead of nullptr (for menu_).

Definition at line 308 of file construct_dialog.hpp.

Referenced by delete_empty_menu(), get_empty_menu(), process(), set_menu(), set_menu_items(), and ~dialog().

std::vector<dialog_button*> gui::dialog::extra_buttons_
private

Definition at line 323 of file construct_dialog.hpp.

Referenced by add_button(), layout(), and update_widget_positions().

dialog_frame* gui::dialog::frame_
private

Definition at line 329 of file construct_dialog.hpp.

Referenced by clear_background(), get_frame(), and ~dialog().

std::vector<button*> gui::dialog::frame_buttons_
private

Definition at line 325 of file construct_dialog.hpp.

Referenced by get_frame().

dialog_button* gui::dialog::help_button_
private

Definition at line 327 of file construct_dialog.hpp.

Referenced by add_button(), get_frame(), and update_widget_positions().

const dialog::style gui::dialog::hotkeys_style
static
dialog_image* gui::dialog::image_
private

Definition at line 314 of file construct_dialog.hpp.

Referenced by layout(), set_image(), update_widget_positions(), and ~dialog().

const size_t gui::dialog::image_h_pad = font::relative_size( 10)
static

Definition at line 220 of file construct_dialog.hpp.

Referenced by layout().

const size_t gui::dialog::left_padding = font::relative_size(10)
static

Definition at line 218 of file construct_dialog.hpp.

Referenced by layout().

const int gui::dialog::max_menu_width = -1
static
gui::menu* gui::dialog::menu_
private
label * gui::dialog::message_
private
const int gui::dialog::message_font_size = font::SIZE_PLUS
static

Definition at line 215 of file construct_dialog.hpp.

Referenced by dialog(), layout(), and set_textbox().

const dialog::style & gui::dialog::message_style = dialog_frame::message_style
static

Definition at line 213 of file construct_dialog.hpp.

std::vector<preview_pane*> gui::dialog::preview_panes_
private
int gui::dialog::result_
private

Definition at line 331 of file construct_dialog.hpp.

Referenced by done(), result(), and set_result().

const size_t gui::dialog::right_padding = font::relative_size(10)
static

Definition at line 219 of file construct_dialog.hpp.

Referenced by layout().

std::vector<dialog_button*> gui::dialog::standard_buttons_
private

Definition at line 322 of file construct_dialog.hpp.

Referenced by add_button(), get_frame(), process(), and update_widget_positions().

const style& gui::dialog::style_
private

Definition at line 316 of file construct_dialog.hpp.

Referenced by get_frame().

dialog_textbox* gui::dialog::text_widget_
private
std::string gui::dialog::title_
private

Definition at line 315 of file construct_dialog.hpp.

Referenced by get_frame(), and show().

label* gui::dialog::title_widget_
private

Definition at line 317 of file construct_dialog.hpp.

Referenced by ~dialog().

std::vector<dialog_button*> gui::dialog::top_buttons_
private

Definition at line 324 of file construct_dialog.hpp.

Referenced by add_button(), layout(), and update_widget_positions().

const size_t gui::dialog::top_padding = font::relative_size(10)
static

Definition at line 221 of file construct_dialog.hpp.

Referenced by layout().

std::string gui::dialog::topic_
private

Definition at line 326 of file construct_dialog.hpp.

DIALOG_TYPE gui::dialog::type_
private

Definition at line 318 of file construct_dialog.hpp.

Referenced by process(), set_basic_behavior(), and set_menu().

CVideo& gui::dialog::video_
private

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