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