The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
spacer.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 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_SPACER_HPP_INCLUDED
16 #define GUI_WIDGETS_SPACER_HPP_INCLUDED
17 
18 #include "gui/widgets/control.hpp"
19 
23 
24 namespace gui2
25 {
26 
27 // ------------ WIDGET -----------{
28 
29 /**
30  * An empty widget.
31  *
32  * Since every grid cell needs a widget this is a blank widget. This widget can
33  * also be used to 'force' sizes.
34  *
35  * Since we're a kind of dummy class we're always active, our drawing does
36  * nothing.
37  */
38 class tspacer : public tcontrol
39 {
40 public:
41  tspacer() : tcontrol(0), best_size_(0, 0)
42  {
43  }
44 
45  /***** ***** ***** ***** layout functions ***** ***** ***** *****/
46 
47 private:
48  /** See @ref twidget::calculate_best_size. */
49  virtual tpoint calculate_best_size() const override;
50 
51 public:
52  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
53 
54  /** See @ref tcontrol::set_active. */
55  virtual void set_active(const bool active) override;
56 
57  /** See @ref tcontrol::get_active. */
58  virtual bool get_active() const override;
59 
60  /** See @ref tcontrol::get_state. */
61  virtual unsigned get_state() const override;
62 
63  /** See @ref twidget::disable_click_dismiss. */
64  bool disable_click_dismiss() const override;
65 
66  /***** ***** ***** setters / getters for members ***** ****** *****/
67 
68  void set_best_size(const tpoint& best_size)
69  {
70  best_size_ = best_size;
71  }
72 
73 private:
74  /** When we're used as a fixed size item, this holds the best size. */
76 
77  /** See @ref twidget::impl_draw_background. */
78  virtual void impl_draw_background(surface& frame_buffer,
79  int x_offset,
80  int y_offset) override;
81 
82  /** See @ref tcontrol::get_control_type. */
83  virtual const std::string& get_control_type() const override;
84 };
85 
86 // }---------- DEFINITION ---------{
87 
89 {
90  explicit tspacer_definition(const config& cfg);
91 
93  {
94  explicit tresolution(const config& cfg);
95  };
96 };
97 
98 // }---------- BUILDER -----------{
99 
100 namespace implementation
101 {
102 
104 {
105  explicit tbuilder_spacer(const config& cfg);
106 
108 
109  twidget* build() const;
110 
111 private:
114 };
115 
116 } // namespace implementation
117 
118 // }------------ END --------------
119 
120 } // namespace gui2
121 
122 #endif
virtual unsigned get_state() const override
See tcontrol::get_state.
Definition: spacer.cpp:47
bool disable_click_dismiss() const override
See twidget::disable_click_dismiss.
Definition: spacer.cpp:52
tformula< unsigned > height_
Definition: spacer.hpp:113
virtual void set_active(const bool active) override
See tcontrol::set_active.
Definition: spacer.cpp:37
tresolution(const config &cfg)
Definition: spacer.cpp:96
void set_best_size(const tpoint &best_size)
Definition: spacer.hpp:68
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
Definition: spacer.cpp:66
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
tspacer_definition(const config &cfg)
Definition: spacer.cpp:74
virtual twidget * build() const =0
An empty widget.
Definition: spacer.hpp:38
tpoint best_size_
When we're used as a fixed size item, this holds the best size.
Definition: spacer.hpp:75
Holds a 2D point.
Definition: point.hpp:24
Base class for all visible items.
Definition: control.hpp:34
virtual bool get_active() const override
See tcontrol::get_active.
Definition: spacer.cpp:42
Base class for all widgets.
Definition: widget.hpp:49
virtual void impl_draw_background(surface &frame_buffer, int x_offset, int y_offset) override
See twidget::impl_draw_background.
Definition: spacer.cpp:57
virtual tpoint calculate_best_size() const override
See twidget::calculate_best_size.
Definition: spacer.cpp:31
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Contains the implementation details for lexical_cast and shouldn't be used directly.
tbuilder_spacer(const config &cfg)
Definition: spacer.cpp:139