gui/auxiliary/window_builder/control.cpp

Go to the documentation of this file.
00001 /* $Id: control.cpp 54216 2012-05-19 08:46:07Z mordante $ */
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/control.hpp"
00019 
00020 #include "config.hpp"
00021 #include "formatter.hpp"
00022 #include "gettext.hpp"
00023 #include "gui/auxiliary/log.hpp"
00024 #include "gui/widgets/control.hpp"
00025 
00026 namespace gui2 {
00027 
00028 namespace implementation {
00029 
00030 tbuilder_control::tbuilder_control(const config& cfg)
00031     : tbuilder_widget(cfg)
00032     , definition(cfg["definition"])
00033     , label(cfg["label"].t_str())
00034     , tooltip(cfg["tooltip"].t_str())
00035     , help(cfg["help"].t_str())
00036     , use_tooltip_on_label_overflow(true)
00037 {
00038     if(definition.empty()) {
00039         definition = "default";
00040     }
00041 
00042     VALIDATE_WITH_DEV_MESSAGE(help.empty() || !tooltip.empty()
00043             , _("Found a widget with a helptip and without a tooltip.")
00044             , (formatter() << "id '" << id
00045                 << "' label '" << label
00046                 << "' helptip '" << help << "'.").str());
00047 
00048 
00049     DBG_GUI_P << "Window builder: found control with id '"
00050             << id << "' and definition '" << definition << "'.\n";
00051 }
00052 
00053 void tbuilder_control::init_control(tcontrol* control) const
00054 {
00055     assert(control);
00056 
00057     control->set_id(id);
00058     control->set_definition(definition);
00059     control->set_linked_group(linked_group);
00060     control->set_label(label);
00061     control->set_tooltip(tooltip);
00062     control->set_help_message(help);
00063     control->set_use_tooltip_on_label_overflow(use_tooltip_on_label_overflow);
00064 #ifndef LOW_MEM
00065     control->set_debug_border_mode(debug_border_mode);
00066     control->set_debug_border_color(debug_border_color);
00067 #endif
00068 }
00069 
00070 } // namespace implementation
00071 
00072 } // namespace gui2
00073 
00074 /*WIKI
00075  * @page = GUIWidgetInstanceWML
00076  * @order = 1_widget
00077  *
00078  * = Widget =
00079  * @begin{parent}{name="generic/"}
00080  * @begin{tag}{name="widget_instance"}{min="0"}{max="-1"}
00081  * All widgets placed in the cell have some values in common:
00082  * @begin{table}{config}
00083  *     id & string & "" &              This value is used for the engine to
00084  *                                     identify 'special' items. This means that
00085  *                                     for example a text_box can get the proper
00086  *                                     initial value. This value should be
00087  *                                     unique or empty. Those special values are
00088  *                                     documented at the window definition that
00089  *                                     uses them. NOTE items starting with an
00090  *                                     underscore are used for composed widgets
00091  *                                     and these should be unique per composed
00092  *                                     widget. $
00093  *
00094  *     definition & string & "default" &
00095  *                                     The id of the widget definition to use.
00096  *                                     This way it's possible to select a
00097  *                                     specific version of the widget e.g. a
00098  *                                     title label when the label is used as
00099  *                                     title. $
00100  *
00101  *     linked_group & string & "" &    The linked group the control belongs
00102  *                                     to. $
00103  *
00104  *     label & t_string & "" &          Most widgets have some text associated
00105  *                                     with them, this field contain the value
00106  *                                     of that text. Some widgets use this value
00107  *                                     for other purposes, this is documented
00108  *                                     at the widget. E.g. an image uses the
00109  *                                     filename in this field. $
00110  *
00111  *     tooltip & t_string & "" &        If you hover over a widget a while (the
00112  *                                     time it takes can differ per widget) a
00113  *                                     short help can show up.This defines the
00114  *                                     text of that message. This field may not
00115  *                                     be empty when 'help' is set. $
00116  *
00117  *
00118  *     help & t_string & "" &           If you hover over a widget and press F10
00119  *                                     (or the key the user defined for the help
00120  *                                     tip) a help message can show up. This
00121  *                                     help message might be the same as the
00122  *                                     tooltip but in general (if used) this
00123  *                                     message should show more help. This
00124  *                                     defines the text of that message. $
00125  *
00126  *    use_tooltip_on_label_overflow & bool & true &
00127  *                                     If the text on the label is truncated and
00128  *                                     the tooltip is empty the label can be
00129  *                                     used for the tooltip. If this variable is
00130  *                                     set to true this will happen. $
00131  *
00132  *   debug_border_mode & unsigned & 0 &
00133  *                                     The mode for showing the debug border.
00134  *                                     This border shows the area reserved for
00135  *                                     a widget. This function is only meant
00136  *                                     for debugging and might not be
00137  *                                     available in all Wesnoth binaries.
00138  *                                     Available modes:
00139  *                                     @* 0 no border.
00140  *                                     @* 1 1 pixel border.
00141  *                                     @* 2 floodfill the widget area. $
00142  *
00143  *   debug_border_color & color & "" & The color of the debug border. $
00144  *   size_text & t_string & "" &       Sets the minimum width of the widget
00145  *                                     depending on the text in it. (Note not
00146  *                                     implemented yet.) $
00147  * @end{table}
00148  * @end{tag}{name="widget_instance"}
00149  * @end{parent}{name="generic/"}
00150  */
00151 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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