The Battle for Wesnoth  1.15.7+dev
edit_text.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 2018 by Iris Morelle <shadowm2006@gmail.com>
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 #pragma once
16 
18 
19 namespace gui2
20 {
21 namespace dialogs
22 {
23 
24 class edit_text : public modal_dialog
25 {
26 public:
27  /**
28  * Constructor.
29  *
30  * @param title The dialog's title.
31  * @param label Label of the text field.
32  * @param [in, out] text The parameter's usage is:
33  * - Input: The initial value of the text field.
34  * - Output: The new unit name the user entered
35  * if the dialog returns @ref retval::OK,
36  * undefined otherwise.
37  * @param disallow_empty Whether to prevent the user from entering a string that is
38  * empty or consists only of whitespace.
39  */
40  edit_text(const std::string& title,
41  const std::string& label,
42  std::string& text,
43  bool disallow_empty = false);
44 
45  /**
46  * Executes the dialog.
47  * See @ref modal_dialog for more information.
48  *
49  * @param [in, out] text The parameter's usage is:
50  * - Input: The initial value of the unit name.
51  * - Output: The new unit name the user entered
52  * if this method returns @a true, undefined
53  * otherwise.
54  */
56 
57 private:
58  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
59  virtual const std::string& window_id() const override;
60 
61  virtual void pre_show(window& window) override;
62 
63  void on_text_change();
64 
66 };
67 } // namespace dialogs
68 } // namespace gui2
virtual const std::string & window_id() const override
Executes the dialog.
Label showing a text.
Definition: label.hpp:32
Generic file dialog.
Definition: field-fwd.hpp:22
edit_text(const std::string &title, const std::string &label, std::string &text, bool disallow_empty=false)
Constructor.
Definition: edit_text.cpp:49
Various uncategorised dialogs.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: edit_text.cpp:60
Abstract base class for all modal dialogs.
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62