tresolution_definition_::tresolution_definition_(const config& cfg) : window_width(cfg["window_width"]) , window_height(cfg["window_height"]) , min_width(cfg["min_width"]) , min_height(cfg["min_height"]) , default_width(cfg["default_width"]) , default_height(cfg["default_height"]) , max_width(cfg["max_width"]) , max_height(cfg["max_height"]) , text_extra_width(cfg["text_extra_width"]) , text_extra_height(cfg["text_extra_height"]) , text_font_size(cfg["text_font_size"]) , text_font_family(font::str_to_family_class(cfg["text_font_family"])) , text_font_style(decode_font_style(cfg["text_font_style"])) , state() { DBG_GUI_P << "Parsing resolution " << window_width << ", " << window_height << '\n'; }
tresolution_definition_::tresolution_definition_(const config& cfg) : window_width(lexical_cast_default<unsigned>(cfg["window_width"])), window_height(lexical_cast_default<unsigned>(cfg["window_height"])), min_width(lexical_cast_default<unsigned>(cfg["min_width"])), min_height(lexical_cast_default<unsigned>(cfg["min_height"])), default_width(lexical_cast_default<unsigned>(cfg["default_width"])), default_height(lexical_cast_default<unsigned>(cfg["default_height"])), max_width(lexical_cast_default<unsigned>(cfg["max_width"])), max_height(lexical_cast_default<unsigned>(cfg["max_height"])), text_extra_width(lexical_cast_default<unsigned>(cfg["text_extra_width"])), text_extra_height(lexical_cast_default<unsigned>(cfg["text_extra_height"])), text_font_size(lexical_cast_default<unsigned>(cfg["text_font_size"])), text_font_style(decode_font_style(cfg["text_font_style"])), state() { /*WIKI * @page = GUIToolkitWML * @order = 1_widget * * == Resolution == * * Depending on the resolution a widget can look different. Resolutions are * evaluated in order of appearance. The ''window_width'' and ''window_height'' * are the upper limit this resolution is valid for. When one of the sizes * gets above the limit, the next resolution is selected. There's one special * case where both values are ''0''. This resolution always matches. (Resolution * definitions behind that one will never be picked.) This resolution can be * used as upper limit or if there's only one resolution. * * The default (and also minimum) size of a button is determined by two items, * the wanted default size and the size needed for the text. The size of the * text differs per used widget so needs to be determined per button. * * Container widgets like panels and windows have other rules for their sizes. * Their sizes are based on the size of their children (and the border they need * themselves). It's wise to set all sizes to 0 for these kind of widgets. * * @start_table = config * window_width (unsigned = 0) Width of the application window. * window_height (unsigned = 0) * Height of the application window. * min_width (unsigned = 0) The minimum width of the widget. * min_height (unsigned = 0) The minimum height of the widget. * * default_width (unsigned = 0) The default width of the widget. * default_height (unsigned = 0) The default height of the widget. * * max_width (unsigned = 0) The maximum width of the widget. * max_height (unsigned = 0) The maximum height of the widget. * * text_extra_width (unsigned = 0) * The extra width needed to determine the * minimal size for the text. * text_extra_height (unsigned = 0) * The extra height needed to determine the * minimal size for the text. * text_font_size (unsigned = 0) The font size, which needs to be used to * determine the minimal size for the text. * text_font_style (font_style = "") * The font style, which needs to be used to * determine the minimal size for the text. * * state (section) Every widget has one or more state * sections. * Note they aren't called state but state_xxx * the exact names are listed per widget. * @end_table * */ DBG_GUI_P << "Parsing resolution " << window_width << ", " << window_height << '\n'; }
ttext::ttext(const config& cfg) : x_(cfg["x"]) , y_(cfg["y"]) , w_(cfg["w"]) , h_(cfg["h"]) , font_size_(cfg["font_size"]) , font_style_(decode_font_style(cfg["font_style"])) , text_alignment_(cfg["text_alignment"]) , color_(decode_color(cfg["color"])) , text_(cfg["text"]) , text_markup_(cfg["text_markup"], false) , maximum_width_(cfg["maximum_width"], -1) , maximum_height_(cfg["maximum_height"], -1) { /*WIKI * @page = GUICanvasWML * * == Text == * @begin{tag}{name="text"}{min="0"}{max="-1"} * Definition of text. * * Keys: * @begin{table}{config} * x & f_unsigned & 0 & The x coordinate of the top left corner. $ * y & f_unsigned & 0 & The y coordinate of the top left corner. $ * w & f_unsigned & 0 & The width of the text's bounding * rectangle. $ * h & f_unsigned & 0 & The height of the text's bounding * rectangle. $ * font_size & unsigned & & The size of the text font. $ * font_style & font_style & "" & The style of the text. $ * text_alignment & f_h_align & "left" & * The alignment of the text. $ * color & color & "" & The color of the text. $ * text & f_tstring & "" & The text to draw (translatable). $ * text_markup & f_bool & false & Can the text have mark-up? $ * maximum_width & f_int & -1 & The maximum width the text is allowed to * be. $ * maximum_height & f_int & -1 & The maximum height the text is allowed * to be. $ * debug & string & "" & Debug message to show upon creation * this message is not stored. $ * @end{table} * @end{tag}{name="text"} * NOTE alignment could only be done with the formulas, but now with the * text_alignment flag as well, older widgets might still use the formulas and * not all widgets may expose the text alignment yet and when exposed not use * it yet. * * Variables: * @begin{table}{formula} * text_width & unsigned & The width of the rendered text. $ * text_height & unsigned & The height of the rendered text. $ * @end{table} * Also the general variables are available, see [[#general_variables|Line]]. * @end{parent}{name="generic/state/draw/"} */ VALIDATE(font_size_, _("Text has a font size of 0.")); const std::string& debug = (cfg["debug"]); if(!debug.empty()) { DBG_GUI_P << "Text: found debug message '" << debug << "'.\n"; } }
tresolution_definition_::tresolution_definition_(const config& cfg) : window_width(cfg["window_width"].to_int()) , window_height(cfg["window_height"].to_int()) , default_width(cfg["default_width"].to_int()) , default_height(cfg["default_height"].to_int()) , max_width(cfg["max_width"].to_int()) , max_height(cfg["max_height"].to_int()) , text_extra_width(cfg["text_extra_width"].to_int()) , text_extra_height(cfg["text_extra_height"].to_int()) , text_font_size(cfg["text_font_size"].to_int()) , text_font_style(decode_font_style(cfg["text_font_style"])) , state() { /*WIKI * @page = GUIToolkitWML * @order = 1_widget * @begin{parent}{name=generic/widget_definition/} * == Resolution == * @begin{tag}{name="resolution"}{min="0"}{max="-1"} * * Depending on the resolution a widget can look different. Resolutions are * evaluated in order of appearance. The ''window_width'' and ''window_height'' * are the upper limit this resolution is valid for. When one of the sizes * gets above the limit, the next resolution is selected. There's one special * case where both values are ''0''. This resolution always matches. (Resolution * definitions behind that one will never be picked.) This resolution can be * used as upper limit or if there's only one resolution. * * The default (and also minimum) size of a button is determined by two items, * the wanted default size and the size needed for the text. The size of the * text differs per used widget so needs to be determined per button. * * Container widgets like panels and windows have other rules for their sizes. * Their sizes are based on the size of their children (and the border they need * themselves). It's wise to set all sizes to 0 for these kind of widgets. * * @begin{table}{config} * window_width & unsigned & 0 & Width of the application window. $ * window_height & unsigned & 0 & Height of the application window. $ * * * min_width & unsigned & 0 & The minimum width of the widget. $ * min_height & unsigned & 0 & The minimum height of the widget. $ * * * default_width & unsigned & 0 & The default width of the widget. $ * default_height & unsigned & 0 & The default height of the widget. $ * * * max_width & unsigned & 0 & The maximum width of the widget. $ * max_height & unsigned & 0 & The maximum height of the widget. $ * * text_extra_width & unsigned & 0 & * The extra width needed to determine the minimal size for the text. $ * * text_extra_height & unsigned & 0 & * The extra height needed to determine the minimal size for the text. $ * * text_font_size & unsigned & 0 & * The font size, which needs to be used to determine the minimal size for * the text. $ * * text_font_style & font_style & "" & * The font style, which needs to be used to determine the minimal size for * the text. $ * * * state & section & & * Every widget has one or more state sections. Note they aren't called * state but state_xxx the exact names are listed per widget. $ * @end{table} * @end{tag}{name="resolution"} * @end{parent}{name=generic/widget_definition/} */ if (twidget::hdpi) { if (window_width && window_height) { window_width = (window_width + 1) * twidget::hdpi_ratio - 1; window_height = (window_height + 1) * twidget::hdpi_ratio - 1; } default_width *= twidget::hdpi_ratio; default_height *= twidget::hdpi_ratio; max_width *= twidget::hdpi_ratio; max_height *= twidget::hdpi_ratio; text_extra_width *= twidget::hdpi_ratio; text_extra_height *= twidget::hdpi_ratio; text_font_size *= twidget::hdpi_ratio; } DBG_GUI_P << "Parsing resolution " << window_width << ", " << window_height << '\n'; }