tbuilder_gridcell::tbuilder_gridcell(const config& cfg) : tbuilder_widget(cfg), flags(read_flags(cfg)), border_size(lexical_cast_default<unsigned>((cfg)["border_size"])), widget(create_builder_widget(cfg)) { }
tbuilder_matrix::tbuilder_matrix(const config& cfg) : tbuilder_control(cfg) , vertical_scrollbar_mode( get_scrollbar_mode(cfg["vertical_scrollbar_mode"])) , horizontal_scrollbar_mode( get_scrollbar_mode(cfg["horizontal_scrollbar_mode"])) , builder_top(NULL) , builder_bottom(NULL) , builder_left(NULL) , builder_right(NULL) , builder_main(create_builder_widget(cfg.child("main", "[matrix]"))) { if(const config& top = cfg.child("top")) { builder_top = new tbuilder_grid(top); } if(const config& bottom = cfg.child("bottom")) { builder_bottom = new tbuilder_grid(bottom); } if(const config& left = cfg.child("left")) { builder_left = new tbuilder_grid(left); } if(const config& right = cfg.child("right")) { builder_right = new tbuilder_grid(right); } }
/*WIKI * @page = GUIToolkitWML * @order = 2_cell * @begin{parent}{name="gui/window/resolution/"} * = Cell = * @begin{tag}{name="grid"}{min="1"}{max="1"} * @begin{table}{config} * id & string & "" & A grid is a widget and can have an id. This isn't * used that often, but is allowed. $ * linked_group & string & 0 & $ * @end{table} * * Every grid cell has some cell configuration values and one widget in the grid * cell. Here we describe the what is available more information about the usage * can be found here [[GUILayout]]. * * == Row values == * @begin{tag}{name="row"}{min="0"}{max="-1"} * For every row the following variables are available: * * @begin{table}{config} * grow_factor & unsigned & 0 & The grow factor for a row. $ * @end{table} * * == Cell values == * @begin{tag}{name="column"}{min="0"}{max="-1"} * @allow{link}{name="gui/window/resolution/grid"} * For every column the following variables are available: * @begin{table}{config} * grow_factor & unsigned & 0 & The grow factor for a column, this * value is only read for the first row. $ * * border_size & unsigned & 0 & The border size for this grid cell. $ * border & border & "" & Where to place the border in this grid * cell. $ * * vertical_alignment & v_align & "" & * The vertical alignment of the widget in * the grid cell. (This value is ignored if * vertical_grow is true.) $ * horizontal_alignment & h_align & "" & * The horizontal alignment of the widget in * the grid cell.(This value is ignored if * horizontal_grow is true.) $ * * vertical_grow & bool & false & Does the widget grow in vertical * direction when the grid cell grows in the * vertical direction. This is used if the * grid cell is wider as the best width for * the widget. $ * horizontal_grow & bool & false & Does the widget grow in horizontal * direction when the grid cell grows in the * horizontal direction. This is used if the * grid cell is higher as the best width for * the widget. $ * @end{table} * @end{tag}{name="column"} * @end{tag}{name="row"} * @end{tag}{name="grid"} * @end{parent}{name="gui/window/resolution/"} * */ tbuilder_grid::tbuilder_grid(const config& cfg) : tbuilder_widget(cfg) , rows(0) , cols(0) , row_grow_factor() , col_grow_factor() , flags() , border_size() , widgets() { log_scope2(log_gui_parse, "Window builder: parsing a grid"); for(const auto & row : cfg.child_range("row")) { unsigned col = 0; row_grow_factor.push_back(row["grow_factor"]); for(const auto & c : row.child_range("column")) { flags.push_back(implementation::read_flags(c)); border_size.push_back(c["border_size"]); if(rows == 0) { col_grow_factor.push_back(c["grow_factor"]); } widgets.push_back(create_builder_widget(c)); ++col; } ++rows; if(rows == 1) { cols = col; } else { VALIDATE(col, _("A row must have a column.")); VALIDATE(col == cols, _("Number of columns differ.")); } } DBG_GUI_P << "Window builder: grid has " << rows << " rows and " << cols << " columns.\n"; }
tbuilder_viewport::tbuilder_viewport(const config& cfg) : tbuilder_widget(cfg) , widget(create_builder_widget(cfg.child("widget", "[viewport]"))) { }
tbuilder_grid::tbuilder_grid(const config& cfg) : tbuilder_widget(cfg), id(cfg["id"]), rows(0), cols(0), row_grow_factor(), col_grow_factor(), flags(), border_size(), widgets() { /*WIKI * @page = GUIToolkitWML * @order = 2_cell * * = Cell = * * Every grid cell has some cell configuration values and one widget in the grid * cell. Here we describe the what is available more information about the usage * can be found here [[GUILayout]]. * * == Row values == * * For every row the following variables are available: * * @start_table = config * grow_factor (unsigned = 0) The grow factor for a row. * @end_table * * == Cell values == * * For every column the following variables are available: * @start_table = config * grow_factor (unsigned = 0) The grow factor for a column, this value * is only read for the first row. * * border_size (unsigned = 0) The border size for this grid cell. * border (border = "") Where to place the border in this grid * cell. * * vertical_alignment (v_align = "") * The vertical alignment of the widget in * the grid cell. (This value is ignored if * vertical_grow is true.) * horizontal_alignment (h_align = "") * The horizontal alignment of the widget in * the grid cell.(This value is ignored if * horizontal_grow is true.) * * vertical_grow (bool = false) Does the widget grow in vertical * direction when the grid cell grows in the * vertical directon. This is used if the * grid cell is wider as the best width for * the widget. * horizontal_grow (bool = false) Does the widget grow in horizontal * direction when the grid cell grows in the * horizontal directon. This is used if the * grid cell is higher as the best width for * the widget. * @end_table * */ log_scope2(gui_parse, "Window builder: parsing a grid"); const config::child_list& row_cfgs = cfg.get_children("row"); for(std::vector<config*>::const_iterator row_itor = row_cfgs.begin(); row_itor != row_cfgs.end(); ++row_itor) { unsigned col = 0; row_grow_factor.push_back(lexical_cast_default<unsigned>((**row_itor)["grow_factor"])); const config::child_list& col_cfgs = (**row_itor).get_children("column"); for(std::vector<config*>::const_iterator col_itor = col_cfgs.begin(); col_itor != col_cfgs.end(); ++col_itor) { flags.push_back(read_flags(**col_itor)); border_size.push_back(lexical_cast_default<unsigned>((**col_itor)["border_size"])); if(rows == 0) { col_grow_factor.push_back(lexical_cast_default<unsigned>((**col_itor)["grow_factor"])); } widgets.push_back(create_builder_widget(**col_itor)); ++col; } ++rows; if(row_itor == row_cfgs.begin()) { cols = col; } else { VALIDATE(col, _("A row must have a column.")); VALIDATE(col == cols, _("Number of columns differ.")); } } DBG_G_P << "Window builder: grid has " << rows << " rows and " << cols << " columns.\n"; }