-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
stacked_widget.hpp
110 lines (85 loc) · 2.79 KB
/
stacked_widget.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
Copyright (C) 2009 - 2016 by Mark de Wever <koraq@xs4all.nl>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef GUI_WIDGETS_STACKED_WIDGET_HPP_INCLUDED
#define GUI_WIDGETS_STACKED_WIDGET_HPP_INCLUDED
#include "gui/widgets/container.hpp"
namespace gui2
{
namespace implementation
{
struct tbuilder_stacked_widget;
}
class tgenerator_;
class tstacked_widget : public tcontainer_
{
friend struct implementation::tbuilder_stacked_widget;
friend class tdebug_layout_graph;
public:
tstacked_widget();
/***** ***** ***** inherited ***** ****** *****/
/** See @ref tcontrol::get_active. */
virtual bool get_active() const OVERRIDE;
/** See @ref tcontrol::get_state. */
virtual unsigned get_state() const OVERRIDE;
/** See @ref twidget::layout_children. */
virtual void layout_children() OVERRIDE;
/**
* Gets the current visible layer number.
*
* The current layer number will be -1 if all layers are currently visible.
* In this case, only the topmost (highest-numbered) layer will receive
* events.
*/
int current_layer() const { return selected_layer_; }
/**
* Selects and displays a particular layer.
*
* If layer -1 is selected, all layers will be displayed but only the
* topmost (highest-numbered) layer will receive events.
*/
void select_layer(const int layer);
/**
* Gets the total number of layers.
*/
unsigned int get_layer_count() const;
tgrid* get_layer_grid(unsigned int i);
private:
/**
* Finishes the building initialization of the widget.
*
* @param widget_builder The builder to build the contents of the
* widget.
*/
void finalize(std::vector<tbuilder_grid_const_ptr> widget_builder);
/**
* Contains a pointer to the generator.
*
* The pointer is not owned by this class, it's stored in the content_grid_
* of the tscrollbar_container super class and freed when it's grid is
* freed.
*/
tgenerator_* generator_;
/**
* The number of the current selected layer.
*/
int selected_layer_;
/**
* Helper to ensure the correct state is set when selecting a layer.
*/
void select_layer_internal(const unsigned int layer, const bool select) const;
/** See @ref tcontrol::get_control_type. */
virtual const std::string& get_control_type() const OVERRIDE;
/** See @ref tcontainer_::set_self_active. */
virtual void set_self_active(const bool active) OVERRIDE;
};
} // namespace gui2
#endif