The Battle for Wesnoth  1.19.0-dev
tod_new_schedule.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2023 - 2024
3  Part of the Battle for Wesnoth Project https://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 
15 /* dialog that takes new schedule ID and name */
16 
17 #define GETTEXT_DOMAIN "wesnoth-lib"
18 
20 
22 #include "gui/widgets/button.hpp"
23 #include "gui/widgets/text_box.hpp"
24 
25 namespace gui2::dialogs
26 {
27 
29 
30 tod_new_schedule::tod_new_schedule(std::string& schedule_id, std::string& schedule_name)
31  : modal_dialog(window_id())
32  , schedule_id_(schedule_id)
33  , schedule_name_(schedule_name)
34 {
35 }
36 
38  find_widget<text_box>(&win, "id_box", false).set_value(schedule_id_);
39  find_widget<text_box>(&win, "name_box", false).set_value(schedule_name_);
40 
41  find_widget<button>(get_window(), "ok", false).set_active(false);
42 
44  find_widget<text_box>(&win, "name_box", false),
45  std::bind(&tod_new_schedule::button_state_change, this));
47  find_widget<text_box>(&win, "id_box", false),
48  std::bind(&tod_new_schedule::button_state_change, this));
49 }
50 
52  if (
53  find_widget<text_box>(get_window(), "id_box", false).get_value().empty()
54  || find_widget<text_box>(get_window(), "name_box", false).get_value().empty())
55  {
56  find_widget<button>(get_window(), "ok", false).set_active(false);
57  } else {
58  find_widget<button>(get_window(), "ok", false).set_active(true);
59  }
60 
62 }
63 
65 {
66  schedule_id_ = find_widget<text_box>(&win, "id_box", false).get_value();
67  schedule_name_ = find_widget<text_box>(&win, "name_box", false).get_value();
68 }
69 
70 }
Abstract base class for all modal dialogs.
window * get_window()
Returns a pointer to the dialog's window.
Dialog that takes new schedule ID and name from the player.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
tod_new_schedule(std::string &schedule_id, std::string &schedule_name)
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
void queue_redraw()
Indicates that this widget should be redrawn.
Definition: widget.cpp:455
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:63
REGISTER_DIALOG(editor_edit_unit)
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
Definition: dispatcher.cpp:203