The Battle for Wesnoth  1.19.5+dev
tod_new_schedule.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2023 - 2024
3  by Subhraman Sarkar (babaissarkar) <suvrax@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /* dialog that takes new schedule ID and name */
17 
18 #define GETTEXT_DOMAIN "wesnoth-lib"
19 
21 
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, t_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>("id_box").set_value(schedule_id_);
39  find_widget<text_box>("name_box").set_value(schedule_name_);
40 
41  find_widget<button>("ok").set_active(false);
42 
44  find_widget<text_box>("name_box"),
45  std::bind(&tod_new_schedule::button_state_change, this));
47  find_widget<text_box>("id_box"),
48  std::bind(&tod_new_schedule::button_state_change, this));
49 }
50 
52  if (
53  find_widget<text_box>("id_box").get_value().empty()
54  || find_widget<text_box>("name_box").get_value().empty())
55  {
56  find_widget<button>("ok").set_active(false);
57  } else {
58  find_widget<button>("ok").set_active(true);
59  }
60 
62 }
63 
65 {
66  schedule_id_ = find_widget<text_box>("id_box").get_value();
67  schedule_name_ = find_widget<text_box>("name_box").get_value();
68 }
69 
70 }
Abstract base class for all modal dialogs.
Dialog that takes new schedule ID and name from the player.
virtual void post_show() override
Actions to be taken after the window has been shown.
virtual void pre_show() override
Actions to be taken before showing the window.
tod_new_schedule(std::string &schedule_id, t_string &schedule_name)
void queue_redraw()
Indicates that this widget should be redrawn.
Definition: widget.cpp:464
window * get_window()
Get the parent window.
Definition: widget.cpp:117
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