The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
synced_choice_wait.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Ignacio Riquelme Morelle <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
16 
18 #include "gui/widgets/label.hpp"
19 #include "gui/widgets/button.hpp"
20 #include "gui/widgets/settings.hpp"
21 #include "gui/widgets/window.hpp"
22 #include "quit_confirmation.hpp"
23 
24 #include "gui/dialogs/message.hpp"
25 #include "game_end_exceptions.hpp"
26 #include "gettext.hpp"
27 
28 
29 #include "utils/functional.hpp"
30 
31 namespace gui2
32 {
33 
34 /*WIKI
35  * @page = GUIWindowDefinitionWML
36  * @order = 2_theme_list
37  *
38  * == Theme list ==
39  *
40  * Dialog for selecting a GUI theme.
41  *
42  * @begin{table}{dialog_widgets}
43  *
44  * themes & & listbox & m &
45  * Listbox displaying user choices. $
46  *
47  * -name & & control & m &
48  * Widget which shows a theme item name. $
49  *
50  * -description & & control & m &
51  * Widget which shows a theme item description. $
52  *
53  * @end{table}
54  */
55 
56 REGISTER_DIALOG(synced_choice_wait)
57 
59  : mgr_(mgr)
60  , message_()
61  , window_(nullptr)
62 {
63  mgr_.changed_event_.attach_handler(this);
64 }
65 
67 {
69 }
70 
72 {
73  window_ = &window;
74  message_ = find_widget<tlabel>(&window, "lblMessage", false, true);
75 
76 
77  tbutton& quit_button = find_widget<tbutton>(
78  &window, "btn_quit_game", false);
79 
82 
84  if(mgr_.finished() || !mgr_.waiting()) {
85  window_->close();
86  }
87 }
88 
90 {
91  assert(event_name == "user_choice_update");
92  assert(message_);
94  if(mgr_.finished() || !mgr_.waiting()) {
95  window_->close();
96  }
97 }
98 
99 }
static void quit_to_title()
user_choice_manager & mgr_
This file contains the window object, this object is a top level container which has the event manage...
REGISTER_DIALOG(label_settings)
virtual void set_label(const t_string &label)
Definition: control.cpp:330
void connect_signal_mouse_left_click(tdispatcher &dispatcher, const tsignal_function &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.hpp:710
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
Simple push button.
Definition: button.hpp:32
bool waiting()
Note: currently finished() does not imply !waiting() so you may need to check both.
This file contains the settings handling of the widget library.
events::generic_event changed_event_
const std::string & wait_message()
void close()
Requests to close the window.
Definition: window.hpp:235
virtual bool detach_handler(observer *obs)
void pre_show(twindow &window)
Inherited from tdialog.
virtual void handle_generic_event(const std::string &event_name)
GLsizei const GLcharARB ** string
Definition: glew.h:4503