The Battle for Wesnoth  1.15.12+dev
instance.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 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 #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
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:583
Base class for all widgets.
Definition: widget.hpp:49
virtual widget * build() const override
Definition: spacer.cpp:133
Generic file dialog.
Definition: field-fwd.hpp:22
virtual widget * build() const override
Definition: instance.cpp:32
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:59
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.