00001 /* $Id: widget_definition.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2007 - 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/widget_definition.hpp" 00019 00020 #include "gettext.hpp" 00021 #include "gui/auxiliary/log.hpp" 00022 #include "gui/widgets/helper.hpp" 00023 #include "wml_exception.hpp" 00024 00025 namespace gui2 { 00026 00027 tresolution_definition_::tresolution_definition_(const config& cfg) 00028 : window_width(cfg["window_width"]) 00029 , window_height(cfg["window_height"]) 00030 , min_width(cfg["min_width"]) 00031 , min_height(cfg["min_height"]) 00032 , default_width(cfg["default_width"]) 00033 , default_height(cfg["default_height"]) 00034 , max_width(cfg["max_width"]) 00035 , max_height(cfg["max_height"]) 00036 , text_extra_width(cfg["text_extra_width"]) 00037 , text_extra_height(cfg["text_extra_height"]) 00038 , text_font_size(cfg["text_font_size"]) 00039 , text_font_style(decode_font_style(cfg["text_font_style"])) 00040 , state() 00041 { 00042 /*WIKI 00043 * @page = GUIToolkitWML 00044 * @order = 1_widget 00045 * @begin{parent}{name=generic/widget_definition/} 00046 * == Resolution == 00047 * @begin{tag}{name="resolution"}{min="0"}{max="-1"} 00048 * 00049 * Depending on the resolution a widget can look different. Resolutions are 00050 * evaluated in order of appearance. The ''window_width'' and ''window_height'' 00051 * are the upper limit this resolution is valid for. When one of the sizes 00052 * gets above the limit, the next resolution is selected. There's one special 00053 * case where both values are ''0''. This resolution always matches. (Resolution 00054 * definitions behind that one will never be picked.) This resolution can be 00055 * used as upper limit or if there's only one resolution. 00056 * 00057 * The default (and also minimum) size of a button is determined by two items, 00058 * the wanted default size and the size needed for the text. The size of the 00059 * text differs per used widget so needs to be determined per button. 00060 * 00061 * Container widgets like panels and windows have other rules for their sizes. 00062 * Their sizes are based on the size of their children (and the border they need 00063 * themselves). It's wise to set all sizes to 0 for these kind of widgets. 00064 * 00065 * @begin{table}{config} 00066 * window_width & unsigned & 0 & Width of the application window. $ 00067 * window_height & unsigned & 0 & Height of the application window. $ 00068 * 00069 * 00070 * min_width & unsigned & 0 & The minimum width of the widget. $ 00071 * min_height & unsigned & 0 & The minimum height of the widget. $ 00072 * 00073 * 00074 * default_width & unsigned & 0 & The default width of the widget. $ 00075 * default_height & unsigned & 0 & The default height of the widget. $ 00076 * 00077 * 00078 * max_width & unsigned & 0 & The maximum width of the widget. $ 00079 * max_height & unsigned & 0 & The maximum height of the widget. $ 00080 * 00081 * text_extra_width & unsigned & 0 & 00082 * The extra width needed to determine the minimal size for the text. $ 00083 * 00084 * text_extra_height & unsigned & 0 & 00085 * The extra height needed to determine the minimal size for the text. $ 00086 * 00087 * text_font_size & unsigned & 0 & 00088 * The font size, which needs to be used to determine the minimal size for 00089 * the text. $ 00090 * 00091 * text_font_style & font_style & "" & 00092 * The font style, which needs to be used to determine the minimal size for 00093 * the text. $ 00094 * 00095 * 00096 * state & section & & 00097 * Every widget has one or more state sections. Note they aren't called 00098 * state but state_xxx the exact names are listed per widget. $ 00099 * @end{table} 00100 * @end{tag}{name="resolution"} 00101 * @end{parent}{name=generic/widget_definition/} 00102 */ 00103 00104 DBG_GUI_P << "Parsing resolution " 00105 << window_width << ", " << window_height << '\n'; 00106 } 00107 00108 tcontrol_definition::tcontrol_definition(const config& cfg) 00109 : id(cfg["id"]) 00110 , description(cfg["description"].t_str()) 00111 , resolutions() 00112 { 00113 /*WIKI 00114 * @page = GUIWidgetDefinitionWML 00115 * @order = 1 00116 * 00117 * {{Autogenerated}} 00118 * 00119 * = Widget definition = 00120 * 00121 * This page describes the definition of all widgets in the toolkit. Every 00122 * widget has some parts in common, first of all; every definition has the 00123 * following fields. 00124 * @begin{parent}{name="generic/"} 00125 * @begin{tag}{name=widget_definition}{min=0}{max=1} 00126 * @begin{table}{config} 00127 * id & string & & Unique id for this gui (theme). $ 00128 * description & t_string & & Unique translatable name for this gui. $ 00129 * 00130 * resolution & section & & The definitions of the widget in various 00131 * resolutions. $ 00132 * @end{table} 00133 * @end{tag}{name=widget_definition} 00134 * @end{parent}{name="generic/"} 00135 */ 00136 00137 VALIDATE(!id.empty(), missing_mandatory_wml_key("control", "id")); 00138 VALIDATE(!description.empty() 00139 , missing_mandatory_wml_key("control", "description")); 00140 00141 /* 00142 * Do this validation here instead of in load_resolutions so the 00143 * translatable string is not in the header and we don't need to pull in 00144 * extra header dependencies. 00145 */ 00146 config::const_child_itors itors = cfg.child_range("resolution"); 00147 VALIDATE(itors.first != itors.second, _("No resolution defined.")); 00148 } 00149 00150 } // namespace gui2 00151
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:54 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |