00001 /* $Id: stacked_widget.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2009 - 2012 by Mark de Wever <koraq@xs4all.nl> 00004 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY. 00012 00013 See the COPYING file for more details. 00014 */ 00015 00016 #define GETTEXT_DOMAIN "wesnoth-lib" 00017 00018 #include "gui/auxiliary/window_builder/stacked_widget.hpp" 00019 00020 #include "config.hpp" 00021 #include "foreach.hpp" 00022 #include "gettext.hpp" 00023 #include "gui/auxiliary/log.hpp" 00024 #include "gui/auxiliary/widget_definition/stacked_widget.hpp" 00025 #include "gui/widgets/stacked_widget.hpp" 00026 #include "wml_exception.hpp" 00027 00028 namespace gui2 { 00029 00030 namespace implementation { 00031 00032 tbuilder_stacked_widget::tbuilder_stacked_widget(const config& cfg) 00033 : tbuilder_control(cfg) 00034 , stack() 00035 { 00036 const config &s = cfg.child("stack"); 00037 VALIDATE(s, _("No stack defined.")); 00038 foreach(const config &layer, s.child_range("layer")) { 00039 stack.push_back(new tbuilder_grid(layer)); 00040 } 00041 } 00042 00043 twidget* tbuilder_stacked_widget::build() const 00044 { 00045 tstacked_widget *widget = new tstacked_widget(); 00046 00047 init_control(widget); 00048 00049 DBG_GUI_G << "Window builder: placed stacked widget '" 00050 << id << "' with definition '" 00051 << definition << "'.\n"; 00052 00053 boost::intrusive_ptr<const tstacked_widget_definition::tresolution> conf = 00054 boost::dynamic_pointer_cast 00055 <const tstacked_widget_definition::tresolution>( 00056 widget->config()); 00057 assert(conf); 00058 00059 widget->init_grid(conf->grid); 00060 00061 widget->finalize(stack); 00062 00063 return widget; 00064 } 00065 00066 } // namespace implementation 00067 00068 } // namespace gui2 00069 00070 /*WIKI 00071 * @page = GUIToolkitWML 00072 * @order = 2_stacked_widget 00073 * 00074 * == Stacked widget == 00075 * 00076 * A stacked widget is a set of widget stacked on top of each other. The 00077 * widgets are drawn in the layers, in the order defined in the the instance 00078 * config. By default the last drawn item is also the 'active' layer for the 00079 * event handling. 00080 * @begin{parent}{name="gui/window/resolution/grid/row/column/"} 00081 * @begin{tag}{name="stacked_widget"}{min="0"}{max="-1"}{super="generic/widget_instance"} 00082 * @begin{table}{config} 00083 * @end{table} 00084 * @begin{tag}{name="stack"}{min=0}{max=-1} 00085 * @begin{tag}{name="layer"}{min=0}{max=-1}{super="gui/window/resolution/grid"} 00086 * @end{tag}{name="layer"} 00087 * @end{tag}{name="stack"} 00088 * @end{tag}{name="stacked_widget"} 00089 * @end{parent}{name="gui/window/resolution/grid/row/column/"} 00090 */ 00091
| Generated by doxygen 1.7.1 on Wed May 23 2012 01:02:42 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |