The Battle for Wesnoth  1.15.0+dev
window.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * This file contains the window object, this object is a top level container
18  * which has the event management as well.
19  */
20 
21 #pragma once
22 
23 #include "cursor.hpp"
24 #include "formula/callable.hpp"
25 #include "formula/function.hpp"
29 #include "gui/widgets/panel.hpp"
30 #include "gui/widgets/retval.hpp"
31 
32 #include <functional>
33 #include <map>
34 #include <memory>
35 #include <string>
36 #include <vector>
37 
38 class CVideo;
39 class surface;
40 struct point;
41 
42 namespace gui2
43 {
44 
45 class widget;
46 namespace event { struct message; }
47 
48 // ------------ WIDGET -----------{
49 
50 namespace dialogs { class modal_dialog; }
51 class debug_layout_graph;
52 class pane;
53 
54 namespace event
55 {
56 class distributor;
57 } // namespace event
58 
59 /**
60  * base class of top level items, the only item
61  * which needs to store the final canvases to draw on
62  */
63 class window : public panel, public cursor::setter
64 {
65  friend class debug_layout_graph;
67  friend struct window_implementation;
69  friend class pane;
70 
71 public:
72  explicit window(const builder_window::window_resolution* definition);
73 
74  ~window();
75 
76  /**
77  * Returns the instance of a window.
78  *
79  * @param handle The instance id of the window.
80  *
81  * @returns The window or nullptr.
82  */
83  static window* window_instance(const unsigned handle);
84 
85  /** Gets the retval for the default buttons. */
86  static retval get_retval_by_id(const std::string& id);
87 
88  /**
89  * @todo Clean up the show functions.
90  *
91  * the show functions are a bit messy and can use a proper cleanup.
92  */
93 
94  /**
95  * Shows the window.
96  *
97  * @param restore Restore the screenarea the window was on
98  * after closing it?
99  * @param auto_close_timeout The time in ms after which the window will
100  * automatically close, if 0 it doesn't close.
101  * @note the timeout is a minimum time and
102  * there's no guarantee about how fast it closes
103  * after the minimum.
104  *
105  * @returns The close code of the window, predefined
106  * values are listed in retval.
107  */
108  int show(const bool restore = true, const unsigned auto_close_timeout = 0);
109 
110  /**
111  * Shows the window as a tooltip.
112  *
113  * A tooltip can't be interacted with and is just shown.
114  *
115  * @todo implement @p auto_close_timeout.
116  *
117  * @p auto_close_timeout The time in ms after which the window will
118  * automatically close, if 0 it doesn't close.
119  * @note the timeout is a minimum time and
120  * there's no guarantee about how fast it closes
121  * after the minimum.
122  */
123  void show_tooltip(/*const unsigned auto_close_timeout = 0*/);
124 
125  /**
126  * Shows the window non modal.
127  *
128  * A tooltip can be interacted with unlike the tooltip.
129  *
130  * @todo implement @p auto_close_timeout.
131  *
132  * @p auto_close_timeout The time in ms after which the window will
133  * automatically close, if 0 it doesn't close.
134  * @note the timeout is a minimum time and
135  * there's no guarantee about how fast it closes
136  * after the minimum.
137  */
138  void show_non_modal(/*const unsigned auto_close_timeout = 0*/);
139 
140  /**
141  * Draws the window.
142  *
143  * This routine draws the window if needed, it's called from the event
144  * handler. This is done by a drawing event. When a window is shown it
145  * manages an SDL timer which fires a drawing event every X milliseconds,
146  * that event calls this routine. Don't call it manually.
147  */
148  void draw();
149 
150  /**
151  * Undraws the window.
152  */
153  void undraw();
154 
155  /**
156  * Adds an item to the dirty_list_.
157  *
158  * @param call_stack The list of widgets traversed to get to the
159  * dirty widget.
160  */
161  void add_to_dirty_list(const std::vector<widget*>& call_stack)
162  {
163  dirty_list_.push_back(call_stack);
164  }
165 
166  /** The status of the window. */
167  enum status {
168  NEW, /**< The window is new and not yet shown. */
169  SHOWING, /**< The window is being shown. */
170  REQUEST_CLOSE, /**< The window has been requested to be
171  * closed but still needs to evaluate the
172  * request.
173  */
174  CLOSED /**< The window has been closed. */
175  };
176 
177  /**
178  * Requests to close the window.
179  *
180  * At the moment the request is always honored but that might change in the
181  * future.
182  */
183  void close()
184  {
185  status_ = REQUEST_CLOSE;
186  }
187 
188  /**
189  * Helper class to block invalidate_layout.
190  *
191  * Some widgets can handling certain layout aspects without help. For
192  * example a listbox can handle hiding and showing rows without help but
193  * setting the visibility calls invalidate_layout(). When this blocker is
194  * Instantiated the call to invalidate_layout() becomes a nop.
195  *
196  * @note The class can't be used recursively.
197  */
199  {
200  public:
203 
204  private:
205  window& window_;
206  };
207 
208  /** Is invalidate_layout blocked, see invalidate_layout_blocker. */
210  {
211  return invalidate_layout_blocked_;
212  }
213 
214  /**
215  * Updates the size of the window.
216  *
217  * If the window has automatic placement set this function recalculates the
218  * window. To be used after creation and after modification or items which
219  * can have different sizes eg listboxes.
220  */
221  void invalidate_layout();
222 
223  /** See @ref widget::find_at. */
224  virtual widget* find_at(const point& coordinate,
225  const bool must_be_active) override;
226 
227  /** See @ref widget::find_at. */
228  virtual const widget* find_at(const point& coordinate,
229  const bool must_be_active) const override;
230 
231  /** Inherited from widget. */
233  {
234  return owner_;
235  }
236 
237  /** See @ref widget::find. */
238  widget* find(const std::string& id, const bool must_be_active) override;
239 
240  /** See @ref widget::find. */
241  const widget* find(const std::string& id,
242  const bool must_be_active) const override;
243 
244 #if 0
245  /** @todo Implement these functions. */
246  /**
247  * Register a widget that prevents easy closing.
248  *
249  * Duplicate registration are ignored. See click_dismiss_ for more info.
250  *
251  * @param id The id of the widget to register.
252  */
253  void add_click_dismiss_blocker(const std::string& id);
254 
255  /**
256  * Unregister a widget the prevents easy closing.
257  *
258  * Removing a non registered id is allowed but will do nothing. See
259  * click_dismiss_ for more info.
260  *
261  * @param id The id of the widget to register.
262  */
263  void remove_click_dismiss_blocker(const std::string& id);
264 #endif
265 
266  /**
267  * Does the window close easily?
268  *
269  * The behavior can change at run-time, but that might cause oddities
270  * with the easy close button (when one is needed).
271  *
272  * @returns Whether or not the window closes easily.
273  */
274  bool does_click_dismiss() const
275  {
276  return click_dismiss_ && !disable_click_dismiss();
277  }
278 
279  /**
280  * Disable the enter key.
281  *
282  * This is added to block dialogs from being closed automatically.
283  *
284  * @todo this function should be merged with the hotkey support once
285  * that has been added.
286  */
287  void set_enter_disabled(const bool enter_disabled)
288  {
289  enter_disabled_ = enter_disabled;
290  }
291 
292  /**
293  * Disable the escape key.
294  *
295  * This is added to block dialogs from being closed automatically.
296  *
297  * @todo this function should be merged with the hotkey support once
298  * that has been added.
299  */
300  void set_escape_disabled(const bool escape_disabled)
301  {
302  escape_disabled_ = escape_disabled;
303  }
304 
305  /**
306  * Initializes a linked size group.
307  *
308  * Note at least one of fixed_width or fixed_height must be true.
309  *
310  * @param id The id of the group.
311  * @param fixed_width Does the group have a fixed width?
312  * @param fixed_height Does the group have a fixed height?
313  */
314  void init_linked_size_group(const std::string& id,
315  const bool fixed_width,
316  const bool fixed_height);
317 
318  /**
319  * Is the linked size group defined for this window?
320  *
321  * @param id The id of the group.
322  *
323  * @returns True if defined, false otherwise.
324  */
325  bool has_linked_size_group(const std::string& id);
326 
327  /**
328  * Adds a widget to a linked size group.
329  *
330  * The group needs to exist, which is done by calling
331  * init_linked_size_group. A widget may only be member of one group.
332  * @todo Untested if a new widget is added after showing the widgets.
333  *
334  * @param id The id of the group.
335  * @param widget The widget to add to the group.
336  */
337  void add_linked_widget(const std::string& id, widget* widget);
338 
339  /**
340  * Removes a widget from a linked size group.
341  *
342  * The group needs to exist, which is done by calling
343  * init_linked_size_group. If the widget is no member of the group the
344  * function does nothing.
345  *
346  * @param id The id of the group.
347  * @param widget The widget to remove from the group.
348  */
349  void remove_linked_widget(const std::string& id, const widget* widget);
350 
351  /***** ***** ***** setters / getters for members ***** ****** *****/
352 
354  {
355  return video_;
356  }
357 
358  /**
359  * Sets there return value of the window.
360  *
361  * @param retval The return value for the window.
362  * @param close_window Close the window after setting the value.
363  */
364  void set_retval(const int retval, const bool close_window = true)
365  {
366  retval_ = retval;
367  if(close_window)
368  close();
369  }
370 
372  {
373  return retval_;
374  }
375 
377  {
378  owner_ = owner;
379  }
380 
381  void set_click_dismiss(const bool click_dismiss)
382  {
383  click_dismiss_ = click_dismiss;
384  }
385 
386  bool get_need_layout() const
387  {
388  return need_layout_;
389  }
390 
391  void set_variable(const std::string& key, const wfl::variant& value)
392  {
393  variables_.add(key, value);
394  set_is_dirty(true);
395  }
396  point get_linked_size(const std::string& linked_group_id) const
397  {
398  std::map<std::string, linked_size>::const_iterator it = linked_size_.find(linked_group_id);
399  if(it != linked_size_.end()) {
400  return point(it->second.width, it->second.height);
401  }
402 
403  return point(-1, -1);
404  }
405 
406  /**
407  * Sets the window's exit hook.
408  *
409  * A window will only close if this function returns true.
410  *
411  * @param func A function taking a window reference and returning a boolean result.
412  */
413  void set_exit_hook(std::function<bool(window&)> func)
414  {
415  exit_hook_ = func;
416  }
417 
418  void set_exit_hook_ok_only(std::function<bool(window&)> func)
419  {
420  exit_hook_ = [func](window& w)->bool { return w.get_retval() != OK || func(w); };
421  }
422 
423  /**
424  * Sets a callback that will be called after the window is drawn next time.
425  * The callback is automatically removed after calling it once.
426  * Useful if you need to do something after the window is drawn for the first time
427  * and it's timing-sensitive (i.e. pre_show is too early).
428  */
429  void set_callback_next_draw(std::function<void()> func)
430  {
431  callback_next_draw_ = func;
432  }
433 
434  enum show_mode {
439  };
440 
441 private:
442  /** Needed so we can change what's drawn on the screen. */
444 
445  /** The status of the window. */
447 
448  /**
449  * The mode in which the window is shown.
450  *
451  * This is used to determine whether or not to remove the tip.
452  */
454 
455  // return value of the window, 0 default.
456  int retval_;
457 
458  /** The dialog that owns the window. */
460 
461  /**
462  * When set the form needs a full layout redraw cycle.
463  *
464  * This happens when either a widget changes it's size or visibility or
465  * the window is resized.
466  */
468 
469  /** The variables of the canvas. */
471 
472  /** Is invalidate_layout blocked, see invalidate_layout_blocker. */
474 
475  /** Avoid drawing the window. */
477 
478  /** Whether the window should undraw the window using restorer_ */
479  bool restore_;
480 
481  /** Whether the window has other windows behind it */
483 
484  /** When the window closes this surface is used to undraw the window. */
486 
487  /** Do we wish to place the widget automatically? */
489 
490  /**
491  * Sets the horizontal placement.
492  *
493  * Only used if automatic_placement_ is true.
494  * The value should be a grid placement flag.
495  */
496  const unsigned horizontal_placement_;
497 
498  /**
499  * Sets the vertical placement.
500  *
501  * Only used if automatic_placement_ is true.
502  * The value should be a grid placement flag.
503  */
504  const unsigned vertical_placement_;
505 
506  /** The maximum width if automatic_placement_ is true. */
507  unsigned maximum_width_;
508 
509  /** The maximum height if automatic_placement_ is true. */
510  unsigned maximum_height_;
511 
512  /** The formula to calculate the x value of the dialog. */
514 
515  /** The formula to calculate the y value of the dialog. */
517 
518  /** The formula to calculate the width of the dialog. */
520 
521  /** The formula to calculate the height of the dialog. */
523 
524  /** The formula to determine whether the size is good. */
526 
527  /** The formula definitions available for the calculation formulas. */
529 
530  /** The settings for the tooltip. */
532 
533  /** The settings for the helptip. */
535 
536  /**
537  * Do we want to have easy close behavior?
538  *
539  * Easy closing means that whenever a mouse click is done the dialog will
540  * be closed. The widgets in the window may override this behavior by
541  * registering themselves as blockers. This is tested by the function
542  * disable_click_dismiss().
543  *
544  * The handling of easy close is done in the window, in order to do so a
545  * window either needs a click_dismiss or an ok button. Both will be hidden
546  * when not needed and when needed first the ok is tried and then the
547  * click_dismiss button. this allows adding a click_dismiss button to the
548  * window definition and use the ok from the window instance.
549  *
550  * @todo After testing the click dismiss feature it should be documented in
551  * the wiki.
552  */
554 
555  /** Disable the enter key see our setter for more info. */
557 
558  /** Disable the escape key see our setter for more info. */
560 
561  /**
562  * Helper struct to force widgets the have the same size.
563  *
564  * Widget which are linked will get the same width and/or height. This
565  * can especially be useful for listboxes, but can also be used for other
566  * applications.
567  */
568  struct linked_size
569  {
570  linked_size(const bool width = false, const bool height = false)
571  : widgets(), width(width ? 0 : -1), height(height ? 0 : -1)
572  {
573  }
574 
575  /** The widgets linked. */
576  std::vector<widget*> widgets;
577 
578  /** The current width of all widgets in the group, -1 if the width is not linked. */
579  int width;
580 
581  /** The current height of all widgets in the group, -1 if the height is not linked. */
582  int height;
583  };
584 
585  /** List of the widgets, whose size are linked together. */
586  std::map<std::string, linked_size> linked_size_;
587 
588  /** List of widgets in the tabbing order. */
589  std::vector<widget*> tab_order;
590 
591  /**
592  * Layouts the window.
593  *
594  * This part does the pre and post processing for the actual layout
595  * algorithm.
596  *
597  * See @ref layout_algorithm for more information.
598  */
599  void layout();
600 
601  /**
602  * Layouts the linked widgets.
603  *
604  * See @ref layout_algorithm for more information.
605  */
606  void layout_linked_widgets();
607 
608  /**
609  * Handles a mouse click event for dismissing the dialog.
610  *
611  * @param mouse_button_mask The SDL_BUTTON mask for the button used to
612  * dismiss the click. If the caller is from the
613  * keyboard code the value should be 0.
614  *
615  * @return Whether the event should be considered as
616  * handled.
617  */
618  bool click_dismiss(const int mouse_button_mask);
619 
620  /**
621  * The state of the mouse button.
622  *
623  * When click dismissing a dialog in the past the DOWN event was used.
624  * This lead to a bug [1]. The obvious change was to switch to the UP
625  * event, this lead to another bug; the dialog was directly dismissed.
626  * Since the game map code uses the UP and DOWN event to select a unit
627  * there is no simple solution.
628  *
629  * Upon entry this value stores the mouse button state at entry. When a
630  * button is DOWN and goes UP that button does \em not trigger a dismissal
631  * of the dialog, instead that button's down state is removed from this
632  * variable. Therefore the next UP event does dismiss the dialog.
633  *
634  * [1] https://gna.org/bugs/index.php?18970
635  */
637 
638 public:
639  /** Static type getter that does not rely on the widget being constructed. */
640  static const std::string& type();
641 
642 private:
643  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
644  virtual const std::string& get_control_type() const override;
645 
646  /**
647  * The list with dirty items in the window.
648  *
649  * When drawing only the widgets that are dirty are updated. The draw()
650  * function has more information about the dirty_list_.
651  */
652  std::vector<std::vector<widget*>> dirty_list_;
653 
654  /**
655  * In how many consecutive frames the window has changed. This is used to
656  * detect the situation where the title screen changes in every frame,
657  * forcing all other windows to redraw everything all the time.
658  */
659  unsigned int consecutive_changed_frames_ = 0u;
660 
661  /** Schedules windows on top of us (if any) to redraw. */
662  void redraw_windows_on_top() const;
663 
664  /**
665  * Finishes the initialization of the grid.
666  *
667  * @param content_grid The new contents for the content grid.
668  */
669  void finalize(const std::shared_ptr<builder_grid>& content_grid);
670 
671 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
672  debug_layout_graph* debug_layout_;
673 
674 public:
675  /** wrapper for debug_layout_graph::generate_dot_file. */
676  void generate_dot_file(const std::string& generator, const unsigned domain);
677 
678 private:
679 #else
680  void generate_dot_file(const std::string&, const unsigned)
681  {
682  }
683 #endif
684 
685  std::unique_ptr<event::distributor> event_distributor_;
686 
687 public:
688  /** Gets a reference to the window's distributor to allow some state peeking. */
690  {
691  return *event_distributor_;
692  }
693 
694  /** Returns the dialog mode for this window. */
695  show_mode mode() const
696  {
697  return show_mode_;
698  }
699 
700  // mouse and keyboard_capture should be renamed and stored in the
701  // dispatcher. Chaining probably should remain exclusive to windows.
702  void mouse_capture(const bool capture = true);
703  void keyboard_capture(widget* widget);
704 
705  /**
706  * Adds the widget to the keyboard chain.
707  *
708  * @todo rename to keyboard_add_to_chain.
709  * @param widget The widget to add to the chain. The widget
710  * should be valid widget, which hasn't been
711  * added to the chain yet.
712  */
713  void add_to_keyboard_chain(widget* widget);
714 
715  /**
716  * Remove the widget from the keyboard chain.
717  *
718  * @todo rename to keyboard_remove_from_chain.
719  *
720  * @param widget The widget to be removed from the chain.
721  */
722  void remove_from_keyboard_chain(widget* widget);
723 
724  /**
725  * Add the widget to the tabbing order
726  * @param widget The widget to be added to the tabbing order
727  * @param at A hint for where to place the widget in the tabbing order
728  */
729  void add_to_tab_order(widget* widget, int at = -1);
730 
731 private:
732  /***** ***** ***** signal handlers ***** ****** *****/
733 
734  void signal_handler_sdl_video_resize(const event::ui_event event,
735  bool& handled,
736  const point& new_size);
737 
738  /**
739  * The handler for the click dismiss mouse 'event'.
740  *
741  * @param event See @ref event::dispatcher::fire.
742  * @param handled See @ref event::dispatcher::fire.
743  * @param halt See @ref event::dispatcher::fire.
744  * @param mouse_button_mask Forwared to @ref click_dismiss.
745  */
746  void signal_handler_click_dismiss(const event::ui_event event,
747  bool& handled,
748  bool& halt,
749  const int mouse_button_mask);
750 
751  void signal_handler_sdl_key_down(const event::ui_event event,
752  bool& handled,
753  const SDL_Keycode key,
754  const SDL_Keymod mod,
755  bool handle_tab);
756 
757  void signal_handler_message_show_tooltip(const event::ui_event event,
758  bool& handled,
759  const event::message& message);
760 
761  void signal_handler_message_show_helptip(const event::ui_event event,
762  bool& handled,
763  const event::message& message);
764 
765  void signal_handler_request_placement(const event::ui_event event,
766  bool& handled);
767 
768  void signal_handler_close_window();
769 
770  std::function<bool(window&)> exit_hook_;
771  std::function<void()> callback_next_draw_;
772 };
773 
774 // }---------- DEFINITION ---------{
775 
777 {
778  explicit window_definition(const config& cfg);
779 
781  {
782  explicit resolution(const config& cfg);
783 
785  };
786 };
787 
788 // }------------ END --------------
789 
790 } // namespace gui2
bool click_dismiss_
Do we want to have easy close behavior?
Definition: window.hpp:553
wfl::function_symbol_table functions_
The formula definitions available for the calculation formulas.
Definition: window.hpp:528
void close()
Requests to close the window.
Definition: window.hpp:183
show_mode mode() const
Returns the dialog mode for this window.
Definition: window.hpp:695
void set_exit_hook_ok_only(std::function< bool(window &)> func)
Definition: window.hpp:418
bool does_click_dismiss() const
Does the window close easily?
Definition: window.hpp:274
std::function< bool(window &)> exit_hook_
Definition: window.hpp:770
Helper class to block invalidate_layout.
Definition: window.hpp:198
typed_formula< unsigned > h_
The formula to calculate the height of the dialog.
Definition: window.hpp:522
const unsigned horizontal_placement_
Sets the horizontal placement.
Definition: window.hpp:496
Visible container to hold multiple widgets.
Definition: panel.hpp:37
Main class to show messages to the user.
Definition: message.hpp:34
CVideo & video_
Needed so we can change what&#39;s drawn on the screen.
Definition: window.hpp:443
Definition: video.hpp:31
void generate_dot_file(const std::string &, const unsigned)
Definition: window.hpp:680
Helper struct to force widgets the have the same size.
Definition: window.hpp:568
Base class for all widgets.
Definition: widget.hpp:47
void set_click_dismiss(const bool click_dismiss)
Definition: window.hpp:381
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
Definition: window.hpp:300
typed_formula< unsigned > w_
The formula to calculate the width of the dialog.
Definition: window.hpp:519
status
The status of the window.
Definition: window.hpp:167
int mouse_button_state_
The state of the mouse button.
Definition: window.hpp:636
Generic file dialog.
Definition: field-fwd.hpp:22
int width
The current width of all widgets in the group, -1 if the width is not linked.
Definition: window.hpp:579
point get_linked_size(const std::string &linked_group_id) const
Definition: window.hpp:396
The message callbacks hold a reference to a message.
Definition: message.hpp:45
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.
Definition: window.hpp:446
std::vector< widget * > widgets
The widgets linked.
Definition: window.hpp:576
surface restorer_
When the window closes this surface is used to undraw the window.
Definition: window.hpp:485
bool suspend_drawing_
Avoid drawing the window.
Definition: window.hpp:476
bool enter_disabled_
Disable the enter key see our setter for more info.
Definition: window.hpp:556
bool invalidate_layout_blocked_
Is invalidate_layout blocked, see invalidate_layout_blocker.
Definition: window.hpp:473
bool need_layout_
When set the form needs a full layout redraw cycle.
Definition: window.hpp:467
typed_formula< bool > reevaluate_best_size_
The formula to determine whether the size is good.
Definition: window.hpp:525
builder_window::window_resolution::tooltip_info helptip_
The settings for the helptip.
Definition: window.hpp:534
bool is_toplevel_
Whether the window has other windows behind it.
Definition: window.hpp:482
The window is new and not yet shown.
Definition: window.hpp:168
typed_formula< unsigned > y_
The formula to calculate the y value of the dialog.
Definition: window.hpp:516
Basic template class to generate new items.
const bool automatic_placement_
Do we wish to place the widget automatically?
Definition: window.hpp:488
static void show_tooltip(const tooltip &tip)
Definition: tooltips.cpp:60
typed_formula< unsigned > x_
The formula to calculate the x value of the dialog.
Definition: window.hpp:513
std::vector< std::vector< widget * > > dirty_list_
The list with dirty items in the window.
Definition: window.hpp:652
bool escape_disabled_
Disable the escape key see our setter for more info.
Definition: window.hpp:559
Various uncategorised dialogs.
CVideo & video()
Definition: window.hpp:353
int get_retval()
Definition: window.hpp:371
linked_size(const bool width=false, const bool height=false)
Definition: window.hpp:570
void add_to_dirty_list(const std::vector< widget *> &call_stack)
Adds an item to the dirty_list_.
Definition: window.hpp:161
Helper to implement private functions without modifying the header.
unsigned maximum_height_
The maximum height if automatic_placement_ is true.
Definition: window.hpp:510
unsigned maximum_width_
The maximum width if automatic_placement_ is true.
Definition: window.hpp:507
window * build(const builder_window::window_resolution *definition)
Builds a window.
const unsigned vertical_placement_
Sets the vertical placement.
Definition: window.hpp:504
std::vector< widget * > tab_order
List of widgets in the tabbing order.
Definition: window.hpp:589
Holds a 2D point.
Definition: point.hpp:23
int w
bool invalidate_layout_blocked() const
Is invalidate_layout blocked, see invalidate_layout_blocker.
Definition: window.hpp:209
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition: window.hpp:364
builder_window::window_resolution::tooltip_info tooltip_
The settings for the tooltip.
Definition: window.hpp:531
show_mode show_mode_
The mode in which the window is shown.
Definition: window.hpp:453
void set_exit_hook(std::function< bool(window &)> func)
Sets the window&#39;s exit hook.
Definition: window.hpp:413
bool find(E event, F functor)
Tests whether an event handler is available.
Helper struct to store information about the tips.
bool restore_
Whether the window should undraw the window using restorer_.
Definition: window.hpp:479
bool get_need_layout() const
Definition: window.hpp:386
Abstract base class for all modal dialogs.
std::unique_ptr< event::distributor > event_distributor_
Definition: window.hpp:685
Class to show the tips.
Definition: tooltip.cpp:71
point resolution()
Definition: general.cpp:373
dialogs::modal_dialog * owner_
The dialog that owns the window.
Definition: window.hpp:459
retval
Default window/dialog return values.
Definition: retval.hpp:28
dialogs::modal_dialog * dialog()
Inherited from widget.
Definition: window.hpp:232
Dialog was closed with the OK button.
Definition: retval.hpp:34
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.
Definition: window.hpp:582
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
std::shared_ptr< halo_record > handle
Definition: halo.hpp:31
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
std::shared_ptr< builder_grid > builder_grid_ptr
The window is being shown.
Definition: window.hpp:169
std::map< std::string, linked_size > linked_size_
List of the widgets, whose size are linked together.
Definition: window.hpp:586
wfl::map_formula_callable variables_
The variables of the canvas.
Definition: window.hpp:470
static std::deque< std::string > call_stack
Definition: function.cpp:39
ui_event
The event send to the dispatcher.
Definition: handler.hpp:55
void set_callback_next_draw(std::function< void()> func)
Sets a callback that will be called after the window is drawn next time.
Definition: window.hpp:429
void set_owner(dialogs::modal_dialog *owner)
Definition: window.hpp:376
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
Definition: tooltip.cpp:154
const event::distributor & get_distributor() const
Gets a reference to the window&#39;s distributor to allow some state peeking.
Definition: window.hpp:689
void set_variable(const std::string &key, const wfl::variant &value)
Definition: window.hpp:391
std::function< void()> callback_next_draw_
Definition: window.hpp:771
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
Definition: window.hpp:287