gui/auxiliary/window_builder/label.cpp

Go to the documentation of this file.
00001 /* $Id: label.cpp 54038 2012-04-30 19:37:24Z 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/label.hpp"
00019 
00020 #include "config.hpp"
00021 #include "gui/auxiliary/log.hpp"
00022 #include "gui/widgets/label.hpp"
00023 
00024 namespace gui2 {
00025 
00026 namespace implementation {
00027 
00028 tbuilder_label::tbuilder_label(const config& cfg)
00029     : tbuilder_control(cfg)
00030     , wrap(cfg["wrap"].to_bool())
00031     , characters_per_line(cfg["characters_per_line"])
00032     , text_alignment(decode_text_alignment(cfg["text_alignment"]))
00033 {
00034 }
00035 
00036 twidget* tbuilder_label::build() const
00037 {
00038     tlabel* label = new tlabel();
00039 
00040     init_control(label);
00041 
00042     label->set_can_wrap(wrap);
00043     label->set_characters_per_line(characters_per_line);
00044     label->set_text_alignment(text_alignment);
00045 
00046     DBG_GUI_G << "Window builder: placed label '"
00047             << id << "' with definition '"
00048             << definition << "'.\n";
00049 
00050     return label;
00051 }
00052 
00053 } // namespace implementation
00054 
00055 } // namespace gui2
00056 
00057 /*WIKI_MACRO
00058  * @begin{macro}{label_description}
00059  *
00060  *        A label displays a text, the text can be wrapped but no scrollbars
00061  *        are provided.
00062  * @end{macro}
00063  */
00064 
00065 /*WIKI
00066  * @page = GUIWidgetInstanceWML
00067  * @order = 2_label
00068  * @begin{parent}{name="gui/window/resolution/grid/row/column/"}
00069  * @begin{tag}{name="label"}{min=0}{max=-1}{super="generic/widget_instance"}
00070  * == Label ==
00071  *
00072  * @macro = label_description
00073  *
00074  * List with the label specific variables:
00075  * @begin{table}{config}
00076  *     wrap & bool & false &      Is wrapping enabled for the label. $
00077  *     characters_per_line & unsigned & 0 &
00078  *                                Sets the maximum number of characters per
00079  *                                line. The amount is an approximate since the
00080  *                                width of a character differs. E.g. iii is
00081  *                                smaller than MMM. When the value is non-zero
00082  *                                it also implies can_wrap is true.
00083  *                                When having long strings wrapping them can
00084  *                                increase readability, often 66 characters per
00085  *                                line is considered the optimum for a one
00086  *                                column text.
00087  *     text_alignment & h_align & "left" &
00088  *                                How is the text aligned in the label. $
00089  * @end{table}
00090  * @end{tag}{name="label"}
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 Fri May 25 2012 01:02:55 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs