unsigned read_flags(const config& cfg) { unsigned flags = 0; const unsigned v_flags = get_v_align(cfg["vertical_alignment"]); const unsigned h_flags = get_h_align(cfg["horizontal_alignment"]); flags |= get_border(utils::split(cfg["border"])); if(cfg["vertical_grow"].to_bool()) { flags |= grid::VERTICAL_GROW_SEND_TO_CLIENT; if(!(cfg["vertical_alignment"]).empty()) { ERR_GUI_P << "vertical_grow and vertical_alignment " "can't be combined, alignment is ignored.\n"; } } else { flags |= v_flags; } if(cfg["horizontal_grow"].to_bool()) { flags |= grid::HORIZONTAL_GROW_SEND_TO_CLIENT; if(!(cfg["horizontal_alignment"]).empty()) { ERR_GUI_P << "horizontal_grow and horizontal_alignment " "can't be combined, alignment is ignored.\n"; } } else { flags |= h_flags; } return flags; }
twindow_builder::tresolution::tresolution(const config& cfg) : window_width(lexical_cast_default<unsigned>(cfg["window_width"])), window_height(lexical_cast_default<unsigned>(cfg["window_height"])), automatic_placement(utils::string_bool(cfg["automatic_placement"], true)), x(cfg["x"]), y(cfg["y"]), width(cfg["width"]), height(cfg["height"]), vertical_placement(get_v_align(cfg["vertical_placement"])), horizontal_placement(get_h_align(cfg["horizontal_placement"])), easy_close(utils::string_bool(cfg["easy_close"])), definition(cfg["definition"]), grid(0) { /*WIKI * @page = GUIToolkitWML * @order = 1_window * * == Resolution == * * @start_table = config * window_width (unsigned = 0) Width of the application window. * window_height (unsigned = 0) Height of the application window. * * automatic_placement (bool = true) * Automatically calculate the best size for * the window and place it. If automatically * placed ''vertical_placement'' and * ''horizontal_placement'' can be used to * modify the final placement. If not * automatically placed the ''width'' and * ''height'' are mandatory. * * x (f_unsigned = 0) X coordinate of the window to show. * y (f_unsigned = 0) Y coordinate of the window to show. * width (f_unsigned = 0) Width of the window to show. * height (f_unsigned = 0) Height of the window to show. * * vertical_placement (v_align = "") * The vertical placement of the window. * horizontal_placement (h_align = "") * The horizontal placement of the window. * * easy_close (bool = false) Does the window need easy close behaviour? * Easy close behaviour means that any mouse * click will close the dialog. Note certain * widgets will automatically disable this * behaviour since they need to process the * clicks as well, for example buttons do need * a click and a missclick on button shouldn't * close the dialog. NOTE with some widgets * this behaviour depends on their contents * (like scrolling labels) so the behaviour * might get changed depending on the data in * the dialog. NOTE the default behaviour * might be changed since it will be disabled * when can't be used due to widgets which use * the mouse, including buttons, so it might * be wise to set the behaviour explicitly * when not wanted and no mouse using widgets * are available. This means enter, escape or * an external source needs to be used to * close the dialog (which is valid). * * definition (string = "default") * Definition of the window which we want to * show. * * grid (grid) The grid with the widgets to show. * @end_table * * The size variables are copied to the window and will be determined runtime. * This is needed since the main window can be resized and the dialog needs to * resize accordingly. The following variables are available: * @start_table = formula * screen_width unsigned The usable width of the Wesnoth main window. * screen_height unsigned The usable height of the Wesnoth main window. * gamemap_width unsigned The usable width of the Wesnoth gamemap, * if no gamemap shown it's the same value as * screen_width. * gamemap_height unsigned The usable height of the Wesnoth gamemap, * if no gamemap shown it's the same value as * screen_height. * @end_table */ VALIDATE(cfg.child("grid"), _("No grid defined.")); grid = new tbuilder_grid(*(cfg.child("grid"))); if(!automatic_placement) { VALIDATE(width.has_formula() || width(), missing_mandatory_wml_key("resolution", "width")); VALIDATE(height.has_formula() || height(), missing_mandatory_wml_key("resolution", "height")); } DBG_G_P << "Window builder: parsing resolution " << window_width << ',' << window_height << '\n'; if(definition.empty()) { definition = "default"; } }