gui/auxiliary/window_builder/spacer.cpp

Go to the documentation of this file.
00001 /* $Id: spacer.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/spacer.hpp"
00019 
00020 #include "config.hpp"
00021 #include "gui/auxiliary/log.hpp"
00022 #include "gui/widgets/spacer.hpp"
00023 
00024 namespace gui2 {
00025 
00026 namespace implementation {
00027 
00028 tbuilder_spacer::tbuilder_spacer(const config& cfg)
00029     : tbuilder_control(cfg)
00030     , width_(cfg["width"])
00031     , height_(cfg["height"])
00032 {
00033 }
00034 
00035 twidget* tbuilder_spacer::build() const
00036 {
00037     tspacer* widget = new tspacer();
00038 
00039     init_control(widget);
00040 
00041     const game_logic::map_formula_callable& size = get_screen_size_variables();
00042 
00043     const unsigned width = width_(size);
00044     const unsigned height = height_(size);
00045 
00046     if(width || height) {
00047         widget->set_best_size(tpoint(width, height));
00048     }
00049 
00050     DBG_GUI_G << "Window builder: placed spacer '"
00051             << id << "' with definition '"
00052             << definition << "'.\n";
00053 
00054     return widget;
00055 }
00056 
00057 } // namespace implementation
00058 
00059 } // namespace gui2
00060 
00061 /*WIKI_MACRO
00062  * @begin{macro}{spacer_description}
00063  *
00064  *        A spacer is a dummy item to either fill in a widget since no empty
00065  *        items are allowed or to reserve a fixed space.
00066  * @end{macro}
00067  */
00068 
00069 
00070 /*WIKI
00071  * @page = GUIWidgetInstanceWML
00072  * @order = 2_spacer
00073  * @begin{parent}{name="gui/window/resolution/grid/row/column/"}
00074  * @begin{tag}{name="spacer"}{min=0}{max=-1}{super="generic/widget_instance"}
00075  * == Spacer ==
00076  *
00077  * @macro = spacer_description
00078  *
00079  * If either the width or the height is non-zero the spacer functions as a
00080  * fixed size spacer.
00081  *
00082  * @begin{table}{config}
00083  *     width & f_unsigned & 0 &          The width of the spacer. $
00084  *     height & f_unsigned & 0 &         The height of the spacer. $
00085  * @end{table}
00086  *
00087  * The variable available are the same as for the window resolution see
00088  * http://www.wesnoth.org/wiki/GUIToolkitWML#Resolution_2 for the list of
00089  * items.
00090  * @end{tag}{name="spacer"}
00091  * @end{parent}{name="gui/window/resolution/grid/row/column/"}
00092  */
00093 
 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