Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #define GETTEXT_DOMAIN "wesnoth-lib"
00017
00018 #include "gui/auxiliary/window_builder/tree_view.hpp"
00019
00020 #include "foreach.hpp"
00021 #include "gettext.hpp"
00022 #include "gui/auxiliary/log.hpp"
00023 #include "gui/auxiliary/widget_definition/tree_view.hpp"
00024 #include "gui/auxiliary/window_builder/helper.hpp"
00025 #include "gui/widgets/tree_view.hpp"
00026 #include "wml_exception.hpp"
00027
00028 namespace gui2 {
00029
00030 namespace implementation {
00031
00032 tbuilder_tree_view::tbuilder_tree_view(const config& cfg)
00033 : tbuilder_control(cfg)
00034 , vertical_scrollbar_mode(
00035 get_scrollbar_mode(cfg["vertical_scrollbar_mode"]))
00036 , horizontal_scrollbar_mode(
00037 get_scrollbar_mode(cfg["horizontal_scrollbar_mode"]))
00038 , indention_step_size(cfg["indention_step_size"])
00039 , nodes()
00040 {
00041
00042 foreach(const config &node, cfg.child_range("node")) {
00043 nodes.push_back(tnode(node));
00044 }
00045
00046 VALIDATE(!nodes.empty(), _("No nodes defined for a tree view."));
00047 }
00048
00049 twidget* tbuilder_tree_view::build() const
00050 {
00051
00052
00053
00054
00055 ttree_view *widget = new ttree_view(nodes);
00056
00057 init_control(widget);
00058
00059 widget->set_vertical_scrollbar_mode(vertical_scrollbar_mode);
00060 widget->set_horizontal_scrollbar_mode(horizontal_scrollbar_mode);
00061
00062 widget->set_indention_step_size(indention_step_size);
00063
00064 DBG_GUI_G << "Window builder: placed tree_view '"
00065 << id << "' with definition '"
00066 << definition << "'.\n";
00067
00068 boost::intrusive_ptr<const ttree_view_definition::tresolution> conf =
00069 boost::dynamic_pointer_cast
00070 <const ttree_view_definition::tresolution>(widget->config());
00071 assert(conf);
00072
00073 widget->init_grid(conf->grid);
00074 widget->finalize_setup();
00075
00076 return widget;
00077 }
00078
00079 tbuilder_tree_view::tnode::tnode(const config& cfg)
00080 : id(cfg["id"])
00081 , builder(NULL)
00082 {
00083 VALIDATE(!id.empty(), missing_mandatory_wml_key("node", "id"));
00084
00085 VALIDATE(id != "root"
00086 , _("[node]id 'root' is reserved for the implementation."));
00087
00088 const config& node_definition = cfg.child("node_definition");
00089
00090 VALIDATE(node_definition, _("No node defined."));
00091
00092 builder = new tbuilder_grid(node_definition);
00093 }
00094
00095 }
00096
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151