The Battle for Wesnoth  1.19.7+dev
panel.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
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 
23 namespace gui2
24 {
25 
26 // ------------ WIDGET -----------{
27 
28 class panel : public container_base
29 {
30 public:
31  /**
32  * Constructor.
33  */
34  panel(const implementation::builder_styled_widget& builder, const std::string& control_type = "");
35 
36  /** See @ref container_base::get_client_rect. */
37  virtual SDL_Rect get_client_rect() const override;
38 
39  /** See @ref styled_widget::get_active. */
40  virtual bool get_active() const override;
41 
42  /** See @ref styled_widget::get_state. */
43  virtual unsigned get_state() const override;
44 
45 private:
46  /** See @ref widget::impl_draw_background. */
47  virtual bool impl_draw_background() override;
48 
49  /** See @ref widget::impl_draw_foreground. */
50  virtual bool impl_draw_foreground() override;
51 
52 public:
53  /** Static type getter that does not rely on the widget being constructed. */
54  static const std::string& type();
55 
56 private:
57  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
58  virtual const std::string& get_control_type() const override;
59 
60  /** See @ref container_base::border_space. */
61  virtual point border_space() const override;
62 
63  /** See @ref container_base::set_self_active. */
64  virtual void set_self_active(const bool active) override;
65 };
66 
67 // }---------- DEFINITION ---------{
68 
70 {
71  explicit panel_definition(const config& cfg);
72 
74  {
75  explicit resolution(const config& cfg);
76 
77  unsigned top_border;
78  unsigned bottom_border;
79 
80  unsigned left_border;
81  unsigned right_border;
82  };
83 };
84 
85 // }---------- BUILDER -----------{
86 
87 namespace implementation
88 {
89 
91 {
92  explicit builder_panel(const config& cfg);
93 
95 
96  virtual std::unique_ptr<widget> build() const override;
97 
99 };
100 
101 } // namespace implementation
102 
103 // }------------ END --------------
104 
105 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
A generic container base class.
virtual bool impl_draw_foreground() override
See widget::impl_draw_foreground.
Definition: panel.cpp:76
virtual bool impl_draw_background() override
See widget::impl_draw_background.
Definition: panel.cpp:66
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
virtual bool get_active() const override
See styled_widget::get_active.
Definition: panel.cpp:56
panel(const implementation::builder_styled_widget &builder, const std::string &control_type="")
Constructor.
Definition: panel.cpp:37
virtual unsigned get_state() const override
See styled_widget::get_state.
Definition: panel.cpp:61
virtual SDL_Rect get_client_rect() const override
See container_base::get_client_rect.
Definition: panel.cpp:42
virtual point border_space() const override
See container_base::border_space.
Definition: panel.cpp:86
virtual void set_self_active(const bool active) override
See container_base::set_self_active.
Definition: panel.cpp:94
Generic file dialog.
std::shared_ptr< builder_grid > builder_grid_ptr
Contains the implementation details for lexical_cast and shouldn't be used directly.
builder_panel(const config &cfg)
Definition: panel.cpp:126
virtual std::unique_ptr< widget > build() const override
Definition: panel.cpp:136
virtual std::unique_ptr< widget > build() const=0
resolution(const config &cfg)
Definition: panel.cpp:109
panel_definition(const config &cfg)
Definition: panel.cpp:101
Holds a 2D point.
Definition: point.hpp:25