The Battle for Wesnoth  1.19.7+dev
widget_definition.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "config.hpp"
19 #include "font/font_options.hpp"
20 #include "font/text.hpp"
23 
24 #include <vector>
25 
26 namespace gui2
27 {
28 
29 /**
30  * Contains the state info for a resolution.
31  *
32  * At the moment all states are the same so there is no need to use
33  * inheritance. If that is needed at some point the containers should contain
34  * pointers
35  */
37 {
38  explicit state_definition(const config& cfg);
39 
41 };
42 
44 {
45  explicit resolution_definition(const config& cfg);
46 
47  unsigned window_width;
48  unsigned window_height;
49 
50  unsigned min_width;
51  unsigned min_height;
52 
53  unsigned default_width;
54  unsigned default_height;
55 
56  unsigned max_width;
57  unsigned max_height;
58 
59  std::vector<linked_group_definition> linked_groups;
60 
61  unsigned text_extra_width;
64 
67 
68  std::vector<state_definition> state;
69 };
70 
71 typedef std::shared_ptr<resolution_definition>
73 
74 typedef std::shared_ptr<const resolution_definition>
76 
78 {
79  explicit styled_widget_definition(const config& cfg);
80 
81  template<class T>
82  void load_resolutions(const config& cfg)
83  {
84  for(const config& resolution : cfg.child_range("resolution")) {
85  resolutions.emplace_back(std::make_shared<T>(resolution));
86  }
87  }
88 
89  std::string id;
91 
92  std::vector<resolution_definition_ptr> resolutions;
93 };
94 
95 typedef std::shared_ptr<styled_widget_definition> styled_widget_definition_ptr;
96 
97 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:158
child_itors child_range(config_key_type key)
Definition: config.cpp:272
Definitions for the interface to Wesnoth Markup Language (WML).
family_class
Font classes for get_font_families().
Generic file dialog.
std::shared_ptr< styled_widget_definition > styled_widget_definition_ptr
std::shared_ptr< resolution_definition > resolution_definition_ptr
std::shared_ptr< const resolution_definition > resolution_definition_const_ptr
std::vector< state_definition > state
typed_formula< unsigned > text_font_size
std::vector< linked_group_definition > linked_groups
font::pango_text::FONT_STYLE text_font_style
resolution_definition(const config &cfg)
font::family_class text_font_family
Contains the state info for a resolution.
state_definition(const config &cfg)
void load_resolutions(const config &cfg)
styled_widget_definition(const config &cfg)
std::vector< resolution_definition_ptr > resolutions