15 #define GETTEXT_DOMAIN "wesnoth-lib" 30 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__ 31 #define LOG_HEADER LOG_SCOPE_HEADER + ':' 46 set_wants_mouse_left_double_click();
48 connect_signal<event::MOUSE_ENTER>(std::bind(
50 connect_signal<event::MOUSE_LEAVE>(std::bind(
53 connect_signal<event::LEFT_BUTTON_CLICK>(
56 std::placeholders::_2),
59 connect_signal<event::LEFT_BUTTON_CLICK>(std::bind(
61 connect_signal<event::LEFT_BUTTON_CLICK>(
64 std::placeholders::_2,
65 std::placeholders::_3),
67 connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(
70 std::placeholders::_2,
71 std::placeholders::_3));
72 connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(
75 std::placeholders::_2,
76 std::placeholders::_3),
82 std::div_t res = std::div(this->
config()->state.size(),
COUNT);
89 const std::map<std::string /* widget id */, string_map>& data)
91 for(
const auto &
item : data)
100 const bool must_be_active)
115 const bool must_be_active)
const 142 const auto conf = cast_config_to<toggle_panel_definition>();
146 result.x += conf->left_border;
147 result.y += conf->top_border;
148 result.w -= conf->left_border + conf->right_border;
149 result.h -= conf->top_border + conf->bottom_border;
156 const auto conf = cast_config_to<toggle_panel_definition>();
159 return point(conf->left_border + conf->right_border, conf->top_border + conf->bottom_border);
192 const auto conf = cast_config_to<toggle_panel_definition>();
291 DBG_GUI_P <<
"Parsing toggle panel " <<
id <<
'\n';
293 load_resolutions<resolution>(cfg);
298 , top_border(cfg[
"top_border"])
299 , bottom_border(cfg[
"bottom_border"])
300 , left_border(cfg[
"left_border"])
301 , right_border(cfg[
"right_border"])
306 state.emplace_back(
c.child(
"enabled"));
307 state.emplace_back(
c.child(
"disabled"));
308 state.emplace_back(
c.child(
"focused"));
317 builder_toggle_panel::builder_toggle_panel(
const config& cfg)
320 , retval_id_(cfg[
"return_value_id"])
321 , retval_(cfg[
"return_value"])
327 grid = std::make_shared<builder_grid>(
c);
336 DBG_GUI_G <<
"Window builder: placed toggle panel '" <<
id 337 <<
"' with definition '" <<
definition <<
"'.\n";
Define the common log macros for the gui toolkit.
Base class of a resolution, contains the common keys for a resolution.
Class for a toggle button.
virtual unsigned get_state() const override
See styled_widget::get_state.
virtual void set_value(unsigned selected, bool fire_event=false) override
Inherited from selectable_item.
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
std::vector< state_definition > state
unsigned state_num_
Usually 1 for selected and 0 for not selected, can also have higher values in tristate buttons...
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
virtual bool get_active() const override
See styled_widget::get_active.
void set_child_members(const std::map< std::string, string_map > &data)
Sets the members of the child controls.
A panel is a visible container to hold multiple widgets.
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
virtual point border_space() const override
See container_base::border_space.
child_itors child_range(config_key_type key)
int get_retval(const std::string &retval_id, const int retval, const std::string &id)
Returns the return value for a widget.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
static std::string _(const char *str)
toggle_panel_definition(const config &cfg)
Sent by a widget to notify others its contents or state are modified.
void signal_handler_pre_left_button_click(const event::ui_event event)
void signal_handler_mouse_leave(const event::ui_event event, bool &handled)
virtual widget * build() const override
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
This file contains the settings handling of the widget library.
void set_state(const state_t state)
virtual void impl_draw_foreground(surface &frame_buffer, int x_offset, int y_offset) override
See widget::impl_draw_foreground.
void init_grid(const builder_grid &grid_builder)
Initializes and builds the grid.
void signal_handler_left_button_click(const event::ui_event event, bool &handled)
virtual unsigned num_states() const override
Inherited from selectable_item.
state_t state_
Current state of the widget.
int retval_
The return value of the button.
bool fire_event(const ui_event event, std::vector< std::pair< widget *, ui_event >> &event_chain, widget *dispatcher, widget *w, F &&... params)
Helper function for fire_event.
state_t
Possible states of the widget.
virtual void set_active(const bool active) override
See styled_widget::set_active.
void set_retval(const int retval)
Default, unset return value.
virtual void impl_draw_background(surface &frame_buffer, int x_offset, int y_offset) override
See widget::impl_draw_background.
resolution(const config &cfg)
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
std::string sound_toggle_panel_click
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
void play_UI_sound(const std::string &files)
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
retval
Default window/dialog return values.
void signal_handler_left_button_double_click(const event::ui_event event, bool &handled)
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
A config object defines a single node in a WML file, with access to child nodes.
virtual unsigned get_value() const override
Inherited from selectable_item.
virtual SDL_Rect get_client_rect() const override
See container_base::get_client_rect.
base class of top level items, the only item which needs to store the final canvases to draw on...
Contains the implementation details for lexical_cast and shouldn't be used directly.
ui_event
The event send to the dispatcher.
std::pair< std::string, unsigned > item
void signal_handler_mouse_enter(const event::ui_event event, bool &handled)