16 #define GETTEXT_DOMAIN "wesnoth-lib"
31 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
32 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
47 set_wants_mouse_left_double_click();
49 connect_signal<event::MOUSE_ENTER>(std::bind(
51 connect_signal<event::MOUSE_LEAVE>(std::bind(
54 connect_signal<event::LEFT_BUTTON_CLICK>(
57 std::placeholders::_2),
60 connect_signal<event::LEFT_BUTTON_CLICK>(std::bind(
62 connect_signal<event::LEFT_BUTTON_CLICK>(
65 std::placeholders::_2,
66 std::placeholders::_3),
68 connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(
71 std::placeholders::_2,
72 std::placeholders::_3));
73 connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(
76 std::placeholders::_2,
77 std::placeholders::_3),
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>();
289 load_resolutions<resolution>(cfg);
294 , top_border(cfg[
"top_border"])
295 , bottom_border(cfg[
"bottom_border"])
296 , left_border(cfg[
"left_border"])
297 , right_border(cfg[
"right_border"])
313 builder_toggle_panel::builder_toggle_panel(
const config& cfg)
316 , retval_id_(cfg[
"return_value_id"])
317 , retval_(cfg[
"return_value"])
323 grid = std::make_shared<builder_grid>(*
c);
328 auto widget = std::make_unique<toggle_panel>(*
this);
332 DBG_GUI_G <<
"Window builder: placed toggle panel '" <<
id
333 <<
"' with definition '" <<
definition <<
"'.";
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Equivalent to mandatory_child, but returns an empty optional if the nth child was not found.
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
void signal_handler_left_button_double_click(const event::ui_event event, bool &handled)
unsigned state_num_
Usually 1 for selected and 0 for not selected, can also have higher values in tristate buttons.
virtual bool impl_draw_foreground() override
See widget::impl_draw_foreground.
virtual bool impl_draw_background() override
See widget::impl_draw_background.
void signal_handler_mouse_enter(const event::ui_event event, bool &handled)
void set_state(const state_t state)
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
void set_child_members(const widget_data &data)
Sets the members of the child controls.
virtual unsigned get_state() const override
See styled_widget::get_state.
virtual void set_active(const bool active) override
See styled_widget::set_active.
int retval_
The return value of the button.
void set_retval(const int retval)
virtual unsigned get_value() const override
Inherited from selectable_item.
void signal_handler_left_button_click(const event::ui_event event, bool &handled)
virtual point border_space() const override
See container_base::border_space.
virtual bool get_active() const override
See styled_widget::get_active.
virtual void set_value(unsigned selected, bool fire_event=false) override
Inherited from selectable_item.
void signal_handler_mouse_leave(const event::ui_event event, bool &handled)
state_t state_
Current state of the widget.
virtual unsigned num_states() const override
Inherited from selectable_item.
void signal_handler_pre_left_button_click(const event::ui_event event)
state_t
Possible states of the widget.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
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.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
static std::string _(const char *str)
Define the common log macros for the gui toolkit.
void point(int x, int y)
Draw a single point.
bool fire_event(const ui_event event, const std::vector< std::pair< widget *, ui_event >> &event_chain, widget *dispatcher, widget *w, F &&... params)
Helper function for fire_event.
ui_event
The event sent to the dispatcher.
int get_retval(const std::string &retval_id, const int retval, const std::string &id)
Returns the return value for a widget.
std::string sound_toggle_panel_click
std::map< std::string, widget_item > widget_data
retval
Default window/dialog return values.
@ NONE
Default, unset return value.
std::pair< std::string, unsigned > item
Contains the implementation details for lexical_cast and shouldn't be used directly.
void play_UI_sound(const std::string &files)
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
This file contains the settings handling of the widget library.
virtual std::unique_ptr< widget > build() const override
std::vector< state_definition > state
resolution(const config &cfg)
toggle_panel_definition(const config &cfg)
std::string missing_mandatory_wml_tag(const std::string §ion, const std::string &tag)
Returns a standard message for a missing wml child (tag).
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
#define VALIDATE_WML_CHILD(cfg, key, message)
#define VALIDATE(cond, message)
The macro to use for the validation of WML.