The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
widget_definition.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 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_AUXILIARY_WIDGET_DEFINITION_HPP_INCLUDED
16 #define GUI_AUXILIARY_WIDGET_DEFINITION_HPP_INCLUDED
17 
18 #include "config.hpp"
19 #include "font_options.hpp"
20 #include "gui/core/canvas.hpp"
21 
22 namespace gui2
23 {
24 
25 /**
26  * Contains the state info for a resolution.
27  *
28  * At the moment all states are the same so there is no need to use
29  * inheritance. If that is needed at some point the containers should contain
30  * pointers and we should inherit from reference_counted_object.
31  */
33 {
34  explicit tstate_definition(const config& cfg);
35 
37 };
38 
39 
40 /** Base class of a resolution, contains the common keys for a resolution. */
42 {
43  explicit tresolution_definition_(const config& cfg);
44 
45  unsigned window_width;
46  unsigned window_height;
47 
48  unsigned min_width;
49  unsigned min_height;
50 
51  unsigned default_width;
52  unsigned default_height;
53 
54  unsigned max_width;
55  unsigned max_height;
56 
57  unsigned text_extra_width;
59  unsigned text_font_size;
62 
63  std::vector<tstate_definition> state;
64 };
65 
68 
71 
72 /**
73  * Casts a tresolution_definition_const_ptr to another type.
74  *
75  * @tparam T The type to cast to, the non const version.
76  *
77  * @param ptr The pointer to cast.
78  *
79  * @returns A reference to type casted to.
80  */
81 template <class T>
83 {
85  = boost::dynamic_pointer_cast<const T>(ptr);
86  assert(conf);
87  return *conf;
88 }
89 
91 {
92  explicit tcontrol_definition(const config& cfg);
93 
94  template <class T>
95  void load_resolutions(const config& cfg)
96  {
97  for (const auto & resolution : cfg.child_range("resolution"))
98  {
99  resolutions.push_back(new T(resolution));
100  }
101  }
102 
105 
106  std::vector<tresolution_definition_ptr> resolutions;
107 };
108 
110 
111 } // namespace gui2
112 
113 #endif
child_itors child_range(const std::string &key)
Definition: config.cpp:613
family_class
Font classes for get_font_families().
void load_resolutions(const config &cfg)
tstate_definition(const config &cfg)
Definition: settings.cpp:549
Definitions for the interface to Wesnoth Markup Language (WML).
const T & cast(tresolution_definition_const_ptr ptr)
Casts a tresolution_definition_const_ptr to another type.
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
boost::intrusive_ptr< const tresolution_definition_ > tresolution_definition_const_ptr
This file contains the canvas object which is the part where the widgets draw (temporally) images on...
std::pair< int, int > resolution()
A simple canvas which can be drawn upon.
Definition: canvas.hpp:44
Contains the state info for a resolution.
tresolution_definition_(const config &cfg)
boost::intrusive_ptr< tcontrol_definition > tcontrol_definition_ptr
boost::intrusive_ptr< tresolution_definition_ > tresolution_definition_ptr
std::vector< tstate_definition > state
std::vector< tresolution_definition_ptr > resolutions
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
tcontrol_definition(const config &cfg)