builder_listbox::builder_listbox(const config& cfg) : builder_styled_widget(cfg) , vertical_scrollbar_mode(get_scrollbar_mode(cfg["vertical_scrollbar_mode"])) , horizontal_scrollbar_mode(get_scrollbar_mode(cfg["horizontal_scrollbar_mode"])) , header(nullptr) , footer(nullptr) , list_builder(nullptr) , list_data() , has_minimum_(cfg["has_minimum"].to_bool(true)) , has_maximum_(cfg["has_maximum"].to_bool(true)) { if(const config& h = cfg.child("header")) { header = std::make_shared<builder_grid>(h); } if(const config& f = cfg.child("footer")) { footer = std::make_shared<builder_grid>(f); } const config& l = cfg.child("list_definition"); VALIDATE(l, _("No list defined.")); list_builder = std::make_shared<builder_grid>(l); assert(list_builder); VALIDATE(list_builder->rows == 1, _("A 'list_definition' should contain one row.")); if(cfg.has_child("list_data")) { list_data = parse_list_data(cfg.child("list_data"), list_builder->cols); } }
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); } }
tbuilder_scroll_label::tbuilder_scroll_label(const config& cfg) : implementation::tbuilder_control(cfg) , vertical_scrollbar_mode( get_scrollbar_mode(cfg["vertical_scrollbar_mode"])) , horizontal_scrollbar_mode( get_scrollbar_mode(cfg["horizontal_scrollbar_mode"])) { }
builder_scroll_label::builder_scroll_label(const config& cfg) : implementation::builder_styled_widget(cfg) , vertical_scrollbar_mode(get_scrollbar_mode(cfg["vertical_scrollbar_mode"])) , horizontal_scrollbar_mode(get_scrollbar_mode(cfg["horizontal_scrollbar_mode"])) , wrap_on(cfg["wrap"].to_bool(true)) , text_alignment(decode_text_alignment(cfg["text_alignment"])) { }
tbuilder_listbox::tbuilder_listbox(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"])) , header(nullptr) , footer(nullptr) , list_builder(nullptr) , list_data() , has_minimum_(cfg["has_minimum"].to_bool(true)) , has_maximum_(cfg["has_maximum"].to_bool(true)) { if(const config& h = cfg.child("header")) { header = std::make_shared<tbuilder_grid>(h); } if(const config& f = cfg.child("footer")) { footer = std::make_shared<tbuilder_grid>(f); } const config& l = cfg.child("list_definition"); VALIDATE(l, _("No list defined.")); list_builder = std::make_shared<tbuilder_grid>(l); assert(list_builder); VALIDATE(list_builder->rows == 1, _("A 'list_definition' should contain one row.")); const config& data = cfg.child("list_data"); if(!data) { return; } for(const auto & row : data.child_range("row")) { unsigned col = 0; for(const auto & c : row.child_range("column")) { list_data.push_back(string_map()); for(const auto & i : c.attribute_range()) { list_data.back()[i.first] = i.second; } ++col; } VALIDATE(col == list_builder->cols, _("'list_data' must have the same number of " "columns as the 'list_definition'.")); } }
tbuilder_report::tbuilder_report(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"])) , width(cfg["width"]) , height(cfg["height"]) , unit_width(cfg["unit_width"]) , unit_height(cfg["unit_height"]) , gap(cfg["gap"]) { }
tbuilder_scrollbar_panel::tbuilder_scrollbar_panel(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"])) , grid(nullptr) { const config& definition = cfg.child("definition"); VALIDATE(definition, _("No list defined.")); grid = std::make_shared<tbuilder_grid>(definition); assert(grid); }
builder_scrollbar_panel::builder_scrollbar_panel(const config& cfg) : builder_styled_widget(cfg) , vertical_scrollbar_mode( get_scrollbar_mode(cfg["vertical_scrollbar_mode"])) , horizontal_scrollbar_mode( get_scrollbar_mode(cfg["horizontal_scrollbar_mode"])) , grid_(nullptr) { const config& grid_definition = cfg.child("definition"); VALIDATE(grid_definition, _("No list defined.")); grid_ = std::make_shared<builder_grid>(grid_definition); assert(grid_); }
tbuilder_tree_view::tbuilder_tree_view(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"])) , indention_step_size(cfg["indention_step_size"]) , nodes() { for(const auto & node : cfg.child_range("node")) { nodes.push_back(ttree_node(node)); } VALIDATE(!nodes.empty(), _("No nodes defined for a tree view.")); }
tbuilder_report::tbuilder_report(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"])) , width(cfg["width"]) , height(cfg["height"]) , unit_width(cfg["unit_width"]) , unit_height(cfg["unit_height"]) , gap(cfg["gap"]) { if (twidget::hdpi) { unit_width *= twidget::hdpi_ratio; unit_height *= twidget::hdpi_ratio; gap *= twidget::hdpi_ratio; } }
tbuilder_horizontal_listbox::tbuilder_horizontal_listbox(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"])) , list_builder(nullptr) , list_data() { const config& l = cfg.child("list_definition"); VALIDATE(l, _("No list defined.")); list_builder = new tbuilder_grid(l); assert(list_builder); VALIDATE(list_builder->rows == 1, _("A 'list_definition' should contain one row.")); const config& data = cfg.child("list_data"); if(!data) return; for(const auto & row : data.child_range("row")) { unsigned col = 0; for(const auto & c : row.child_range("column")) { list_data.push_back(string_map()); for(const auto & i : c.attribute_range()) { list_data.back()[i.first] = i.second; } ++col; } VALIDATE(col == list_builder->cols, _("'list_data' must have " "the same number of columns as the 'list_definition'.")); } }
tbuilder_horizontal_listbox::tbuilder_horizontal_listbox(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"])) , list_builder(nullptr) , list_data() , has_minimum_(cfg["has_minimum"].to_bool(true)) , has_maximum_(cfg["has_maximum"].to_bool(true)) { const config& l = cfg.child("list_definition"); VALIDATE(l, _("No list defined.")); list_builder = std::make_shared<tbuilder_grid>(l); assert(list_builder); VALIDATE(list_builder->rows == 1, _("A 'list_definition' should contain one row.")); if(cfg.has_child("list_data")) { list_data = parse_list_data(cfg.child("list_data"), list_builder->cols); } }
tbuilder_listbox::tbuilder_listbox(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"])), header(cfg.child("header") ? new tbuilder_grid(*(cfg.child("header"))) : 0), footer(cfg.child("footer") ? new tbuilder_grid(*(cfg.child("footer"))) : 0), list_builder(0), list_data() { /*WIKI * @page = GUIWidgetInstanceWML * @order = 2_listbox * * == Listbox == * * Instance of a listbox. * * List with the listbox specific variables: * @start_table = config * vertical_scrollbar_mode (scrollbar_mode = auto) * Determines whether or not to show the * scrollbar. * horizontal_scrollbar_mode (scrollbar_mode = auto) * Determines whether or not to show the * scrollbar. * * header (grid = []) Defines the grid for the optional * header. (This grid will automatically * get the id _header_grid.) * footer (grid = []) Defines the grid for the optional * footer. (This grid will automatically * get the id _footer_grid.) * * list_definition (section) This defines how a listboxs list data * looks. It must contain the grid * definition for 1 row of the list. * * list_data(section = []) A grid alike section which stores the * initial data for the listbox. Every row * must have the same number of columns as * the 'list_definition'. * @end_table * * * Inside the list section there are only the following widgets allowed * * grid (to nest) * * selectable widgets which are * ** toggle_button * ** toggle_panel * */ VALIDATE(cfg.child("list_definition"), _("No list defined.")); list_builder = new tbuilder_grid(*(cfg.child("list_definition"))); assert(list_builder); VALIDATE(list_builder->rows == 1, _("A 'list_definition' should contain one row.")); const config *data = cfg.child("list_data"); if(data) { const config::child_list& row_cfgs = data->get_children("row"); for(std::vector<config*>::const_iterator row_itor = row_cfgs.begin(); row_itor != row_cfgs.end(); ++row_itor) { unsigned col = 0; 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) { list_data.push_back((**col_itor).values); ++col; } VALIDATE(col == list_builder->cols, _("'list_data' must have " "the same number of columns as the 'list_definition'.")); } } }