45 namespace event {
struct message; }
49 namespace dialogs {
class modal_dialog; }
50 class debug_layout_graph;
66 friend class debug_layout_graph;
87 static retval get_retval_by_id(
const std::string&
id);
109 int show(
const bool restore =
true,
const unsigned auto_close_timeout = 0);
139 void show_non_modal();
164 dirty_list_.push_back(call_stack);
183 status_ = status::REQUEST_CLOSE;
209 return invalidate_layout_blocked_;
219 void invalidate_layout();
223 const bool must_be_active)
override;
226 virtual const widget* find_at(
const point& coordinate,
227 const bool must_be_active)
const override;
236 widget* find(
const std::string&
id,
const bool must_be_active)
override;
239 const widget* find(
const std::string&
id,
240 const bool must_be_active)
const override;
251 void add_click_dismiss_blocker(
const std::string&
id);
261 void remove_click_dismiss_blocker(
const std::string&
id);
274 return click_dismiss_ && !disable_click_dismiss();
287 enter_disabled_ = enter_disabled;
300 escape_disabled_ = escape_disabled;
312 void init_linked_size_group(
const std::string&
id,
313 const bool fixed_width,
314 const bool fixed_height);
323 bool has_linked_size_group(
const std::string&
id);
335 void add_linked_widget(
const std::string&
id,
widget*
widget);
347 void remove_linked_widget(
const std::string&
id,
const widget* widget);
376 click_dismiss_ = click_dismiss;
386 variables_.add(key, value);
391 std::map<std::string, linked_size>::const_iterator it = linked_size_.find(linked_group_id);
392 if(it != linked_size_.end()) {
393 return point(it->second.width, it->second.height);
396 return point(-1, -1);
413 exit_hook_ = [func](
window&
w)->
bool {
return w.get_retval() !=
OK || func(
w); };
424 callback_next_draw_ = func;
564 : widgets(), width(width ? 0 : -1), height(height ? 0 : -1)
599 void layout_linked_widgets();
611 bool click_dismiss(
const int mouse_button_mask);
633 static const std::string&
type();
637 virtual const std::string& get_control_type()
const override;
652 unsigned int consecutive_changed_frames_ = 0u;
655 void redraw_windows_on_top()
const;
664 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS 665 debug_layout_graph* debug_layout_;
669 void generate_dot_file(
const std::string&
generator,
const unsigned domain);
684 return *event_distributor_;
695 void mouse_capture(
const bool capture =
true);
696 void keyboard_capture(widget* widget);
706 void add_to_keyboard_chain(widget* widget);
715 void remove_from_keyboard_chain(widget* widget);
722 void add_to_tab_order(widget* widget,
int at = -1);
729 const point& new_size);
742 const int mouse_button_mask);
746 const SDL_Keycode key,
747 const SDL_Keymod mod,
761 void signal_handler_close_window();
bool click_dismiss_
Do we want to have easy close behavior?
wfl::function_symbol_table functions_
The formula definitions available for the calculation formulas.
void close()
Requests to close the window.
show_mode mode() const
Returns the dialog mode for this window.
void set_exit_hook_ok_only(std::function< bool(window &)> func)
typed_formula< unsigned > maximum_height_
The maximum height if automatic_placement_ is true.
bool does_click_dismiss() const
Does the window close easily?
std::function< bool(window &)> exit_hook_
Helper class to block invalidate_layout.
typed_formula< unsigned > h_
The formula to calculate the height of the dialog.
Key Type Default Description window_width unsigned 0 Width of the application window.
const unsigned horizontal_placement_
Sets the horizontal placement.
A panel is a visible container to hold multiple widgets.
Main class to show messages to the user.
CVideo & video_
Needed so we can change what's drawn on the screen.
void generate_dot_file(const std::string &, const unsigned)
Helper struct to force widgets the have the same size.
void set_click_dismiss(const bool click_dismiss)
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
typed_formula< unsigned > w_
The formula to calculate the width of the dialog.
status
The status of the window.
int mouse_button_state_
The state of the mouse button.
int width
The current width of all widgets in the group, -1 if the width is not linked.
point get_linked_size(const std::string &linked_group_id) const
The message callbacks hold a reference to a message.
The event handler class for the widget library.
static std::string at(const std::string &file, int line)
status status_
The status of the window.
std::vector< widget * > widgets
The widgets linked.
surface restorer_
When the window closes this surface is used to undraw the window.
bool suspend_drawing_
Avoid drawing the window.
bool enter_disabled_
Disable the enter key see our setter for more info.
bool invalidate_layout_blocked_
Is invalidate_layout blocked, see invalidate_layout_blocker.
bool need_layout_
When set the form needs a full layout redraw cycle.
typed_formula< bool > reevaluate_best_size_
The formula to determine whether the size is good.
builder_window::window_resolution::tooltip_info helptip_
The settings for the helptip.
bool is_toplevel_
Whether the window has other windows behind it.
static thread_local std::deque< std::string > call_stack
For printing error messages when WFL parsing or evaluation fails, this contains the names of the WFL ...
typed_formula< unsigned > y_
The formula to calculate the y value of the dialog.
Basic template class to generate new items.
const bool automatic_placement_
Do we wish to place the widget automatically?
typed_formula< unsigned > maximum_width_
The maximum width if automatic_placement_ is true.
typed_formula< unsigned > x_
The formula to calculate the x value of the dialog.
std::vector< std::vector< widget * > > dirty_list_
The list with dirty items in the window.
bool escape_disabled_
Disable the escape key see our setter for more info.
A pane is a container where new members can be added and removed during run-time. ...
Various uncategorised dialogs.
linked_size(const bool width=false, const bool height=false)
void add_to_dirty_list(const std::vector< widget *> &call_stack)
Adds an item to the dirty_list_.
Helper to implement private functions without modifying the header.
const unsigned vertical_placement_
Sets the vertical placement.
std::vector< widget * > tab_order
List of widgets in the tabbing order.
bool invalidate_layout_blocked() const
Is invalidate_layout blocked, see invalidate_layout_blocker.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
builder_window::window_resolution::tooltip_info tooltip_
The settings for the tooltip.
show_mode show_mode_
The mode in which the window is shown.
void set_exit_hook(std::function< bool(window &)> func)
Sets the window's exit hook.
bool restore_
Whether the window should undraw the window using restorer_.
bool get_need_layout() const
Abstract base class for all modal dialogs.
std::unique_ptr< event::distributor > event_distributor_
dialogs::modal_dialog * owner_
The dialog that owns the window.
retval
Default window/dialog return values.
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
dialogs::modal_dialog * dialog()
Inherited from widget.
Dialog was closed with the OK button.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
int height
The current height of all widgets in the group, -1 if the height is not linked.
A config object defines a single node in a WML file, with access to child nodes.
std::shared_ptr< halo_record > handle
base class of top level items, the only item which needs to store the final canvases to draw on...
std::shared_ptr< builder_grid > builder_grid_ptr
std::map< std::string, linked_size > linked_size_
List of the widgets, whose size are linked together.
wfl::map_formula_callable variables_
The variables of the canvas.
ui_event
The event send to the dispatcher.
void set_callback_next_draw(std::function< void()> func)
Sets a callback that will be called after the window is drawn next time.
void set_owner(dialogs::modal_dialog *owner)
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
const event::distributor & get_distributor() const
Gets a reference to the window's distributor to allow some state peeking.
void set_variable(const std::string &key, const wfl::variant &value)
std::function< void()> callback_next_draw_
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.