The Battle for Wesnoth  1.19.0-dev
prompt.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 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
17 #include "gui/dialogs/prompt.hpp"
18 
20 #include "gui/widgets/text_box.hpp"
21 
22 namespace gui2::dialogs
23 {
24 
25 REGISTER_DIALOG(prompt)
26 
27 prompt::prompt(std::string& value)
28  : modal_dialog(window_id())
29  , value_(value)
30 {
31  find_widget<text_box>(get_window(), "prompt_box", false).set_value(value);
32 }
33 
35 {
36  text_box* prompt_box = find_widget<text_box>(&win, "prompt_box", false, true);
37  win.keyboard_capture(prompt_box);
38 }
39 
41 {
42  value_ = find_widget<text_box>(&win, "prompt_box", false).get_value();
43 }
44 
45 } // namespace gui2::dialogs
Abstract base class for all modal dialogs.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: prompt.cpp:40
std::string & value_
Definition: prompt.hpp:39
virtual void pre_show(window &window) override
The execute function.
Definition: prompt.cpp:34
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:61
void keyboard_capture(widget *widget)
Definition: window.cpp:1221
REGISTER_DIALOG(editor_edit_unit)
SDL_Window * get_window()
Definition: video.cpp:655