The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
drawing.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 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_DRAWING_HPP_INCLUDED
16 #define GUI_WIDGETS_DRAWING_HPP_INCLUDED
17 
18 #include "gui/widgets/control.hpp"
19 
22 
23 namespace gui2
24 {
25 
26 // ------------ WIDGET -----------{
27 
28 /**
29  * A widget to draw upon.
30  *
31  * This widget has a fixed size like the spacer, but allows the user to
32  * manual draw items. The widget is display only.
33  */
34 class tdrawing : public tcontrol
35 {
36 public:
38  {
39  }
40 
41  /***** ***** ***** ***** layout functions ***** ***** ***** *****/
42 
43 private:
44  /** See @ref twidget::calculate_best_size. */
45  virtual tpoint calculate_best_size() const override;
46 
47 public:
48  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
49 
50  /** See @ref tcontrol::set_active. */
51  virtual void set_active(const bool active) override;
52 
53  /** See @ref tcontrol::get_active. */
54  virtual bool get_active() const override;
55 
56  /** See @ref tcontrol::get_state. */
57  virtual unsigned get_state() const override;
58 
59  /** See @ref twidget::disable_click_dismiss. */
60  bool disable_click_dismiss() const override;
61 
62  /***** ***** ***** setters / getters for members ***** ****** *****/
63 
64  void set_best_size(const tpoint& best_size)
65  {
66  best_size_ = best_size;
67  }
68 
69 private:
70  /**
71  * Possible states of the widget.
72  *
73  * Note the order of the states must be the same as defined in
74  * settings.hpp.
75  */
76  enum tstate {
79  };
80 
81  /** When we're used as a fixed size item, this holds the best size. */
83 
84  /** See @ref tcontrol::get_control_type. */
85  virtual const std::string& get_control_type() const override;
86 };
87 
88 // }---------- DEFINITION ---------{
89 
91 {
92  explicit tdrawing_definition(const config& cfg);
93 
95  {
96  explicit tresolution(const config& cfg);
97  };
98 };
99 
100 // }---------- BUILDER -----------{
101 
102 namespace implementation
103 {
104 
106 {
107  explicit tbuilder_drawing(const config& cfg);
108 
110 
111  twidget* build() const;
112 
113  /** The width of the widget. */
115 
116  /** The height of the widget. */
118 
119  /** Config containing what to draw on the widgets canvas. */
121 };
122 
123 } // namespace implementation
124 
125 // }------------ END --------------
126 
127 } // namespace gui2
128 
129 #endif
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
Definition: drawing.cpp:60
tpoint best_size_
When we're used as a fixed size item, this holds the best size.
Definition: drawing.hpp:82
virtual bool get_active() const override
See tcontrol::get_active.
Definition: drawing.cpp:45
A widget to draw upon.
Definition: drawing.hpp:34
void set_best_size(const tpoint &best_size)
Definition: drawing.hpp:64
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
config draw
Config containing what to draw on the widgets canvas.
Definition: drawing.hpp:120
virtual void set_active(const bool active) override
See tcontrol::set_active.
Definition: drawing.cpp:40
tstate
Possible states of the widget.
Definition: drawing.hpp:76
virtual unsigned get_state() const override
See tcontrol::get_state.
Definition: drawing.cpp:50
tformula< unsigned > height
The height of the widget.
Definition: drawing.hpp:117
virtual tpoint calculate_best_size() const override
See twidget::calculate_best_size.
Definition: drawing.cpp:34
Holds a 2D point.
Definition: point.hpp:24
Base class for all visible items.
Definition: control.hpp:34
tformula< unsigned > width
The width of the widget.
Definition: drawing.hpp:114
Base class for all widgets.
Definition: widget.hpp:49
tdrawing_definition(const config &cfg)
Definition: drawing.cpp:68
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
bool disable_click_dismiss() const override
See twidget::disable_click_dismiss.
Definition: drawing.cpp:55
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Contains the implementation details for lexical_cast and shouldn't be used directly.