The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
instance.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2017 by Mark de Wever <koraq@xs4all.nl>
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 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "gui/widgets/spacer.hpp"
20 
21 namespace gui2
22 {
23 
24 namespace implementation
25 {
26 
28  : builder_widget(cfg), configuration(cfg)
29 {
30 }
31 
33 {
34  return build(replacements_map());
35 }
36 
37 widget* builder_instance::build(const replacements_map& replacements) const
38 {
39  const replacements_map::const_iterator itor = replacements.find(id);
40  if(itor != replacements.end()) {
41  return itor->second->build();
42  } else {
44  return builder.build();
45  }
46 }
47 
48 } // namespace implementation
49 
50 } // namespace gui2
51 
52 /*WIKI
53  * @page = GUIWidgetInstanceWML
54  * @order = 2_instance
55  * @begin{parent}{name="gui/window/resolution/grid/row/column/"}
56  * @begin{tag}{name="instance"}{min=0}{max=-1}{super="generic/widget_instance"}
57  * @end{tag}{name="instance"}
58  * @end{parent}{name="gui/window/resolution/grid/row/column/"}
59  */
Contains the info needed to instantiate a widget.
virtual widget * find(const std::string &id, const bool must_be_active)
Returns a widget with the wanted id.
Definition: widget.cpp:587
Base class for all widgets.
Definition: widget.hpp:48
Generic file dialog.
Definition: text.hpp:37
std::map< std::string, std::shared_ptr< builder_widget > > replacements_map
The replacements type is used to define replacement types.
config configuration
Holds a copy of the cfg parameter in the constructor.
Definition: instance.hpp:41
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
Contains the implementation details for lexical_cast and shouldn't be used directly.