gui/auxiliary/window_builder/drawing.cpp

Go to the documentation of this file.
00001 /* $Id: drawing.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2010 - 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/drawing.hpp"
00019 
00020 #include "config.hpp"
00021 #include "gui/auxiliary/log.hpp"
00022 #include "gui/widgets/drawing.hpp"
00023 
00024 namespace gui2 {
00025 
00026 namespace implementation {
00027 
00028 tbuilder_drawing::tbuilder_drawing(const config& cfg)
00029     : tbuilder_control(cfg)
00030     , width(cfg["width"])
00031     , height(cfg["height"])
00032     , draw(cfg.child("draw"))
00033 {
00034     assert(!draw.empty());
00035 }
00036 
00037 twidget* tbuilder_drawing::build() const
00038 {
00039     tdrawing* widget = new tdrawing();
00040 
00041     init_control(widget);
00042 
00043     const game_logic::map_formula_callable& size =
00044             get_screen_size_variables();
00045 
00046     const unsigned w = width(size);
00047     const unsigned h = height(size);
00048 
00049     if(w || h) {
00050         widget->set_best_size(tpoint(w, h));
00051     }
00052 
00053     widget->canvas().front().set_cfg(draw);
00054 
00055     DBG_GUI_G << "Window builder: placed drawing '"
00056             << id << "' with definition '"
00057             << definition << "'.\n";
00058 
00059     return widget;
00060 }
00061 
00062 } // namespace implementation
00063 
00064 } // namespace gui2
00065 
00066 /*WIKI_MACRO
00067  * @begin{macro}{drawing_description}
00068  *
00069  *        A drawing is widget with a fixed size and gives access to the
00070  *        canvas of the widget in the window instance. This allows special
00071  *        display only widgets.
00072  * @end{macro}
00073  */
00074 
00075 
00076 /*WIKI
00077  * @page = GUIWidgetInstanceWML
00078  * @order = 2_drawing
00079  *
00080  * == Spacer ==
00081  * @begin{parent}{name="gui/window/resolution/grid/row/column/"}
00082  * @begin{tag}{name="drawing"}{min=0}{max=-1}{super="generic/widget_instance"}
00083  * @macro = drawing_description
00084  *
00085  * If either the width or the height is not zero the drawing functions as a
00086  * fixed size drawing.
00087  *
00088  * @begin{table}{config}
00089  *     width & f_unsigned & 0 &          The width of the drawing. $
00090  *     height & f_unsigned & 0 &         The height of the drawing. $
00091  *     draw & config & &                 The config containing the drawing. $
00092  * @end{table}
00093  * @allow{link}{name="generic/state/draw"}
00094  * @end{tag}{name="drawing"}
00095  * @end{parent}{name="gui/window/resolution/grid/row/column/"}
00096  * The variable available are the same as for the window resolution see
00097  * http://www.wesnoth.org/wiki/GUIToolkitWML#Resolution_2 for the list of
00098  * items.
00099  */
00100 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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