The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
window.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 #ifndef GUI_WIDGETS_WINDOW_HPP_INCLUDED
22 #define GUI_WIDGETS_WINDOW_HPP_INCLUDED
23 
24 #include "cursor.hpp"
25 #include "formula/callable.hpp"
26 #include "formula/function.hpp"
30 #include "gui/widgets/panel.hpp"
31 #include "sdl/utils.hpp"
32 
33 #include <map>
34 #include <string>
35 #include <vector>
36 
37 class CVideo;
38 
39 namespace boost { template <class T> class intrusive_ptr; }
40 namespace gui2 { class twidget; }
41 namespace gui2 { namespace event { struct tmessage; } }
42 namespace gui2 { struct tpoint; }
43 
44 namespace gui2
45 {
46 
47 // ------------ WIDGET -----------{
48 
49 class tdialog;
50 class tdebug_layout_graph;
51 class tpane;
52 
53 namespace event
54 {
55 class tdistributor;
56 } // namespace event
57 
58 /**
59  * base class of top level items, the only item
60  * which needs to store the final canvases to draw on
61  */
62 class twindow : public tpanel, public cursor::setter
63 {
64  friend class tdebug_layout_graph;
66  friend struct twindow_implementation;
68  friend class tpane;
69 
70 public:
76  tformula<bool> reevaluate_best_size,
77  const game_logic::function_symbol_table& functions,
78  const bool automatic_placement,
79  const unsigned horizontal_placement,
80  const unsigned vertical_placement,
81  const unsigned maximum_width,
82  const unsigned maximum_height,
83  const std::string& definition,
85  const twindow_builder::tresolution::ttip& helptip);
86 
87  ~twindow();
88 
89  /**
90  * Update the size of the screen variables in settings.
91  *
92  * Before a window gets build the screen sizes need to be updated. This
93  * function does that. It's only done when no other window is active, if
94  * another window is active it already updates the sizes with it's resize
95  * event.
96  */
97  static void update_screen_size();
98 
99  /**
100  * Returns the instance of a window.
101  *
102  * @param handle The instance id of the window.
103  *
104  * @returns The window or nullptr.
105  */
106  static twindow* window_instance(const unsigned handle);
107 
108  /**
109  * Default return values.
110  *
111  * These values are named return values and most are assigned to a widget
112  * automatically when using a certain id for that widget. The automatic
113  * return values are always a negative number.
114  *
115  * Note this might be moved somewhere else since it will force people to
116  * include the button, while it should be and implementation detail for most
117  * callers.
118  */
119  enum tretval {
120  NONE = 0, /**<
121  * Dialog is closed with no return
122  * value, should be rare but eg a
123  * message popup can do it.
124  */
125  OK = -1, /**< Dialog is closed with ok button. */
126  CANCEL = -2, /**<
127  * Dialog is closed with the cancel
128  * button.
129  */
130  AUTO_CLOSE = -3 /**<
131  * The dialog is closed automatically
132  * since it's timeout has been
133  * triggered.
134  */
135  };
136 
137  /** Gets the retval for the default buttons. */
138  static tretval get_retval_by_id(const std::string& id);
139 
140  /**
141  * @todo Clean up the show functions.
142  *
143  * the show functions are a bit messy and can use a proper cleanup.
144  */
145 
146  /**
147  * Shows the window.
148  *
149  * @param restore Restore the screenarea the window was on
150  * after closing it?
151  * @param auto_close_timeout The time in ms after which the window will
152  * automatically close, if 0 it doesn't close.
153  * @note the timeout is a minimum time and
154  * there's no quarantee about how fast it closes
155  * after the minimum.
156  *
157  * @returns The close code of the window, predefined
158  * values are listed in tretval.
159  */
160  int show(const bool restore = true, const unsigned auto_close_timeout = 0);
161 
162  /**
163  * Shows the window as a tooltip.
164  *
165  * A tooltip can't be interacted with and is just shown.
166  *
167  * @todo implement @p auto_close_timeout.
168  *
169  * @p auto_close_timeout The time in ms after which the window will
170  * automatically close, if 0 it doesn't close.
171  * @note the timeout is a minimum time and
172  * there's no guarantee about how fast it closes
173  * after the minimum.
174  */
175  void show_tooltip(/*const unsigned auto_close_timeout = 0*/);
176 
177  /**
178  * Shows the window non modal.
179  *
180  * A tooltip can be interacted with unlike the tooltip.
181  *
182  * @todo implement @p auto_close_timeout.
183  *
184  * @p auto_close_timeout The time in ms after which the window will
185  * automatically close, if 0 it doesn't close.
186  * @note the timeout is a minimum time and
187  * there's no guarantee about how fast it closes
188  * after the minimum.
189  */
190  void show_non_modal(/*const unsigned auto_close_timeout = 0*/);
191 
192  /**
193  * Draws the window.
194  *
195  * This routine draws the window if needed, it's called from the event
196  * handler. This is done by a drawing event. When a window is shown it
197  * manages an SDL timer which fires a drawing event every X milliseconds,
198  * that event calls this routine. Don't call it manually.
199  */
200  void draw();
201 
202  /**
203  * Undraws the window.
204  */
205  void undraw();
206 
207  /**
208  * Adds an item to the dirty_list_.
209  *
210  * @param call_stack The list of widgets traversed to get to the
211  * dirty widget.
212  */
213  void add_to_dirty_list(const std::vector<twidget*>& call_stack)
214  {
215  dirty_list_.push_back(call_stack);
216  }
217 
218  /** The status of the window. */
219  enum tstatus {
220  NEW, /**< The window is new and not yet shown. */
221  SHOWING, /**< The window is being shown. */
222  REQUEST_CLOSE, /**< The window has been requested to be
223  * closed but still needs to evaluate the
224  * request.
225  */
226  CLOSED /**< The window has been closed. */
227  };
228 
229  /**
230  * Requests to close the window.
231  *
232  * At the moment the request is always honored but that might change in the
233  * future.
234  */
235  void close()
236  {
238  }
239 
240  /**
241  * Helper class to block invalidate_layout.
242  *
243  * Some widgets can handling certain layout aspects without help. For
244  * example a listbox can handle hiding and showing rows without help but
245  * setting the visibility calls invalidate_layout(). When this blocker is
246  * Instantiated the call to invalidate_layout() becomes a nop.
247  *
248  * @note The class can't be used recursively.
249  */
251  {
252  public:
255 
256  private:
258  };
259 
260  /**
261  * Updates the size of the window.
262  *
263  * If the window has automatic placement set this function recalculates the
264  * window. To be used after creation and after modification or items which
265  * can have different sizes eg listboxes.
266  */
267  void invalidate_layout();
268 
269  /** Inherited from tevent_handler. */
271  {
272  return *this;
273  }
274 
275  /** Inherited from tevent_handler. */
276  const twindow& get_window() const
277  {
278  return *this;
279  }
280 
281  /** See @ref twidget::find_at. */
282  virtual twidget* find_at(const tpoint& coordinate,
283  const bool must_be_active) override;
284 
285  /** See @ref twidget::find_at. */
286  virtual const twidget* find_at(const tpoint& coordinate,
287  const bool must_be_active) const override;
288 
289  /** Inherited from twidget. */
291  {
292  return owner_;
293  }
294 
295  /** See @ref twidget::find. */
296  twidget* find(const std::string& id, const bool must_be_active) override;
297 
298  /** See @ref twidget::find. */
299  const twidget* find(const std::string& id,
300  const bool must_be_active) const override;
301 
302 #if 0
303  /** @todo Implement these functions. */
304  /**
305  * Register a widget that prevents easy closing.
306  *
307  * Duplicate registration are ignored. See click_dismiss_ for more info.
308  *
309  * @param id The id of the widget to register.
310  */
311  void add_click_dismiss_blocker(const std::string& id);
312 
313  /**
314  * Unregister a widget the prevents easy closing.
315  *
316  * Removing a non registered id is allowed but will do nothing. See
317  * click_dismiss_ for more info.
318  *
319  * @param id The id of the widget to register.
320  */
321  void remove_click_dismiss_blocker(const std::string& id);
322 #endif
323 
324  /**
325  * Does the window close easily?
326  *
327  * The behavior can change at run-time, but that might cause oddities
328  * with the easy close button (when one is needed).
329  *
330  * @returns Whether or not the window closes easily.
331  */
332  bool does_click_dismiss() const
333  {
335  }
336 
337  /**
338  * Disable the enter key.
339  *
340  * This is added to block dialogs from being closed automatically.
341  *
342  * @todo this function should be merged with the hotkey support once
343  * that has been added.
344  */
345  void set_enter_disabled(const bool enter_disabled)
346  {
347  enter_disabled_ = enter_disabled;
348  }
349 
350  /**
351  * Disable the escape key.
352  *
353  * This is added to block dialogs from being closed automatically.
354  *
355  * @todo this function should be merged with the hotkey support once
356  * that has been added.
357  */
358  void set_escape_disabled(const bool escape_disabled)
359  {
360  escape_disabled_ = escape_disabled;
361  }
362 
363  /**
364  * Initializes a linked size group.
365  *
366  * Note at least one of fixed_width or fixed_height must be true.
367  *
368  * @param id The id of the group.
369  * @param fixed_width Does the group have a fixed width?
370  * @param fixed_height Does the group have a fixed height?
371  */
372  void init_linked_size_group(const std::string& id,
373  const bool fixed_width,
374  const bool fixed_height);
375 
376  /**
377  * Is the linked size group defined for this window?
378  *
379  * @param id The id of the group.
380  *
381  * @returns True if defined, false otherwise.
382  */
383  bool has_linked_size_group(const std::string& id);
384 
385  /**
386  * Adds a widget to a linked size group.
387  *
388  * The group needs to exist, which is done by calling
389  * init_linked_size_group. A widget may only be member of one group.
390  * @todo Untested if a new widget is added after showing the widgets.
391  *
392  * @param id The id of the group.
393  * @param widget The widget to add to the group.
394  */
395  void add_linked_widget(const std::string& id, twidget* widget);
396 
397  /**
398  * Removes a widget from a linked size group.
399  *
400  * The group needs to exist, which is done by calling
401  * init_linked_size_group. If the widget is no member of the group the
402  * function does nothing.
403  *
404  * @param id The id of the group.
405  * @param widget The widget to remove from the group.
406  */
407  void remove_linked_widget(const std::string& id, const twidget* widget);
408 
409  /***** ***** ***** setters / getters for members ***** ****** *****/
410 
412  {
413  return video_;
414  }
415 
416  /**
417  * Sets there return value of the window.
418  *
419  * @param retval The return value for the window.
420  * @param close_window Close the window after setting the value.
421  */
422  void set_retval(const int retval, const bool close_window = true)
423  {
424  retval_ = retval;
425  if(close_window)
426  close();
427  }
428 
429  void set_owner(tdialog* owner)
430  {
431  owner_ = owner;
432  }
433 
435  {
437  }
438 
439  static void set_sunset(const unsigned interval)
440  {
441  sunset_ = interval ? interval : 5;
442  }
443 
444  bool get_need_layout() const
445  {
446  return need_layout_;
447  }
448 
449  void set_variable(const std::string& key, const variant& value)
450  {
451  variables_.add(key, value);
452  set_is_dirty(true);
453  }
454  tpoint get_linked_size(const std::string& linked_group_id) const
455  {
456  std::map<std::string, tlinked_size>::const_iterator it = linked_size_.find(linked_group_id);
457  if(it != linked_size_.end()) {
458  return tpoint(it->second.width, it->second.height);
459  }
460  else {
461  return tpoint(-1, -1);
462  }
463  }
464 private:
465  /** Needed so we can change what's drawn on the screen. */
467 
468  /** The status of the window. */
470 
471  enum tshow_mode {
475  };
476 
477  /**
478  * The mode in which the window is shown.
479  *
480  * This is used to determine whether or not to remove the tip.
481  */
483 
484  // return value of the window, 0 default.
485  int retval_;
486 
487  /** The dialog that owns the window. */
489 
490  /**
491  * When set the form needs a full layout redraw cycle.
492  *
493  * This happens when either a widget changes it's size or visibility or
494  * the window is resized.
495  */
497 
498  /** The variables of the canvas. */
500 
501  /** Is invalidate layout blocked see tinvalidate_layout_blocker. */
503 
504  /** Avoid drawing the window. */
506 
507  /** Whether the window should undraw the window using restorer_ */
508  bool restore_;
509 
510  /** When the window closes this surface is used to undraw the window. */
512 
513  /** Do we wish to place the widget automatically? */
515 
516  /**
517  * Sets the horizontal placement.
518  *
519  * Only used if automatic_placement_ is true.
520  * The value should be a tgrid placement flag.
521  */
522  const unsigned horizontal_placement_;
523 
524  /**
525  * Sets the vertical placement.
526  *
527  * Only used if automatic_placement_ is true.
528  * The value should be a tgrid placement flag.
529  */
530  const unsigned vertical_placement_;
531 
532  /** The maximum width if automatic_placement_ is true. */
533  unsigned maximum_width_;
534 
535  /** The maximum height if automatic_placement_ is true. */
536  unsigned maximum_height_;
537 
538  /** The formula to calulate the x value of the dialog. */
540 
541  /** The formula to calulate the y value of the dialog. */
543 
544  /** The formula to calulate the width of the dialog. */
546 
547  /** The formula to calulate the height of the dialog. */
549 
550  /** The formula to determine whether the size is good. */
552 
553  /** The formula definitions available for the calulation formulas. */
555 
556  /** The settings for the tooltip. */
558 
559  /** The settings for the helptip. */
561 
562  /**
563  * Do we want to have easy close behavior?
564  *
565  * Easy closing means that whenever a mouse click is done the dialog will
566  * be closed. The widgets in the window may override this behavior by
567  * registering themselves as blockers. This is tested by the function
568  * disable_click_dismiss().
569  *
570  * The handling of easy close is done in the window, in order to do so a
571  * window either needs a click_dismiss or an ok button. Both will be hidden
572  * when not needed and when needed first the ok is tried and then the
573  * click_dismiss button. this allows adding a click_dismiss button to the
574  * window definition and use the ok from the window instance.
575  *
576  * @todo After testing the click dismiss feature it should be documented in
577  * the wiki.
578  */
580 
581  /** Disable the enter key see our setter for more info. */
583 
584  /** Disable the escape key see our setter for more info. */
586 
587  /**
588  * Controls the sunset feature.
589  *
590  * If this value is not 0 it will darken the entire screen every
591  * sunset_th drawing request that nothing has been modified. It's a debug
592  * feature.
593  */
594  static unsigned sunset_;
595 
596  /**
597  * Helper struct to force widgets the have the same size.
598  *
599  * Widget which are linked will get the same width and/or height. This
600  * can especially be useful for listboxes, but can also be used for other
601  * applications.
602  */
604  {
605  tlinked_size(const bool width = false, const bool height = false)
606  : widgets(), width(width ? 0 : -1), height(height ? 0 : -1)
607  {
608  }
609 
610  /** The widgets linked. */
611  std::vector<twidget*> widgets;
612 
613  /** the current width of all widgets in the intis group, -1 if the width is not linked*/
614  int width;
615 
616  /** the current height of all widgets in the intis group, -1 if the height is not linked*/
617  int height;
618  };
619 
620  /** List of the widgets, whose size are linked together. */
621  std::map<std::string, tlinked_size> linked_size_;
622 
623  /**
624  * Layouts the window.
625  *
626  * This part does the pre and post processing for the actual layout
627  * algorithm.
628  *
629  * See @ref layout_algorithm for more information.
630  */
631  void layout();
632 
633  /**
634  * Layouts the linked widgets.
635  *
636  * See @ref layout_algorithm for more information.
637  */
638  void layout_linked_widgets();
639 
640  /**
641  * Handles a mouse click event for dismissing the dialogue.
642  *
643  * @param mouse_button_mask The SDL_BUTTON mask for the button used to
644  * dismiss the click. If the caller is from the
645  * keyboard code the value should be 0.
646  *
647  * @return Whether the event should be considered as
648  * handled.
649  */
650  bool click_dismiss(const Uint8 mouse_button_mask);
651 
652  /**
653  * The state of the mouse button.
654  *
655  * When click dismissing a dialogue in the past the DOWN event was used.
656  * This lead to a bug [1]. The obvious change was to switch to the UP
657  * event, this lead to another bug; the dialogue was directly dismissed.
658  * Since the game map code uses the UP and DOWN event to select a unit
659  * there is no simple solution.
660  *
661  * Upon entry this value stores the mouse button state at entry. When a
662  * button is DOWN and goes UP that button does \em not trigger a dismissal
663  * of the dialogue, instead that button's down state is removed from this
664  * variable. Therefore the next UP event does dismiss the dialogue.
665  *
666  * [1] https://gna.org/bugs/index.php?18970
667  */
669 
670  /** See @ref tcontrol::get_control_type. */
671  virtual const std::string& get_control_type() const override;
672 
673  /**
674  * The list with dirty items in the window.
675  *
676  * When drawing only the widgets that are dirty are updated. The draw()
677  * function has more information about the dirty_list_.
678  */
679  std::vector<std::vector<twidget*> > dirty_list_;
680 
681  /**
682  * Finishes the initialization of the grid.
683  *
684  * @param content_grid The new contents for the content grid.
685  */
686  void finalize(const boost::intrusive_ptr<tbuilder_grid>& content_grid);
687 
688 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
689  tdebug_layout_graph* debug_layout_;
690 
691 public:
692  /** wrapper for tdebug_layout_graph::generate_dot_file. */
693  void generate_dot_file(const std::string& generator, const unsigned domain);
694 
695 private:
696 #else
697  void generate_dot_file(const std::string&, const unsigned)
698  {
699  }
700 #endif
701 
702  event::tdistributor* event_distributor_;
703 
704 public:
705  // mouse and keyboard_capture should be renamed and stored in the
706  // dispatcher. Chaining probably should remain exclusive to windows.
707  void mouse_capture(const bool capture = true);
708  void keyboard_capture(twidget* widget);
709 
710  /**
711  * Adds the widget to the keyboard chain.
712  *
713  * @todo rename to keyboard_add_to_chain.
714  * @param widget The widget to add to the chain. The widget
715  * should be valid widget, which hasn't been
716  * added to the chain yet.
717  */
718  void add_to_keyboard_chain(twidget* widget);
719 
720  /**
721  * Remove the widget from the keyboard chain.
722  *
723  * @todo rename to keyboard_remove_from_chain.
724  *
725  * @param widget The widget to be removed from the chain.
726  */
727  void remove_from_keyboard_chain(twidget* widget);
728 
729 private:
730  /***** ***** ***** signal handlers ***** ****** *****/
731 
733  bool& handled,
734  const tpoint& new_size);
735 
736  /**
737  * The handler for the click dismiss mouse 'event'.
738  *
739  * @param event See @ref event::tdispatcher::fire.
740  * @param handled See @ref event::tdispatcher::fire.
741  * @param halt See @ref event::tdispatcher::fire.
742  * @param mouse_button_mask Forwared to @ref click_dismiss.
743  */
745  bool& handled,
746  bool& halt,
747  const Uint8 mouse_button_mask);
748 
750  bool& handled,
751  const SDLKey key);
752 
754  bool& handled,
755  event::tmessage& message);
756 
758  bool& handled,
759  event::tmessage& message);
760 
762  bool& handled);
763 };
764 
765 // }---------- DEFINITION ---------{
766 
768 {
769  explicit twindow_definition(const config& cfg);
770 
772  {
773  explicit tresolution(const config& cfg);
774 
776  };
777 };
778 
779 // }------------ END --------------
780 
781 } // namespace gui2
782 
783 #endif
bool escape_disabled_
Disable the escape key see our setter for more info.
Definition: window.hpp:585
tdialog * owner_
The dialog that owns the window.
Definition: window.hpp:488
unsigned maximum_height_
The maximum height if automatic_placement_ is true.
Definition: window.hpp:536
twidget * find(const std::string &id, const bool must_be_active) override
See twidget::find.
Definition: window.cpp:958
tformula< unsigned > x_
The formula to calulate the x value of the dialog.
Definition: window.hpp:539
bool enter_disabled_
Disable the enter key see our setter for more info.
Definition: window.hpp:582
bool does_click_dismiss() const
Does the window close easily?
Definition: window.hpp:332
void remove_from_keyboard_chain(twidget *widget)
Remove the widget from the keyboard chain.
Definition: window.cpp:1406
CVideo & video()
Definition: window.hpp:411
The dialog is closed automatically since it's timeout has been triggered.
Definition: window.hpp:130
rng * generator
This generator is automatically synced during synced context.
Definition: random_new.cpp:52
tretval
Default return values.
Definition: window.hpp:119
tstatus
The status of the window.
Definition: window.hpp:219
Definition: video.hpp:58
friend class tdebug_layout_graph
Definition: window.hpp:64
game_logic::function_symbol_table functions_
The formula definitions available for the calulation formulas.
Definition: window.hpp:554
std::vector< twidget * > widgets
The widgets linked.
Definition: window.hpp:611
twindow_builder::tresolution::ttip tooltip_
The settings for the tooltip.
Definition: window.hpp:557
void signal_handler_message_show_helptip(const event::tevent event, bool &handled, event::tmessage &message)
Definition: window.cpp:1475
std::vector< std::vector< twidget * > > dirty_list_
The list with dirty items in the window.
Definition: window.hpp:679
void signal_handler_sdl_key_down(const event::tevent event, bool &handled, const SDLKey key)
Definition: window.cpp:1438
const unsigned horizontal_placement_
Sets the horizontal placement.
Definition: window.hpp:522
static void set_sunset(const unsigned interval)
Definition: window.hpp:439
void add_to_keyboard_chain(twidget *widget)
Adds the widget to the keyboard chain.
Definition: window.cpp:1400
static void update_screen_size()
Update the size of the screen variables in settings.
Definition: window.cpp:459
The window has been requested to be closed but still needs to evaluate the request.
Definition: window.hpp:222
surface restorer_
When the window closes this surface is used to undraw the window.
Definition: window.hpp:511
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
Definition: window.hpp:358
static tretval get_retval_by_id(const std::string &id)
Gets the retval for the default buttons.
Definition: window.cpp:493
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
void undraw()
Undraws the window.
Definition: window.cpp:917
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
Definition: window.cpp:1253
std::map< std::string, tlinked_size > linked_size_
List of the widgets, whose size are linked together.
Definition: window.hpp:621
void set_is_dirty(const bool is_dirty)
Definition: widget.cpp:435
static twindow * window_instance(const unsigned handle)
Returns the instance of a window.
Definition: window.cpp:454
#define SDLKey
Definition: compat.hpp:29
The window is new and not yet shown.
Definition: window.hpp:220
The window is being shown.
Definition: window.hpp:221
bool suspend_drawing_
Avoid drawing the window.
Definition: window.hpp:505
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
Definition: window.hpp:345
void signal_handler_sdl_video_resize(const event::tevent event, bool &handled, const tpoint &new_size)
Definition: window.cpp:1412
void finalize(const boost::intrusive_ptr< tbuilder_grid > &content_grid)
Finishes the initialization of the grid.
Definition: window.cpp:1301
tdialog * dialog()
Inherited from twidget.
Definition: window.hpp:290
bool disable_click_dismiss() const override
See twidget::disable_click_dismiss.
Definition: container.cpp:203
Dialog is closed with ok button.
Definition: window.hpp:125
void signal_handler_click_dismiss(const event::tevent event, bool &handled, bool &halt, const Uint8 mouse_button_mask)
The handler for the click dismiss mouse 'event'.
Definition: window.cpp:1427
Dialog is closed with no return value, should be rare but eg a message popup can do it...
Definition: window.hpp:120
void draw()
Draws the window.
Definition: window.cpp:738
Abstract base class for all dialogs.
Definition: dialog.hpp:121
void show_tooltip()
Shows the window as a tooltip.
Definition: window.cpp:547
int show(const bool restore=true, const unsigned auto_close_timeout=0)
Shows the window.
Definition: window.cpp:592
Dialog is closed with the cancel button.
Definition: window.hpp:126
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1858
Uint8 mouse_button_state_
The state of the mouse button.
Definition: window.hpp:668
GLsizei const GLfloat * value
Definition: glew.h:1817
const t_string & tooltip() const
Definition: control.hpp:260
void set_owner(tdialog *owner)
Definition: window.hpp:429
void set_variable(const std::string &key, const variant &value)
Definition: window.hpp:449
twindow_builder::tresolution::ttip helptip_
The settings for the helptip.
Definition: window.hpp:560
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition: window.hpp:422
void generate_dot_file(const std::string &, const unsigned)
Definition: window.hpp:697
void init_linked_size_group(const std::string &id, const bool fixed_width, const bool fixed_height)
Initializes a linked size group.
Definition: window.cpp:969
tformula< unsigned > h_
The formula to calulate the height of the dialog.
Definition: window.hpp:548
tevent
The event send to the dispatcher.
Definition: handler.hpp:54
void close()
Requests to close the window.
Definition: window.hpp:235
void signal_handler_request_placement(const event::tevent event, bool &handled)
Definition: window.cpp:1489
Visible container to hold multiple widgets.
Definition: panel.hpp:34
tformula< bool > reevaluate_best_size_
The formula to determine whether the size is good.
Definition: window.hpp:551
void layout()
Layouts the window.
Definition: window.cpp:1013
bool invalidate_layout_blocked_
Is invalidate layout blocked see tinvalidate_layout_blocker.
Definition: window.hpp:502
const twindow & get_window() const
Inherited from tevent_handler.
Definition: window.hpp:276
The window has been closed.
Definition: window.hpp:226
bool restore_
Whether the window should undraw the window using restorer_.
Definition: window.hpp:508
virtual twidget * find_at(const tpoint &coordinate, const bool must_be_active) override
See twidget::find_at.
Definition: window.cpp:947
bool get_need_layout() const
Definition: window.hpp:444
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:5910
Holds a 2D point.
Definition: point.hpp:24
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
Helper struct to store information about the tips.
map_formula_callable & add(const std::string &key, const variant &value)
Definition: formula.cpp:41
tshow_mode show_mode_
The mode in which the window is shown.
Definition: window.hpp:482
void set_click_dismiss(const bool click_dismiss)
Definition: window.hpp:434
void show_non_modal()
Shows the window non modal.
Definition: window.cpp:569
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1220
tformula< unsigned > y_
The formula to calulate the y value of the dialog.
Definition: window.hpp:542
Helper class to block invalidate_layout.
Definition: window.hpp:250
void add_to_dirty_list(const std::vector< twidget * > &call_stack)
Adds an item to the dirty_list_.
Definition: window.hpp:213
bool has_linked_size_group(const std::string &id)
Is the linked size group defined for this window?
Definition: window.cpp:979
void add_linked_widget(const std::string &id, twidget *widget)
Adds a widget to a linked size group.
Definition: window.cpp:984
twindow_definition(const config &cfg)
Definition: window.cpp:1520
tstatus status_
The status of the window.
Definition: window.hpp:469
Helper to implement private functions without modifying the header.
cl_event event
Definition: glew.h:3070
const unsigned vertical_placement_
Sets the vertical placement.
Definition: window.hpp:530
Helper struct to force widgets the have the same size.
Definition: window.hpp:603
Base class for all widgets.
Definition: widget.hpp:49
void mouse_capture(const bool capture=true)
Definition: window.cpp:1388
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
twindow & get_window()
Inherited from tevent_handler.
Definition: window.hpp:270
unsigned maximum_width_
The maximum width if automatic_placement_ is true.
Definition: window.hpp:533
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1220
int height
the current height of all widgets in the intis group, -1 if the height is not linked ...
Definition: window.hpp:617
void layout_linked_widgets()
Layouts the linked widgets.
Definition: window.cpp:1194
const bool automatic_placement_
Do we wish to place the widget automatically?
Definition: window.hpp:514
int width
the current width of all widgets in the intis group, -1 if the width is not linked ...
Definition: window.hpp:614
void keyboard_capture(twidget *widget)
Definition: window.cpp:1394
twindow(CVideo &video, tformula< unsigned > x, tformula< unsigned > y, tformula< unsigned > w, tformula< unsigned > h, tformula< bool > reevaluate_best_size, const game_logic::function_symbol_table &functions, const bool automatic_placement, const unsigned horizontal_placement, const unsigned vertical_placement, const unsigned maximum_width, const unsigned maximum_height, const std::string &definition, const twindow_builder::tresolution::ttip &tooltip, const twindow_builder::tresolution::ttip &helptip)
< Needs to be initialised in show.
Definition: window.cpp:292
tformula< unsigned > w_
The formula to calulate the width of the dialog.
Definition: window.hpp:545
friend twindow * build(CVideo &, const twindow_builder::tresolution *)
Builds a window.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
void remove_linked_widget(const std::string &id, const twidget *widget)
Removes a widget from a linked size group.
Definition: window.cpp:995
CVideo & video_
Needed so we can change what's drawn on the screen.
Definition: window.hpp:466
tpoint get_linked_size(const std::string &linked_group_id) const
Definition: window.hpp:454
game_logic::map_formula_callable variables_
The variables of the canvas.
Definition: window.hpp:499
tlinked_size(const bool width=false, const bool height=false)
Definition: window.hpp:605
bool click_dismiss_
Do we want to have easy close behavior?
Definition: window.hpp:579
GLsizei const GLcharARB ** string
Definition: glew.h:4503
bool click_dismiss(const Uint8 mouse_button_mask)
Handles a mouse click event for dismissing the dialogue.
Definition: window.cpp:1240
void signal_handler_message_show_tooltip(const event::tevent event, bool &handled, event::tmessage &message)
Definition: window.cpp:1461
event::tdistributor * event_distributor_
Definition: window.hpp:702
void invalidate_layout()
Updates the size of the window.
Definition: window.cpp:941
static unsigned sunset_
Controls the sunset feature.
Definition: window.hpp:594
boost::shared_ptr< halo_record > handle
Definition: halo.hpp:34
bool need_layout_
When set the form needs a full layout redraw cycle.
Definition: window.hpp:496