The Battle for Wesnoth  1.15.1+dev
panel.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 
21 
22 namespace gui2
23 {
24 namespace implementation
25 {
26 struct builder_panel;
27 }
28 
29 // ------------ WIDGET -----------{
30 
31 /**
32  * Visible container to hold multiple widgets.
33  *
34  * This widget can draw items beyond the widgets it holds and in front of them.
35  * A panel is always active so these functions return dummy values.
36  */
37 class panel : public container_base
38 {
39 public:
40  /**
41  * Constructor.
42  */
43  panel(const implementation::builder_styled_widget& builder, const std::string& control_type = "");
44 
45  /** See @ref container_base::get_client_rect. */
46  virtual SDL_Rect get_client_rect() const override;
47 
48  /** See @ref styled_widget::get_active. */
49  virtual bool get_active() const override;
50 
51  /** See @ref styled_widget::get_state. */
52  virtual unsigned get_state() const override;
53 
54 private:
55  /** See @ref widget::impl_draw_background. */
56  virtual void impl_draw_background(surface& frame_buffer,
57  int x_offset,
58  int y_offset) override;
59 
60  /** See @ref widget::impl_draw_foreground. */
61  virtual void impl_draw_foreground(surface& frame_buffer,
62  int x_offset,
63  int y_offset) override;
64 
65 public:
66  /** Static type getter that does not rely on the widget being constructed. */
67  static const std::string& type();
68 
69 private:
70  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
71  virtual const std::string& get_control_type() const override;
72 
73  /** See @ref container_base::border_space. */
74  virtual point border_space() const override;
75 
76  /** See @ref container_base::set_self_active. */
77  virtual void set_self_active(const bool active) override;
78 };
79 
80 // }---------- DEFINITION ---------{
81 
83 {
84  explicit panel_definition(const config& cfg);
85 
87  {
88  explicit resolution(const config& cfg);
89 
90  unsigned top_border;
91  unsigned bottom_border;
92 
93  unsigned left_border;
94  unsigned right_border;
95  };
96 };
97 
98 // }---------- BUILDER -----------{
99 
100 namespace implementation
101 {
102 
104 {
105  explicit builder_panel(const config& cfg);
106 
108 
109  widget* build() const;
110 
112 };
113 
114 } // namespace implementation
115 
116 // }------------ END --------------
117 
118 } // namespace gui2
Base class of a resolution, contains the common keys for a resolution.
virtual widget * build() const =0
Visible container to hold multiple widgets.
Definition: panel.hpp:37
Base class for all widgets.
Definition: widget.hpp:47
Generic file dialog.
Definition: field-fwd.hpp:22
window * build(const builder_window::window_resolution *definition)
Builds a window.
Holds a 2D point.
Definition: point.hpp:23
A generic container base class.
point resolution()
Definition: general.cpp:373
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
std::shared_ptr< builder_grid > builder_grid_ptr
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.