gui/auxiliary/window_builder/toggle_panel.cpp

Go to the documentation of this file.
00001 /* $Id: toggle_panel.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 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/toggle_panel.hpp"
00019 
00020 #include "config.hpp"
00021 #include "gettext.hpp"
00022 #include "gui/auxiliary/log.hpp"
00023 #include "gui/auxiliary/window_builder/helper.hpp"
00024 #include "gui/widgets/toggle_panel.hpp"
00025 #include "wml_exception.hpp"
00026 
00027 namespace gui2 {
00028 
00029 namespace implementation {
00030 
00031 tbuilder_toggle_panel::tbuilder_toggle_panel(const config& cfg)
00032     : tbuilder_control(cfg)
00033     , grid(NULL)
00034     , retval_id_(cfg["return_value_id"])
00035     , retval_(cfg["return_value"])
00036 {
00037     const config &c = cfg.child("grid");
00038 
00039     VALIDATE(c, _("No grid defined."));
00040 
00041     grid = new tbuilder_grid(c);
00042 }
00043 
00044 twidget* tbuilder_toggle_panel::build() const
00045 {
00046     ttoggle_panel* widget = new ttoggle_panel();
00047 
00048     init_control(widget);
00049 
00050     widget->set_retval(get_retval(retval_id_, retval_, id));
00051 
00052     DBG_GUI_G << "Window builder: placed toggle panel '"
00053             << id << "' with definition '"
00054             << definition << "'.\n";
00055 
00056     widget->init_grid(grid);
00057     return widget;
00058 }
00059 
00060 } // namespace implementation
00061 
00062 } // namespace gui2
00063 
00064 /*WIKI
00065  * @page = GUIWidgetInstanceWML
00066  * @order = 2_toggle_panel
00067  * @begin{parent}{name="gui/window/resolution/grid/row/column/"}
00068  * @begin{tag}{name="toggle_panel"}{min=0}{max=-1}{super="generic/widget_instance"}
00069  * == Toggle panel ==
00070  *
00071  * A toggle panel is an item which can hold other items. The difference between
00072  * a grid and a panel is that it's possible to define how a panel looks. A grid
00073  * in an invisible container to just hold the items. The toggle panel is a
00074  * combination of the panel and a toggle button, it allows a toggle button with
00075  * its own grid.
00076  *
00077  * @begin{table}{config}
00078  *     grid & grid & &                 Defines the grid with the widgets to
00079  *                                     place on the panel. $
00080  *     return_value_id & string & "" & The return value id, see
00081  *                                     [[GUIToolkitWML#Button]] for more
00082  *                                     information. $
00083  *     return_value & int & 0 &        The return value, see
00084  *                                     [[GUIToolkitWML#Button]] for more
00085  *                                     information. $
00086  * @end{table}
00087  * @allow{link}{name="gui/window/resolution/grid"}
00088  * @end{tag}{name="toggle_panel"}
00089  * @end{parent}{name="gui/window/resolution/grid/row/column/"}
00090  */
00091 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Wed May 23 2012 01:02:42 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs