The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
stacked_widget.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 #ifndef GUI_WIDGETS_STACKED_WIDGET_HPP_INCLUDED
16 #define GUI_WIDGETS_STACKED_WIDGET_HPP_INCLUDED
17 
19 
22 
23 namespace gui2
24 {
25 
26 // ------------ WIDGET -----------{
27 
28 namespace implementation
29 {
30 struct tbuilder_stacked_widget;
31 }
32 
33 class tgenerator_;
34 
36 {
38  friend class tdebug_layout_graph;
39 
40 public:
42 
43  /***** ***** ***** inherited ***** ****** *****/
44 
45  /** See @ref tcontrol::get_active. */
46  virtual bool get_active() const override;
47 
48  /** See @ref tcontrol::get_state. */
49  virtual unsigned get_state() const override;
50 
51  /** See @ref twidget::layout_children. */
52  virtual void layout_children() override;
53 
54  /**
55  * Gets the current visible layer number.
56  *
57  * The current layer number will be -1 if all layers are currently visible.
58  * In this case, only the topmost (highest-numbered) layer will receive
59  * events.
60  */
61  int current_layer() const { return selected_layer_; }
62 
63  /**
64  * Selects and displays a particular layer.
65  *
66  * If layer -1 is selected, all layers will be displayed but only the
67  * topmost (highest-numbered) layer will receive events.
68  */
69  void select_layer(const int layer);
70 
71  /**
72  * Gets the total number of layers.
73  */
74  unsigned int get_layer_count() const;
75 
76  tgrid* get_layer_grid(unsigned int i);
77 
78 private:
79  /**
80  * Finishes the building initialization of the widget.
81  *
82  * @param widget_builder The builder to build the contents of the
83  * widget.
84  */
85  void finalize(std::vector<tbuilder_grid_const_ptr> widget_builder);
86 
87  /**
88  * Contains a pointer to the generator.
89  *
90  * The pointer is not owned by this class, it's stored in the content_grid_
91  * of the tscrollbar_container super class and freed when it's grid is
92  * freed.
93  */
95 
96  /**
97  * The number of the current selected layer.
98  */
100 
101  /**
102  * Helper to ensure the correct state is set when selecting a layer.
103  */
104  void select_layer_internal(const unsigned int layer, const bool select) const;
105 
106  /** See @ref tcontrol::get_control_type. */
107  virtual const std::string& get_control_type() const override;
108 
109  /** See @ref tcontainer_::set_self_active. */
110  virtual void set_self_active(const bool active) override;
111 };
112 
113 // }---------- DEFINITION ---------{
114 
116 {
117  explicit tstacked_widget_definition(const config& cfg);
118 
120  {
121  explicit tresolution(const config& cfg);
122 
124  };
125 };
126 
127 // }---------- BUILDER -----------{
128 
129 namespace implementation
130 {
131 
133 {
134  explicit tbuilder_stacked_widget(const config& cfg);
135 
137 
138  twidget* build() const;
139 
140  /** The builders for all layers of the stack .*/
141  std::vector<tbuilder_grid_const_ptr> stack;
142 };
143 
144 } // namespace implementation
145 
146 // }------------ END --------------
147 
148 } // namespace gui2
149 
150 #endif
Abstract base class for the generator.
Definition: generator.hpp:41
void finalize(std::vector< tbuilder_grid_const_ptr > widget_builder)
Finishes the building initialization of the widget.
unsigned int get_layer_count() const
Gets the total number of layers.
Base container class.
Definition: grid.hpp:29
tgrid * get_layer_grid(unsigned int i)
void select_layer(const int layer)
Selects and displays a particular layer.
std::vector< tbuilder_grid_const_ptr > stack
The builders for all layers of the stack .
Base class of a resolution, contains the common keys for a resolution.
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
virtual twidget * build() const =0
GLenum GLenum GLuint GLint GLint layer
Definition: glew.h:3455
tstacked_widget_definition(const config &cfg)
int selected_layer_
The number of the current selected layer.
virtual bool get_active() const override
See tcontrol::get_active.
friend class tdebug_layout_graph
virtual void set_self_active(const bool active) override
See tcontainer_::set_self_active.
virtual void layout_children() override
See twidget::layout_children.
void select_layer_internal(const unsigned int layer, const bool select) const
Helper to ensure the correct state is set when selecting a layer.
size_t i
Definition: function.cpp:1057
tgenerator_ * generator_
Contains a pointer to the generator.
virtual unsigned get_state() const override
See tcontrol::get_state.
A generic container base class.
Definition: container.hpp:32
Base class for all widgets.
Definition: widget.hpp:49
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Contains the implementation details for lexical_cast and shouldn't be used directly.
int current_layer() const
Gets the current visible layer number.