The Battle for Wesnoth  1.15.5+dev
widget.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 #pragma once
16 
18 #include "sdl/point.hpp"
20 #include "scripting/lua_ptr.hpp"
21 
22 #include "color.hpp"
23 
24 #include <string>
25 
26 class surface;
27 
28 typedef std::map<std::string, t_string> string_map;
29 
30 namespace gui2
31 {
32 
33 struct builder_widget;
34 class window;
35 class grid;
36 
37 namespace iteration
38 {
39 class walker_base;
40 } // namespace iteration
41 
42 /**
43  * Base class for all widgets.
44  *
45  * From this abstract all other widgets should derive. It contains the minimal
46  * info needed for a real widget and some pure abstract functions which need to
47  * be implemented by classes deriving from this class.
48  */
49 class widget : public event_executor, public event::dispatcher, public enable_lua_ptr<widget>
50 {
51  friend class debug_layout_graph;
52  friend class window; // needed for modifying the layout_size.
53 
54 
55  /***** ***** ***** ***** ***** Types. ***** ***** ***** ***** *****/
56 
57 public:
58  /** Visibility settings done by the user. */
59  enum class visibility
60  {
61  /**
62  * The user sets the widget visible, that means:
63  * * The widget is visible.
64  * * @ref find_at always 'sees' the widget (the active flag is
65  * tested later).
66  * * The widget (if active) handles events (and sends events to
67  * its children).
68  * * The widget is drawn (and sends the call to
69  * @ref populate_dirty_list to children).
70  */
71  visible,
72 
73  /**
74  * The user sets the widget hidden, that means:
75  * * The widget is invisible but keeps its size.
76  * * @ref find_at 'sees' the widget if active is @c false.
77  * * The widget doesn't handle events (and doesn't send events to
78  * its children).
79  * * The widget doesn't add itself @ref window::dirty_list_ when
80  * @ref populate_dirty_list is called (nor does it send the
81  * request to its children).
82  */
83  hidden,
84 
85  /**
86  * The user set the widget invisible, that means:
87  * * The widget is invisible and its grid cell has size 0,0.
88  * * @ref find_at never 'sees' the widget.
89  * * The widget doesn't handle events (and doesn't send events to
90  * its children).
91  * * The widget doesn't add itself @ref window::dirty_list_ when
92  * @ref populate_dirty_list is called (nor does it send the
93  * request to its children).
94  */
95  invisible
96  };
97 
98  /**
99  * Visibility set by the engine.
100  *
101  * This state only will be used if @ref visible_ is @ref visibility::visible
102  * depending on this state the widget might not be visible after all.
103  */
104  enum class redraw_action
105  {
106  /**
107  * The widget is fully visible.
108  *
109  * The widget should be drawn if @ref dirty_ is @c true. The entire
110  * widget's rectangle should be redrawn.
111  */
112  full,
113 
114  /**
115  * The widget is partly visible.
116  *
117  * The should be drawn if @ref dirty_ is @c true. The rectangle to
118  * redraw in determined by @ref clipping_rectangle_
119  */
120  partly,
121 
122  /**
123  * The widget is not visible.
124  *
125  * The widget should not be drawn if @ref dirty_ is @c true.
126  */
127  none
128  };
129 
130 
131  /***** ***** ***** Constructor and destructor. ***** ***** *****/
132 
133 public:
134  widget(const widget&) = delete;
135  widget& operator=(const widget&) = delete;
136 
137  /** @deprecated use the second overload. */
138  widget();
139 
140  /**
141  * Constructor.
142  *
143  * @param builder The builder object with the settings for the
144  * object.
145  */
146  explicit widget(const builder_widget& builder);
147 
148  virtual ~widget() override;
149 
150 
151  /***** ***** ***** ***** ID functions. ***** ***** ***** *****/
152 
153 public:
154  /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/
155 
156  void set_id(const std::string& id);
157  const std::string& id() const;
158 
159  /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
160 
161 private:
162  /**
163  * The id is the unique name of the widget in a certain context.
164  *
165  * This is needed for certain widgets so the engine knows which widget is
166  * which. E.g. it knows which button is pressed and thus which engine action
167  * is connected to the button. This doesn't mean that the id is unique in a
168  * window, e.g. a listbox can have the same id for every row.
169  */
171 
172 
173  /***** ***** ***** ***** Parent functions ***** ***** ***** *****/
174 
175 public:
176  /**
177  * Get the parent window.
178  *
179  * @returns Pointer to parent window.
180  * @retval nullptr No parent window found.
181  */
182  window* get_window();
183 
184  /** The constant version of @ref get_window. */
185  const window* get_window() const;
186 
187  /**
188  * Get the parent grid.
189  *
190  * @returns Pointer to parent grid.
191  * @retval nullptr No parent grid found.
192  */
193  grid* get_parent_grid();
194 
195  /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/
196 
197  void set_parent(widget* parent);
198  widget* parent();
199 
200  /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
201 
202 private:
203  /**
204  * The parent widget.
205  *
206  * If the widget has a parent it contains a pointer to the parent, else it
207  * is set to @c nullptr.
208  */
210 
211 
212  /***** ***** ***** ***** Size and layout functions. ***** ***** ***** *****/
213 
214 public:
215  /**
216  * How the layout engine works.
217  *
218  * Every widget has a member @ref layout_size_ which holds the best size in
219  * the current layout phase. When the windows starts the layout phase it
220  * calls @ref layout_initialize which resets this value.
221  *
222  * Every widget has two function to get the best size. @ref get_best_size
223  * tests whether layout_size_ is set and if so returns that value otherwise
224  * it calls @ref calculate_best_size so the size can be updated.
225  *
226  * During the layout phase some functions can modify layout_size_ so the
227  * next call to @ref get_best_size returns the currently best size. This
228  * means that after the layout phase @ref get_best_size still returns this
229  * value.
230  */
231 
232  /**
233  * Initialises the layout phase.
234  *
235  * Clears the initial best size for the widgets.
236  *
237  * See @ref layout_algorithm for more information.
238  *
239  * @param full_initialization For widgets with scrollbars it hides them
240  * unless the mode is
241  * @ref scrollbar_mode::ALWAYS_VISIBLE. For
242  * other widgets this flag is a @em NOP.
243  */
244  virtual void layout_initialize(const bool full_initialization);
245 
246  /**
247  * Tries to reduce the width of a widget.
248  *
249  * This function tries to do it 'friendly' and only use scrollbars or
250  * tries to wrap the widget.
251  *
252  * See @ref layout_algorithm for more information.
253  *
254  * @param maximum_width The wanted maximum width.
255  */
256  virtual void request_reduce_width(const unsigned maximum_width) = 0;
257 
258  /**
259  * Tries to reduce the width of a widget.
260  *
261  * This function does it more aggressively and should only be used when
262  * using scrollbars and wrapping failed.
263  *
264  * @todo Make pure virtual.
265  *
266  * See @ref layout_algorithm for more information.
267  *
268  * @param maximum_width The wanted maximum width.
269  */
270  virtual void demand_reduce_width(const unsigned maximum_width);
271 
272  /**
273  * Tries to reduce the height of a widget.
274  *
275  * This function tries to do it 'friendly' and only use scrollbars.
276  *
277  * @todo Make pure virtual.
278  *
279  * See @ref layout_algorithm for more information.
280  *
281  * @param maximum_height The wanted maximum height.
282  */
283  virtual void request_reduce_height(const unsigned maximum_height);
284 
285  /**
286  * Tries to reduce the height of a widget.
287  *
288  * This function does it more aggressively and should only be used when
289  * using scrollbars failed.
290  *
291  * @todo Make pure virtual.
292  *
293  * See @ref layout_algorithm for more information.
294  *
295  * @param maximum_height The wanted maximum height.
296  */
297  virtual void demand_reduce_height(const unsigned maximum_height);
298 
299  /**
300  * Gets the best size for the widget.
301  *
302  * During the layout phase a best size will be determined, several stages
303  * might change the best size. This function will return the currently best
304  * size as determined during the layout phase.
305  *
306  * @returns The best size for the widget.
307  * @retval 0,0 The best size is 0,0.
308  */
309  point get_best_size() const;
310 
311 private:
312  /**
313  * Calculates the best size.
314  *
315  * This function calculates the best size and ignores the current values in
316  * the layout phase. Note containers can call the @ref get_best_size() of
317  * their children since it is meant to update itself.
318  *
319  * @returns The best size for the widget.
320  * @retval 0,0 The best size is 0,0.
321  */
322  virtual point calculate_best_size() const = 0;
323 
324 public:
325  /**
326  * Whether the mouse move/click event go 'through' this widget.
327  */
328  virtual bool can_mouse_focus() const { return true; }
329  /**
330  * Can the widget wrap.
331  *
332  * When a widget can wrap it can reduce its width by increasing its
333  * height. When a layout is too wide it should first try to wrap and if
334  * that fails it should check the vertical scrollbar status. After wrapping
335  * the height might (probably will) change so the layout engine needs to
336  * recalculate the height after wrapping.
337  */
338  virtual bool can_wrap() const;
339 
340  /**
341  * Sets the origin of the widget.
342  *
343  * This function can be used to move the widget without dirtying it. The
344  * location is an absolute position, if a relative more is required use
345  * @ref move.
346  *
347  *
348  * @param origin The new origin.
349  */
350  virtual void set_origin(const point& origin);
351 
352  /**
353  * Sets the size of the widget.
354  *
355  * This version is meant to resize a widget, since the origin isn't
356  * modified. This can be used if a widget needs to change its size and the
357  * layout will be fixed later.
358  *
359  * @param size The size of the widget.
360  */
361  virtual void set_size(const point& size);
362 
363  /**
364  * Places the widget.
365  *
366  * This function is normally called by a layout function to do the
367  * placement of a widget.
368  *
369  * @param origin The position of top left of the widget.
370  * @param size The size of the widget.
371  */
372  virtual void place(const point& origin, const point& size);
373 
374  /**
375  * Moves a widget.
376  *
377  * This function can be used to move the widget without dirtying it.
378  *
379  * @todo Implement the function to all derived classes.
380  *
381  * @param x_offset The amount of pixels to move the widget in
382  * the x-direction.
383  * @param y_offset The amount of pixels to move the widget in
384  * the y-direction.
385  */
386  virtual void move(const int x_offset, const int y_offset);
387 
388  /**
389  * Sets the horizontal alignment of the widget within its parent grid.
390  *
391  * @param alignment The new alignment.
392  */
393  virtual void set_horizontal_alignment(const std::string& alignment);
394 
395  /**
396  * Sets the horizontal alignment of the widget within its parent grid.
397  *
398  * @param alignment The new alignment.
399  */
400  virtual void set_vertical_alignment(const std::string& alignment);
401 
402  /**
403  * Allows a widget to update its children.
404  *
405  * Before the window is populating the dirty list the widgets can update
406  * their content, which allows delayed initialization. This delayed
407  * initialization is only allowed if the widget resizes itself, not when
408  * being placed.
409  */
410  virtual void layout_children();
411 
412  /**
413  * Returns the screen origin of the widget.
414  *
415  * @returns The origin of the widget.
416  */
417  point get_origin() const;
418 
419  /**
420  * Returns the size of the widget.
421  *
422  * @returns The size of the widget.
423  */
424  point get_size() const;
425 
426  /**
427  * Gets the bounding rectangle of the widget on the screen.
428  *
429  * @returns The bounding rectangle of the widget.
430  */
431  SDL_Rect get_rectangle() const;
432 
433  /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/
434 
435  int get_x() const;
436 
437  int get_y() const;
438 
439  unsigned get_width() const;
440 
441  unsigned get_height() const;
442 
443 protected:
444  void set_layout_size(const point& size);
445  const point& layout_size() const;
446 
447  /**
448  * Throws away @ref layout_size_.
449  *
450  * Use with care: this function does not recurse to child widgets.
451  *
452  * See @ref layout_algorithm for more information.
453  */
454  void clear_layout_size() { set_layout_size(point()); }
455 
456 public:
457  void set_linked_group(const std::string& linked_group);
458 
459  /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
460 
461 private:
462  /** The x-coordinate of the widget on the screen. */
463  int x_;
464 
465  /** The y-coordinate of the widget on the screen. */
466  int y_;
467 
468  /** The width of the widget. */
469  unsigned width_;
470 
471  /** The height of the widget. */
472  unsigned height_;
473 
474  /**
475  * The best size for the widget.
476  *
477  * When 0,0 the real best size is returned, but in the layout phase a
478  * wrapping or a scrollbar might change the best size for that widget.
479  * This variable holds that best value.
480  *
481  * If the widget size hasn't been changed from the default that
482  * calculate_best_size() returns, layout_size_ is (0,0).
483  */
485 
486 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
487 
488  /**
489  * Debug helper to store last value of get_best_size().
490  *
491  * We're mutable so calls can stay const and this is disabled in
492  * production code.
493  */
494  mutable point last_best_size_;
495 
496 #endif
497 
498  /**
499  * The linked group the widget belongs to.
500  *
501  * @todo For now the linked group is initialized when the layout of the
502  * widget is initialized. The best time to set it would be upon adding the
503  * widget in the window. Need to look whether it is possible in a clean way.
504  * Maybe a signal just prior to showing a window where the widget can do
505  * some of it's on things, would also be nice for widgets that need a
506  * finalizer function.
507  */
509 
510 
511  /***** ***** ***** ***** Drawing functions. ***** ***** ***** *****/
512 
513 public:
514  /**
515  * Calculates the blitting rectangle of the widget.
516  *
517  * The blitting rectangle is the entire widget rectangle, but offsetted for
518  * drawing position.
519  *
520  * @param x_offset The offset in the x-direction when drawn.
521  * @param y_offset The offset in the y-direction when drawn.
522  *
523  * @returns The drawing rectangle.
524  */
525  SDL_Rect calculate_blitting_rectangle(const int x_offset,
526  const int y_offset);
527 
528  /**
529  * Calculates the clipping rectangle of the widget.
530  *
531  * The clipping rectangle is used then the @ref redraw_action_ is
532  * @ref redraw_action::partly. Since the drawing can be offsetted it also
533  * needs offset parameters.
534  *
535  * @param x_offset The offset in the x-direction when drawn.
536  * @param y_offset The offset in the y-direction when drawn.
537  *
538  * @returns The clipping rectangle.
539  */
540  SDL_Rect calculate_clipping_rectangle(const int x_offset,
541  const int y_offset);
542 
543  /**
544  * Draws the background of a widget.
545  *
546  * Derived should override @ref impl_draw_background instead of changing
547  * this function.
548  *
549  * @param frame_buffer The surface to draw upon.
550  * @param x_offset The offset in the x-direction in the
551  * @p frame_buffer to draw.
552  * @param y_offset The offset in the y-direction in the
553  * @p frame_buffer to draw.
554  */
555  void draw_background(surface& frame_buffer, int x_offset, int y_offset);
556 
557  /**
558  * Draws the children of a widget.
559  *
560  * Containers should draw their children when they get this request.
561  *
562  * Derived should override @ref impl_draw_children instead of changing
563  * this function.
564  *
565  * @param frame_buffer The surface to draw upon.
566  * @param x_offset The offset in the x-direction in the
567  * @p frame_buffer to draw.
568  * @param y_offset The offset in the y-direction in the
569  * @p frame_buffer to draw.
570  */
571  void draw_children(surface& frame_buffer, int x_offset, int y_offset);
572 
573  /**
574  * Draws the foreground of the widget.
575  *
576  * Some widgets e.g. panel and window have a back and foreground layer this
577  * function requests the drawing of the foreground.
578  *
579  * Derived should override @ref impl_draw_foreground instead of changing
580  * this function.
581  *
582  * @param frame_buffer The surface to draw upon.
583  * @param x_offset The offset in the x-direction in the
584  * @p frame_buffer to draw.
585  * @param y_offset The offset in the y-direction in the
586  * @p frame_buffer to draw.
587  */
588  void draw_foreground(surface& frame_buffer, int x_offset, int y_offset);
589 
590 private:
591  /** See @ref draw_background. */
592  virtual void impl_draw_background(surface& /*frame_buffer*/)
593  {
594  }
595  virtual void impl_draw_background(surface& /*frame_buffer*/
596  ,
597  int /*x_offset*/
598  ,
599  int /*y_offset*/)
600  {
601  }
602 
603  /** See @ref draw_children. */
604  virtual void impl_draw_children(surface& /*frame_buffer*/
605  ,
606  int /*x_offset*/
607  ,
608  int /*y_offset*/)
609  {
610  }
611 
612  /** See @ref draw_foreground. */
613  virtual void impl_draw_foreground(surface& /*frame_buffer*/
614  ,
615  int /*x_offset*/
616  ,
617  int /*y_offset*/)
618  {
619  }
620 
621 public:
622  /**
623  * Adds a widget to the dirty list if it is dirty.
624  *
625  * See @ref window::dirty_list_ for more information regarding the dirty
626  * list.
627  *
628  * If the widget is not dirty and has children it should add itself to the
629  * call_stack and call child_populate_dirty_list with the new call_stack.
630  *
631  * @param caller The parent window, if dirty it should
632  * register itself to this window.
633  * @param call_stack The call-stack of widgets traversed to reach
634  * this function.
635  */
636  void populate_dirty_list(window& caller,
637  std::vector<widget*>& call_stack);
638 
639 private:
640  /**
641  * Tries to add all children of a container to the dirty list.
642  *
643  * @note The function is private since everybody should call
644  * @ref populate_dirty_list instead.
645  *
646  * @param caller The parent window, if dirty it should
647  * register itself to this window.
648  * @param call_stack The call-stack of widgets traversed to reach
649  * this function.
650  */
651  virtual void
652  child_populate_dirty_list(window& caller,
653  const std::vector<widget*>& call_stack);
654 
655 public:
656  /**
657  * Gets the dirty rectangle of the widget.
658  *
659  * Depending on the @ref redraw_action_ it returns the rectangle this
660  * widget dirties while redrawing.
661  *
662  * @returns The dirty rectangle.
663  */
664  SDL_Rect get_dirty_rectangle() const;
665 
666  /**
667  * Sets the visible rectangle for a widget.
668  *
669  * This function sets the @ref redraw_action_ and the
670  * @ref clipping_rectangle_.
671  *
672  * @param rectangle The visible rectangle in screen coordinates.
673  */
674  virtual void set_visible_rectangle(const SDL_Rect& rectangle);
675 
676  /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/
677 
678  void set_is_dirty(const bool is_dirty);
679  bool get_is_dirty() const;
680 
681  void set_visible(const visibility visible);
682  visibility get_visible() const;
683 
684  redraw_action get_drawing_action() const;
685 
686  void set_debug_border_mode(const unsigned debug_border_mode);
687 
688  void set_debug_border_color(const color_t debug_border_color);
689 
690  /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
691 
692 private:
693  /**
694  * Is the widget dirty?
695  *
696  * When a widget is dirty it needs to be redrawn at the next drawing cycle.
697  *
698  * The top-level window will use @ref populate_dirty_list and
699  * @ref child_populate_dirty_list to find al dirty widgets, so the widget
700  * doesn't need to inform its parent regarding it being marked dirty.
701  */
702  bool is_dirty_;
703 
704  /** Field for the status of the visibility. */
706 
707  /** Field for the action to do on a drawing request. */
709 
710  /** The clipping rectangle if a widget is partly visible. */
712 
713  /**
714  * Mode for drawing the debug border.
715  *
716  * The debug border is a helper border to determine where a widget is
717  * placed. It is only intended for debugging purposes.
718  *
719  * Possible values:
720  * - 0 no border
721  * - 1 single pixel border
722  * - 2 flood-filled rectangle
723  */
725 
726  /** The color for the debug border. */
728 
729  void draw_debug_border();
730  void draw_debug_border(int x_offset, int y_offset);
731 
732  /***** ***** ***** ***** Query functions ***** ***** ***** *****/
733 
734 public:
735  /**
736  * Returns the widget at the wanted coordinates.
737  *
738  * @param coordinate The coordinate which should be inside the
739  * widget.
740  * @param must_be_active The widget should be active, not all widgets
741  * have an active flag, those who don't ignore
742  * flag.
743  *
744  * @returns The widget with the id.
745  * @retval nullptr No widget at the wanted coordinate found (or
746  * not active if must_be_active was set).
747  */
748  virtual widget* find_at(const point& coordinate,
749  const bool must_be_active);
750 
751  /** The constant version of @ref find_at. */
752  virtual const widget* find_at(const point& coordinate,
753  const bool must_be_active) const;
754 
755  /**
756  * Returns @em a widget with the wanted id.
757  *
758  * @note Since the id might not be unique inside a container there is no
759  * guarantee which widget is returned.
760  *
761  * @param id The id of the widget to find.
762  * @param must_be_active The widget should be active, not all widgets
763  * have an active flag, those who don't ignore
764  * flag.
765  *
766  * @returns The widget with the id.
767  * @retval nullptr No widget with the id found (or not active if
768  * must_be_active was set).
769  */
770  virtual widget* find(const std::string& id, const bool must_be_active);
771 
772  /** The constant version of @ref find. */
773  virtual const widget* find(const std::string& id,
774  const bool must_be_active) const;
775 
776  /**
777  * Does the widget contain the widget.
778  *
779  * Widgets can be containers which have more widgets inside them, this
780  * function will traverse in those child widgets and tries to find the
781  * wanted widget.
782  *
783  * @param widget Pointer to the widget to find.
784  *
785  * @returns Whether or not the @p widget was found.
786  */
787  virtual bool has_widget(const widget& widget) const;
788 
789 private:
790  /** See @ref event::dispatcher::is_at. */
791  virtual bool is_at(const point& coordinate) const override;
792 
793  /**
794  * Is the coordinate inside our area.
795  *
796  * Helper for find_at so also looks at our visibility.
797  *
798  * @param coordinate The coordinate which should be inside the
799  * widget.
800  * @param must_be_active The widget should be active, not all widgets
801  * have an active flag, those who don't ignore
802  * flag.
803  *
804  * @returns Status.
805  */
806  bool is_at(const point& coordinate, const bool must_be_active) const;
807 
808  /**
809  * Is the widget and every single one of its parents visible?
810  *
811  * @param widget Widget where to start the check.
812  * @param must_be_active The widget should be active, not all widgets
813  * have an active flag, those who don't ignore
814  * flag.
815  *
816  * @returns Status.
817  */
818  bool recursive_is_visible(const widget* widget, const bool must_be_active) const;
819 
820  /***** ***** ***** ***** Miscellaneous ***** ***** ****** *****/
821 
822 public:
823  /** Does the widget disable easy close? */
824  virtual bool disable_click_dismiss() const = 0;
825 
826  /** Creates a new walker object on the heap. */
827  virtual iteration::walker_base* create_walker() = 0;
828 };
829 
830 } // namespace gui2
Contains the info needed to instantiate a widget.
redraw_action
Visibility set by the engine.
Definition: widget.hpp:104
virtual void impl_draw_foreground(surface &, int, int)
See draw_foreground.
Definition: widget.hpp:613
Base class for event handling.
Definition: dispatcher.hpp:172
unsigned debug_border_mode_
Mode for drawing the debug border.
Definition: widget.hpp:724
widget * parent_
The parent widget.
Definition: widget.hpp:209
static void draw_background(surface screen, const SDL_Rect &area, const std::string &image)
Definition: display.cpp:1487
unsigned height_
The height of the widget.
Definition: widget.hpp:472
Base class for all widgets.
Definition: widget.hpp:49
redraw_action redraw_action_
Field for the action to do on a drawing request.
Definition: widget.hpp:708
std::string id_
The id is the unique name of the widget in a certain context.
Definition: widget.hpp:170
visibility visible_
Field for the status of the visibility.
Definition: widget.hpp:705
Generic file dialog.
Definition: field-fwd.hpp:22
Base container class.
Definition: grid.hpp:30
virtual void impl_draw_background(surface &)
See draw_background.
Definition: widget.hpp:592
The walker abstract base class.
Definition: walker.hpp:26
point layout_size_
The best size for the widget.
Definition: widget.hpp:484
std::string linked_group_
The linked group the widget belongs to.
Definition: widget.hpp:508
int y_
The y-coordinate of the widget on the screen.
Definition: widget.hpp:466
virtual void impl_draw_children(surface &, int, int)
See draw_children.
Definition: widget.hpp:604
Event execution calls.
virtual bool can_mouse_focus() const
Whether the mouse move/click event go &#39;through&#39; this widget.
Definition: widget.hpp:328
u64 size
Definition: statement.cpp:80
color_t debug_border_color_
The color for the debug border.
Definition: widget.hpp:727
std::map< std::string, t_string > string_map
Definition: widget.hpp:26
visibility
Visibility settings done by the user.
Definition: widget.hpp:59
Holds a 2D point.
Definition: point.hpp:23
void clear_layout_size()
Throws away layout_size_.
Definition: widget.hpp:454
virtual void impl_draw_background(surface &, int, int)
Definition: widget.hpp:595
bool grid()
Definition: general.cpp:504
SDL_Rect clipping_rectangle_
The clipping rectangle if a widget is partly visible.
Definition: widget.hpp:711
unsigned width_
The width of the widget.
Definition: widget.hpp:469
bool find(E event, F functor)
Tests whether an event handler is available.
bool is_dirty_
Is the widget dirty?
Definition: widget.hpp:702
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
int x_
The x-coordinate of the widget on the screen.
Definition: widget.hpp:463
static std::deque< std::string > call_stack
Definition: function.cpp:39