The Battle for Wesnoth  1.13.4+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 - 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 #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  : tbuilder_widget(cfg), configuration(cfg)
29 {
30 }
31 
33 {
34  return build(treplacements());
35 }
36 
37 twidget* tbuilder_instance::build(const treplacements& replacements) const
38 {
39  const treplacements::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.
config configuration
Holds a copy of the cfg parameter in the constructor.
Definition: instance.hpp:42
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
std::map< std::string, tfilter >::iterator itor
Definition: filter.cpp:199
Base class for all widgets.
Definition: widget.hpp:49
std::map< std::string, boost::intrusive_ptr< tbuilder_widget > > treplacements
The replacements type is used to define replacement types.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
Contains the implementation details for lexical_cast and shouldn't be used directly.