The Battle for Wesnoth  1.19.2+dev
size_lock.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2024
3  by Jyrki Vesterinen <sandgtx@gmail.com>
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 
23 
24 namespace gui2
25 {
26 
27 namespace implementation
28 {
29 struct builder_size_lock;
30 }
31 
32 class size_lock : public container_base
33 {
35 
36 public:
37  explicit size_lock(const implementation::builder_size_lock& builder);
38 
39  bool get_active() const override
40  {
41  return true;
42  }
43 
44  unsigned get_state() const override
45  {
46  return 0;
47  }
48 
49  /** See @ref widget::place. */
50  void place(const point& origin, const point& size) override;
51 
52  /** See @ref widget::layout_children. */
53  void layout_children() override;
54 
55 protected:
56  point calculate_best_size() const override;
57 
58 private:
61 
62  /**
63  * Points to the actual widget.
64  *
65  * The widget is owned by container_base (the base class).
66  */
68 
69  /**
70  * Finishes the building initialization of the widget.
71  *
72  * @param widget_builder The builder to build the contents of the
73  * widget.
74  */
75  void finalize(const builder_widget& widget_builder);
76 
77 public:
78  /** Static type getter that does not rely on the widget being constructed. */
79  static const std::string& type();
80 
81 private:
82  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
83  virtual const std::string& get_control_type() const override;
84 
85  /** See @ref container_base::set_self_active */
86  void set_self_active(const bool) override
87  {
88  // DO NOTHING
89  }
90 };
91 
93 {
94  explicit size_lock_definition(const config& cfg);
95 
97  {
98  explicit resolution(const config& cfg);
99 
101  };
102 };
103 
104 namespace implementation
105 {
106 
108 {
109  explicit builder_size_lock(const config& cfg);
110 
112 
113  virtual std::unique_ptr<widget> build() const override;
114 
117 
118 private:
120 };
121 }
122 }
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
A generic container base class.
typed_formula< unsigned > width_
Definition: size_lock.hpp:59
void place(const point &origin, const point &size) override
See widget::place.
Definition: size_lock.cpp:38
unsigned get_state() const override
Returns the id of the state.
Definition: size_lock.hpp:44
typed_formula< unsigned > height_
Definition: size_lock.hpp:60
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
bool get_active() const override
Gets the active state of the styled_widget.
Definition: size_lock.hpp:39
void finalize(const builder_widget &widget_builder)
Finishes the building initialization of the widget.
Definition: size_lock.cpp:71
void layout_children() override
See widget::layout_children.
Definition: size_lock.cpp:64
widget * widget_
Points to the actual widget.
Definition: size_lock.hpp:67
point calculate_best_size() const override
See widget::calculate_best_size.
Definition: size_lock.cpp:81
void set_self_active(const bool) override
See container_base::set_self_active.
Definition: size_lock.hpp:86
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
size_lock(const implementation::builder_size_lock &builder)
Definition: size_lock.cpp:30
Base class for all widgets.
Definition: widget.hpp:53
Generic file dialog.
std::shared_ptr< builder_grid > builder_grid_ptr
std::shared_ptr< const builder_widget > builder_widget_const_ptr
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:85
Contains the info needed to instantiate a widget.
typed_formula< unsigned > height_
Definition: size_lock.hpp:116
typed_formula< unsigned > width_
Definition: size_lock.hpp:115
virtual std::unique_ptr< widget > build() const override
Definition: size_lock.cpp:127
builder_widget_const_ptr content_
Definition: size_lock.hpp:119
virtual std::unique_ptr< widget > build() const=0
size_lock_definition(const config &cfg)
Definition: size_lock.cpp:93
Holds a 2D point.
Definition: point.hpp:25