The Battle for Wesnoth  1.15.2+dev
widget_definition.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://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 #pragma once
16 
17 #include "config.hpp"
18 #include "font/font_options.hpp"
19 #include "font/text.hpp"
21 
22 #include <vector>
23 
24 namespace gui2
25 {
26 
27 /**
28  * Contains the state info for a resolution.
29  *
30  * At the moment all states are the same so there is no need to use
31  * inheritance. If that is needed at some point the containers should contain
32  * pointers
33  */
35 {
36  explicit state_definition(const config& cfg);
37 
39 };
40 
41 /** Base class of a resolution, contains the common keys for a resolution. */
43 {
44  explicit resolution_definition(const config& cfg);
45 
46  unsigned window_width;
47  unsigned window_height;
48 
49  unsigned min_width;
50  unsigned min_height;
51 
52  unsigned default_width;
53  unsigned default_height;
54 
55  unsigned max_width;
56  unsigned max_height;
57 
58  std::vector<linked_group_definition> linked_groups;
59 
60  unsigned text_extra_width;
62  unsigned text_font_size;
63 
66 
67  std::vector<state_definition> state;
68 };
69 
70 typedef std::shared_ptr<resolution_definition>
72 
73 typedef std::shared_ptr<const resolution_definition>
75 
77 {
78  explicit styled_widget_definition(const config& cfg);
79 
80  template<class T>
81  void load_resolutions(const config& cfg)
82  {
83  for(const config& resolution : cfg.child_range("resolution")) {
84  resolutions.emplace_back(std::make_shared<T>(resolution));
85  }
86  }
87 
88  std::string id;
90 
91  std::vector<resolution_definition_ptr> resolutions;
92 };
93 
94 typedef std::shared_ptr<styled_widget_definition> styled_widget_definition_ptr;
95 
96 } // namespace gui2
Base class of a resolution, contains the common keys for a resolution.
std::vector< state_definition > state
family_class
Font classes for get_font_families().
state_definition(const config &cfg)
child_itors child_range(config_key_type key)
Definition: config.cpp:362
std::shared_ptr< const resolution_definition > resolution_definition_const_ptr
Definitions for the interface to Wesnoth Markup Language (WML).
font::pango_text::FONT_STYLE text_font_style
std::shared_ptr< styled_widget_definition > styled_widget_definition_ptr
Generic file dialog.
Definition: field-fwd.hpp:22
std::vector< resolution_definition_ptr > resolutions
std::shared_ptr< resolution_definition > resolution_definition_ptr
Contains the state info for a resolution.
font::family_class text_font_family
std::vector< linked_group_definition > linked_groups
void load_resolutions(const config &cfg)
point resolution()
Definition: general.cpp:373
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68