The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
spacer.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2008 - 2025
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
22
23namespace gui2
24{
25namespace implementation
26{
27struct builder_spacer;
28}
29
30// ------------ WIDGET -----------{
31
32class spacer : public styled_widget
33{
34public:
35 spacer(const implementation::builder_spacer& builder, const std::string& w = "0", const std::string& h = "0");
36
37 /***** ***** ***** ***** layout functions ***** ***** ***** *****/
38
39 /** See @ref widget::request_reduce_width. */
40 virtual void request_reduce_width(const unsigned maximum_width) override;
41
42 /** See @ref widget::request_reduce_height. */
43 virtual void request_reduce_height(const unsigned maximum_height) override;
44
45private:
46 /** See @ref widget::calculate_best_size. */
47 virtual point calculate_best_size() const override;
48
49public:
50 /***** ***** ***** ***** Inherited ***** ***** ***** *****/
51
52 /** See @ref styled_widget::set_active. */
53 virtual void set_active(const bool active) override;
54
55 /** See @ref styled_widget::get_active. */
56 virtual bool get_active() const override;
57
58 /** See @ref styled_widget::get_state. */
59 virtual unsigned get_state() const override;
60
61 /** See @ref widget::disable_click_dismiss. */
62 bool disable_click_dismiss() const override;
63
64 /***** ***** ***** setters / getters for members ***** ****** *****/
65
66private:
69
71
72 /** See @ref widget::impl_draw_background. */
73 virtual bool impl_draw_background() override;
74
75public:
76 /** Static type getter that does not rely on the widget being constructed. */
77 static const std::string& type();
78
79private:
80 /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
81 virtual const std::string& get_control_type() const override;
82};
83
84// }---------- DEFINITION ---------{
85
87{
88 explicit spacer_definition(const config& cfg);
89
91 {
92 explicit resolution(const config& cfg);
93 };
94};
95
96// }---------- BUILDER -----------{
97
98namespace implementation
99{
100
102{
103 explicit builder_spacer(const config& cfg);
104
106
107 virtual std::unique_ptr<widget> build() const override;
108
109private:
110 // We store these as strings since they could contain formulas.
111 // The widget handles the parsing.
112 const std::string width_;
113 const std::string height_;
114};
115
116} // namespace implementation
117
118// }------------ END --------------
119
120} // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
virtual void request_reduce_height(const unsigned maximum_height) override
See widget::request_reduce_height.
Definition spacer.cpp:50
virtual unsigned get_state() const override
See styled_widget::get_state.
Definition spacer.cpp:88
bool fills_available_space()
Definition spacer.cpp:37
virtual void set_active(const bool active) override
See styled_widget::set_active.
Definition spacer.cpp:78
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
virtual bool impl_draw_background() override
See widget::impl_draw_background.
Definition spacer.cpp:98
typed_formula< unsigned > width_
Definition spacer.hpp:67
virtual bool get_active() const override
See styled_widget::get_active.
Definition spacer.cpp:83
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
Definition spacer.cpp:93
virtual point calculate_best_size() const override
See widget::calculate_best_size.
Definition spacer.cpp:58
typed_formula< unsigned > height_
Definition spacer.hpp:68
virtual void request_reduce_width(const unsigned maximum_width) override
See widget::request_reduce_width.
Definition spacer.cpp:42
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
Template class can hold a value or a formula to calculate the value.
const config * cfg
Generic file dialog.
Contains the implementation details for lexical_cast and shouldn't be used directly.
int w
Definition pathfind.cpp:188
virtual std::unique_ptr< widget > build() const override
Definition spacer.cpp:129
virtual std::unique_ptr< widget > build() const=0
Holds a 2D point.
Definition point.hpp:25
#define h