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