#include <construct_dialog.hpp>
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_frame & | get_frame () |
void | set_basic_behavior (DIALOG_TYPE type) |
int | show (int xloc, int yloc) |
int | show () |
int | result () const |
menu & | get_menu () |
bool | done () const |
std::string | textbox_text () const |
dialog_textbox & | get_textbox () const |
bool | option_checked (unsigned int option_index=0) |
CVideo & | get_video () |
Static Public Member Functions | |
static void | delete_empty_menu () |
Explicit freeing of class static resources. More... | |
Static Public Attributes | |
static const style & | default_style = dialog_frame::default_style |
static const style & | message_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 () |
label & | get_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 menu * | get_empty_menu (CVideo &video) |
Provides create-on-use semantics for empty_menu. More... | |
Private Attributes | |
CVideo & | video_ |
dialog_image * | image_ |
std::string | title_ |
const style & | style_ |
label * | title_widget_ |
label * | message_ |
DIALOG_TYPE | type_ |
gui::menu * | menu_ |
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_button * | help_button_ |
dialog_textbox * | text_widget_ |
dialog_frame * | frame_ |
dimension_measurements | dim_ |
int | result_ |
Static Private Attributes | |
static menu * | empty_menu = nullptr |
A pointer to this empty menu is used instead of nullptr (for menu_). More... | |
Definition at line 184 of file construct_dialog.hpp.
|
private |
Definition at line 205 of file construct_dialog.hpp.
|
private |
Definition at line 204 of file construct_dialog.hpp.
|
private |
Definition at line 207 of file construct_dialog.hpp.
|
private |
Definition at line 206 of file construct_dialog.hpp.
|
private |
Definition at line 203 of file construct_dialog.hpp.
|
private |
Definition at line 202 of file construct_dialog.hpp.
Definition at line 199 of file construct_dialog.hpp.
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.
gui::dialog::dialog | ( | CVideo & | video, |
const std::string & | title = "" , |
||
const std::string & | message = "" , |
||
const DIALOG_TYPE | type = MESSAGE , |
||
const style & | dialog_style = default_style |
||
) |
Definition at line 97 of file construct_dialog.cpp.
References _(), add_button(), BUTTON_STANDARD, gui::CANCEL_ONLY, gui::CLOSE_ONLY, ERR_DP, CVideo::getx(), CVideo::gety(), gui::MESSAGE, message_, message_font_size, game_logic::msg(), font::NORMAL_COLOR, gui::OK_CANCEL, gui::OK_ONLY, video_, font::word_wrap_text(), and gui::YES_NO.
|
virtual |
Definition at line 155 of file construct_dialog.cpp.
References button_pool_, empty_menu, frame_, image_, menu_, message_, text_widget_, and title_widget_.
|
protectedvirtual |
Reimplemented in dialogs::file_dialog, and statistics_dialog.
Definition at line 872 of file construct_dialog.cpp.
References gui::CONTINUE_DIALOG, gui::DELETE_ITEM, gui::menu::erase_item(), gui::dialog_process_info::first_time, menu_, result(), gui::menu::selection(), and set_result().
Referenced by show().
void gui::dialog::add_button | ( | dialog_button *const | btn, |
BUTTON_LOCATION | loc | ||
) |
Definition at line 191 of file construct_dialog.cpp.
References BUTTON_CHECKBOX, BUTTON_CHECKBOX_LEFT, BUTTON_EXTRA, BUTTON_EXTRA_LEFT, BUTTON_HELP, button_pool_, BUTTON_STANDARD, BUTTON_TOP, extra_buttons_, help_button_, gui::dialog_button::set_parent(), standard_buttons_, and top_buttons_.
Referenced by add_button(), add_option(), dialog(), dialogs::file_dialog::file_dialog(), dialogs::recruit_dialog(), gui::show_dialog(), and statistics_dialog::statistics_dialog().
void gui::dialog::add_button | ( | dialog_button_info | btn_info, |
BUTTON_LOCATION | loc = BUTTON_EXTRA |
||
) |
Definition at line 219 of file construct_dialog.cpp.
References add_button(), gui::CONTINUE_DIALOG, gui::dialog_button_info::handler, gui::dialog_button_info::label, gui::button::TYPE_PRESS, and video_.
void gui::dialog::add_option | ( | const std::string & | label, |
bool | checked = false , |
||
BUTTON_LOCATION | loc = BUTTON_CHECKBOX , |
||
const std::string & | help_string = "" |
||
) |
Definition at line 225 of file construct_dialog.cpp.
References add_button(), gui::button::set_check(), gui::widget::set_help_string(), gui::button::TYPE_CHECK, and video_.
Referenced by gui::show_dialog().
|
inline |
Definition at line 246 of file construct_dialog.hpp.
References preview_panes_.
Referenced by gui::show_dialog().
|
private |
|
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().
|
inline |
Definition at line 276 of file construct_dialog.hpp.
References gui::CONTINUE_DIALOG, and result_.
Referenced by show().
|
private |
Definition at line 353 of file construct_dialog.cpp.
References gui::widget::draw(), CVideo::flip(), gui::preview_pane::handler_members(), i, preview_panes_, events::raise_draw_event(), and video_.
Referenced by show().
|
private |
Definition at line 388 of file construct_dialog.cpp.
References gui::dialog_frame::draw(), and get_frame().
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 | ( | ) |
Definition at line 370 of file construct_dialog.cpp.
References frame_, frame_buttons_, help_button_, standard_buttons_, style_, title_, and video_.
Referenced by draw_frame(), layout(), process(), set_layout(), and show().
|
inline |
|
inline |
Definition at line 275 of file construct_dialog.hpp.
References menu_.
Referenced by statistics_dialog::action(), gui::dialog_button::action(), dialogs::file_dialog::layout(), layout(), and update_widget_positions().
|
inlineprotected |
Definition at line 296 of file construct_dialog.hpp.
References message_.
Referenced by dialogs::file_dialog::action(), and dialogs::file_dialog::file_dialog().
|
inline |
Definition at line 278 of file construct_dialog.hpp.
References text_widget_.
Referenced by dialogs::file_dialog::action(), dialogs::file_dialog::layout(), dialogs::file_dialog::select_file(), and dialogs::file_dialog::set_save_text().
|
inline |
Definition at line 280 of file construct_dialog.hpp.
References video_.
Referenced by statistics_dialog::action(), dialogs::file_dialog::action(), and statistics_dialog::do_scene_selection().
|
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().
|
private |
Definition at line 755 of file construct_dialog.cpp.
References button_pool_, game_config::sounds::button_press, gui::CLOSE_DIALOG, gui::CLOSE_ONLY, gui::CONTINUE_DIALOG, gui::dialog_process_info::double_clicked, gui::menu::double_clicked(), draw_frame(), empty_menu, gui::dialog_process_info::first_time, get_frame(), get_layout(), i, gui::dialog_process_info::key, gui::dialog_process_info::key_down, gui::dialog_process_info::left_button, gui::widget::location(), menu_, gui::dialog_process_info::new_key_down, gui::dialog_process_info::new_left_button, gui::dialog_process_info::new_right_button, gui::OK_CANCEL, gui::OK_ONLY, sound::play_UI_sound(), sdl::point_in_rect(), preview_panes_, gui::menu::process(), events::raise_draw_event(), events::raise_process_event(), gui::dialog_process_info::right_button, gui::dialog_process_info::selection, gui::menu::selection(), standard_buttons_, text_widget_, type_, and gui::YES_NO.
Referenced by show().
|
protected |
Definition at line 459 of file construct_dialog.cpp.
References CVideo::delay(), CVideo::flip(), and video_.
Referenced by show().
|
inline |
Definition at line 274 of file construct_dialog.hpp.
References result_.
Referenced by statistics_dialog::action(), dialogs::file_dialog::action(), action(), set_result(), show(), gui::show_dialog(), dialogs::show_file_chooser_dialog(), and dialogs::show_file_chooser_dialog_save().
|
inline |
Definition at line 266 of file construct_dialog.hpp.
References type_.
|
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 | ) |
Definition at line 749 of file construct_dialog.cpp.
References dim_, get_frame(), gui::dialog::dimension_measurements::interior, and gui::dialog_frame::layout().
Referenced by dialogs::file_dialog::layout(), and layout().
Definition at line 239 of file construct_dialog.hpp.
References empty_menu, and menu_.
Referenced by statistics_dialog::action(), dialogs::advance_unit_dialog(), events::console_handler::do_layers(), dialogs::file_dialog::file_dialog(), set_menu(), set_menu_items(), gui::show_dialog(), hotkey::command_executor::show_menu(), and dialogs::show_unit_list().
void gui::dialog::set_menu | ( | const std::vector< std::string > & | menu_items, |
menu::sorter * | sorter = nullptr |
||
) |
Definition at line 243 of file construct_dialog.cpp.
References gui::menu::default_style, max_menu_width, gui::MESSAGE, set_menu(), type_, and video_.
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().
|
inline |
Definition at line 247 of file construct_dialog.hpp.
References preview_panes_.
Referenced by dialogs::advance_unit_dialog().
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().
|
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) |
||
) |
Definition at line 233 of file construct_dialog.cpp.
References gui2::event::find(), message_font_size, font::NORMAL_COLOR, gui::textbox::set_wrap(), text_widget_, and video_.
Definition at line 280 of file construct_dialog.cpp.
References layout(), and show().
Referenced by statistics_dialog::action(), dialogs::advance_unit_dialog(), gui::show_dialog(), dialogs::show_file_chooser_dialog(), dialogs::show_file_chooser_dialog_save(), hotkey::command_executor::show_menu(), and events::menu_handler::show_statistics().
int gui::dialog::show | ( | ) |
Definition at line 286 of file construct_dialog.cpp.
References action(), plugins_manager::any_running(), clear_background(), gui::CLOSE_DIALOG, gui::CONTINUE_DIALOG, gui::dialog_process_info::cycle(), dim_, done(), draw_contents(), draw_frame(), sdl::empty_rect, ERR_DP, CVideo::faked(), plugins_manager::get(), get_frame(), get_int, gui::label::get_text(), gui::dialog::dimension_measurements::interior, events::sdl_handler::join(), layout(), LOG_DP, message_, plugins_manager::notify_event(), plugins_context::play_slice(), process(), events::pump(), refresh(), result(), plugins_context::set_callback(), set_result(), title_, CVideo::update_locked(), update_widget_positions(), and video_.
Referenced by show().
|
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().
|
private |
Definition at line 393 of file construct_dialog.cpp.
References gui::dialog::dimension_measurements::buttons, gui::dialog_image::caption(), gui::dialog::dimension_measurements::caption_x, gui::dialog::dimension_measurements::caption_y, dim_, extra_buttons_, gui::dialog_textbox::get_label(), get_menu(), help_button_, i, image_, gui::dialog::dimension_measurements::image_x, gui::dialog::dimension_measurements::image_y, events::sdl_handler::join(), gui::dialog::dimension_measurements::label_x, gui::dialog::dimension_measurements::label_y, events::sdl_handler::leave(), 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_, gui::dialog::dimension_measurements::panes, preview_panes_, gui::widget::set_location(), gui::menu::set_max_height(), gui::menu::set_max_width(), gui::menu::set_numeric_keypress_selection(), gui::widget::set_width(), standard_buttons_, text_widget_, gui::dialog::dimension_measurements::textbox, and top_buttons_.
Referenced by show().
|
static |
Definition at line 222 of file construct_dialog.hpp.
Referenced by layout().
|
private |
Definition at line 321 of file construct_dialog.hpp.
Referenced by add_button(), layout(), option_checked(), process(), and ~dialog().
|
static |
Definition at line 216 of file construct_dialog.hpp.
Referenced by set_image().
|
static |
Definition at line 212 of file construct_dialog.hpp.
Referenced by dialogs::recall_dialog(), dialogs::recruit_dialog(), and gui::show_dialog().
|
private |
Definition at line 330 of file construct_dialog.hpp.
Referenced by get_layout(), set_layout(), show(), and update_widget_positions().
|
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().
|
private |
Definition at line 323 of file construct_dialog.hpp.
Referenced by add_button(), layout(), and update_widget_positions().
|
private |
Definition at line 329 of file construct_dialog.hpp.
Referenced by clear_background(), get_frame(), and ~dialog().
|
private |
Definition at line 325 of file construct_dialog.hpp.
Referenced by get_frame().
|
private |
Definition at line 327 of file construct_dialog.hpp.
Referenced by add_button(), get_frame(), and update_widget_positions().
|
static |
Definition at line 214 of file construct_dialog.hpp.
Referenced by gui::combo::make_drop_down_menu(), and hotkey::command_executor::show_menu().
|
private |
Definition at line 314 of file construct_dialog.hpp.
Referenced by layout(), set_image(), update_widget_positions(), and ~dialog().
|
static |
Definition at line 220 of file construct_dialog.hpp.
Referenced by layout().
|
static |
Definition at line 218 of file construct_dialog.hpp.
Referenced by layout().
|
static |
Definition at line 217 of file construct_dialog.hpp.
Referenced by dialogs::recall_dialog(), dialogs::recruit_dialog(), set_menu(), and gui::show_dialog().
|
private |
Definition at line 319 of file construct_dialog.hpp.
Referenced by action(), get_menu(), layout(), process(), set_menu(), set_menu_items(), update_widget_positions(), and ~dialog().
|
private |
Definition at line 317 of file construct_dialog.hpp.
Referenced by dialog(), get_message(), layout(), show(), update_widget_positions(), and ~dialog().
|
static |
Definition at line 215 of file construct_dialog.hpp.
Referenced by dialog(), layout(), and set_textbox().
|
static |
Definition at line 213 of file construct_dialog.hpp.
|
private |
Definition at line 320 of file construct_dialog.hpp.
Referenced by add_pane(), draw_contents(), layout(), process(), set_menu_items(), set_panes(), and update_widget_positions().
|
private |
Definition at line 331 of file construct_dialog.hpp.
Referenced by done(), result(), and set_result().
|
static |
Definition at line 219 of file construct_dialog.hpp.
Referenced by layout().
|
private |
Definition at line 322 of file construct_dialog.hpp.
Referenced by add_button(), get_frame(), process(), and update_widget_positions().
|
private |
Definition at line 316 of file construct_dialog.hpp.
Referenced by get_frame().
|
private |
Definition at line 328 of file construct_dialog.hpp.
Referenced by get_textbox(), layout(), process(), set_textbox(), textbox_text(), update_widget_positions(), and ~dialog().
|
private |
Definition at line 315 of file construct_dialog.hpp.
Referenced by get_frame(), and show().
|
private |
Definition at line 317 of file construct_dialog.hpp.
Referenced by ~dialog().
|
private |
Definition at line 324 of file construct_dialog.hpp.
Referenced by add_button(), layout(), and update_widget_positions().
|
static |
Definition at line 221 of file construct_dialog.hpp.
Referenced by layout().
|
private |
Definition at line 326 of file construct_dialog.hpp.
|
private |
Definition at line 318 of file construct_dialog.hpp.
Referenced by process(), set_basic_behavior(), and set_menu().
|
private |
Definition at line 313 of file construct_dialog.hpp.
Referenced by add_button(), add_option(), dialog(), draw_contents(), get_frame(), get_video(), layout(), refresh(), set_image(), set_menu(), set_textbox(), and show().