The Battle for Wesnoth  1.17.0-dev
resize_map.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2021
3  by Mark de Wever <koraq@xs4all.nl>
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 #pragma once
17 
19 
20 namespace gui2
21 {
22 
23 class toggle_button;
24 
25 namespace dialogs
26 {
27 
28 /**
29  * @ingroup GUIWindowDefinitionWML
30  *
31  * This shows the dialog to resize the current map.
32  * Key |Type |Mandatory|Description
33  * ------------------|------------------|---------|-----------
34  * old_width | @ref label |no |Shows the old width of the map.
35  * old_height | @ref label |no |Shows the old height of the map.
36  * width | @ref slider |yes |Determines the new width of the map.
37  * height | @ref slider |yes |Determines the new height of the map.
38  * copy_edge_terrain | boolean_selector |yes |Determines whether the border terrains should be used to expand or not.
39  * expand0 | toggle_button |yes |Determines in which direction to expand, shows the north east marker.
40  * expand1 | toggle_button |yes |Determines in which direction to expand, shows the north marker.
41  * expand2 | toggle_button |yes |Determines in which direction to expand, shows the north west marker.
42  * expand3 | toggle_button |yes |Determines in which direction to expand, shows the east marker.
43  * expand4 | toggle_button |yes |Determines in which direction to expand, shows the center marker.
44  * expand5 | toggle_button |yes |Determines in which direction to expand, shows the west marker.
45  * expand6 | toggle_button |yes |Determines in which direction to expand, shows the south east marker.
46  * expand7 | toggle_button |yes |Determines in which direction to expand, shows the south marker.
47  * expand8 | toggle_button |yes |Determines in which direction to expand, shows the south west marker.
48  */
50 {
51 public:
62  };
63 
64  /**
65  * Constructor.
66  *
67  * @param [in, out] width The parameter's usage is:
68  * - Input: The initial width of the map.
69  * - Output: The selected width of the map if
70  * the dialog returns retval::OK
71  * undefined otherwise.
72  *
73  * @param [in, out] height The parameter's usage is:
74  * - Input: The initial height of the map.
75  * - Output: The selected height of the map if
76  * the dialog returns retval::OK
77  * undefined otherwise.
78  *
79  * @param [out] expand_direction
80  * The selected expand direction if the dialog
81  * returns retval::OK undefined
82  * otherwise.
83  *
84  * @param [in, out] copy_edge_terrain
85  * The parameter's usage is:
86  * - Input: The initial value of the copy edge
87  * toggle.
88  * - Output: The final value of the copy edge
89  * toggle if the dialog returns
90  * retval::OK undefined otherwise.
91  */
92  editor_resize_map(int& width,
93  int& height,
94  EXPAND_DIRECTION& expand_direction,
95  bool& copy_edge_terrain);
96 
97  /** The execute function. See @ref modal_dialog for more information. */
99 
100 private:
101  /** The currently selected width. */
103 
104  /** The currently selected height. */
106 
107  /** The original width. */
109 
110  /** The original height. */
112 
113  /** The selected expansion direction. */
115 
116  /**
117  * The toggle buttons show the state of expand_direction_.
118  *
119  * Allows both so select a direction and visually show the effect of the
120  * selection.
121  */
123 
125 
126  void set_direction_icon(int index, std::string icon);
127 
128  virtual void pre_show(window& window) override;
129 
130  virtual const std::string& window_id() const override;
131 };
132 
133 } // namespace dialogs
134 } // namespace gui2
virtual const std::string & window_id() const override
The id of the window to build.
editor_resize_map(int &width, int &height, EXPAND_DIRECTION &expand_direction, bool &copy_edge_terrain)
Constructor.
Definition: resize_map.cpp:32
Generic file dialog.
Definition: field-fwd.hpp:23
field_integer * height_
The currently selected height.
Definition: resize_map.hpp:105
toggle_button * direction_buttons_[9]
The toggle buttons show the state of expand_direction_.
Definition: resize_map.hpp:122
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: resize_map.cpp:49
Various uncategorised dialogs.
This shows the dialog to resize the current map.
Definition: resize_map.hpp:49
EXPAND_DIRECTION & expand_direction_
The selected expansion direction.
Definition: resize_map.hpp:114
void set_direction_icon(int index, std::string icon)
Definition: resize_map.cpp:87
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:72
int old_width_
The original width.
Definition: resize_map.hpp:108
Abstract base class for all modal dialogs.
int old_height_
The original height.
Definition: resize_map.hpp:111
field_integer * width_
The execute function.
Definition: resize_map.hpp:102
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
Template class to implement the generic field implementation.
Definition: field-fwd.hpp:36
Class for a toggle button.