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