The Battle for Wesnoth  1.15.1+dev
grid.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 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 
17 #include "gui/widgets/widget.hpp"
18 
19 #include <cassert>
20 
21 namespace gui2
22 {
23 
24 /**
25  * Base container class.
26  *
27  * This class holds a number of widgets and their wanted layout parameters. It
28  * also layouts the items in the grid and handles their drawing.
29  */
30 class grid : public widget
31 {
32  friend class debug_layout_graph;
33  friend struct grid_implementation;
34 
35 public:
36  explicit grid(const unsigned rows = 0, const unsigned cols = 0);
37 
38  /** Delete the copy constructor. */
39  grid(const grid&) = delete;
40 
41  /** Delete the move assignment operator. */
42  grid& operator=(const grid&) = delete;
43 
44  virtual ~grid();
45 
46  /***** ***** ***** ***** LAYOUT FLAGS ***** ***** ***** *****/
47  static const unsigned VERTICAL_SHIFT = 0;
48  static const unsigned VERTICAL_GROW_SEND_TO_CLIENT = 1 << VERTICAL_SHIFT;
49  static const unsigned VERTICAL_ALIGN_TOP = 2 << VERTICAL_SHIFT;
50  static const unsigned VERTICAL_ALIGN_CENTER = 3 << VERTICAL_SHIFT;
51  static const unsigned VERTICAL_ALIGN_BOTTOM = 4 << VERTICAL_SHIFT;
52  static const unsigned VERTICAL_MASK = 7 << VERTICAL_SHIFT;
53 
54  static const unsigned HORIZONTAL_SHIFT = 3;
55  static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT = 1 << HORIZONTAL_SHIFT;
56  static const unsigned HORIZONTAL_ALIGN_LEFT = 2 << HORIZONTAL_SHIFT;
57  static const unsigned HORIZONTAL_ALIGN_CENTER = 3 << HORIZONTAL_SHIFT;
58  static const unsigned HORIZONTAL_ALIGN_RIGHT = 4 << HORIZONTAL_SHIFT;
59  static const unsigned HORIZONTAL_MASK = 7 << HORIZONTAL_SHIFT;
60 
61  static const unsigned BORDER_TOP = 1 << 6;
62  static const unsigned BORDER_BOTTOM = 1 << 7;
63  static const unsigned BORDER_LEFT = 1 << 8;
64  static const unsigned BORDER_RIGHT = 1 << 9;
65  static const unsigned BORDER_ALL = BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT;
66 
67  /***** ***** ***** ***** ROW COLUMN MANIPULATION ***** ***** ***** *****/
68 
69  /**
70  * Adds a row to end of the grid.
71  *
72  * @param count Number of rows to add, should be > 0.
73  *
74  * @returns The row number of the first row added.
75  */
76  unsigned add_row(const unsigned count = 1);
77 
78  /**
79  * Sets the grow factor for a row.
80  *
81  * @todo refer to a page with the layout manipulation info.
82  *
83  * @param row The row to modify.
84  * @param factor The grow factor.
85  */
86  void set_row_grow_factor(const unsigned row, const unsigned factor)
87  {
88  assert(row < row_grow_factor_.size());
89  row_grow_factor_[row] = factor;
90  set_is_dirty(true);
91  }
92 
93  /**
94  * Sets the grow factor for a column.
95  *
96  * @todo refer to a page with the layout manipulation info.
97  *
98  * @param column The column to modify.
99  * @param factor The grow factor.
100  */
101  void set_column_grow_factor(const unsigned column, const unsigned factor)
102  {
103  assert(column < col_grow_factor_.size());
104  col_grow_factor_[column] = factor;
105  set_is_dirty(true);
106  }
107 
108  /***** ***** ***** ***** CHILD MANIPULATION ***** ***** ***** *****/
109 
110  /**
111  * Sets a child in the grid.
112  *
113  * When the child is added to the grid the grid 'owns' the widget.
114  * The widget is put in a cell, and every cell can only contain 1 widget if
115  * the wanted cell already contains a widget, that widget is freed and
116  * removed.
117  *
118  * @param widget The widget to put in the grid.
119  * @param row The row of the cell.
120  * @param col The column of the cell.
121  * @param flags The flags for the widget in the cell.
122  * @param border_size The size of the border for the cell, how the
123  * border is applied depends on the flags.
124  */
125  void set_child(widget* widget,
126  const unsigned row,
127  const unsigned col,
128  const unsigned flags,
129  const unsigned border_size);
130 
131  /**
132  * Exchanges a child in the grid.
133  *
134  * It replaced the child with a certain id with the new widget but doesn't
135  * touch the other settings of the child.
136  *
137  * @param id The id of the widget to free.
138  * @param w The widget to put in the grid.
139  * @param recurse Do we want to decent into the child grids.
140  * @param new_parent The new parent for the swapped out widget.
141  *
142  * returns The widget which got removed (the parent of
143  * the widget is cleared). If no widget found
144  * and thus not replace nullptr will returned.
145  */
146  std::unique_ptr<widget> swap_child(const std::string& id,
147  widget* w,
148  const bool recurse,
149  widget* new_parent = nullptr);
150 
151  /**
152  * Removes and frees a widget in a cell.
153  *
154  * @param row The row of the cell.
155  * @param col The column of the cell.
156  */
157  void remove_child(const unsigned row, const unsigned col);
158 
159  /**
160  * Removes and frees a widget in a cell by it's id.
161  *
162  * @param id The id of the widget to free.
163  * @param find_all If true if removes all items with the id,
164  * otherwise it stops after removing the first
165  * item (or once all children have been tested).
166  */
167  void remove_child(const std::string& id, const bool find_all = false);
168 
169  /**
170  * Activates all children.
171  *
172  * If a child inherits from styled_widget or is a grid it will call
173  * set_active() for the child otherwise it ignores the widget.
174  *
175  * @param active Parameter for set_active.
176  */
177  void set_active(const bool active);
178 
179  /** Returns the widget in the selected cell. */
180  const widget* get_widget(const unsigned row, const unsigned col) const
181  {
182  return get_child(row, col).get_widget();
183  }
184 
185  /** Returns the widget in the selected cell. */
186  widget* get_widget(const unsigned row, const unsigned col)
187  {
188  return get_child(row, col).get_widget();
189  }
190 
191  virtual bool can_mouse_focus() const override { return false; }
192  /***** ***** ***** ***** layout functions ***** ***** ***** *****/
193 
194  /** See @ref widget::layout_initialize. */
195  virtual void layout_initialize(const bool full_initialization) override;
196 
197  /**
198  * Tries to reduce the width of a container.
199  *
200  * See @ref layout_algorithm for more information.
201  *
202  * @param maximum_width The wanted maximum width.
203  */
204  void reduce_width(const unsigned maximum_width);
205 
206  /** See @ref widget::request_reduce_width. */
207  virtual void request_reduce_width(const unsigned maximum_width) override;
208 
209  /** See @ref widget::demand_reduce_width. */
210  virtual void demand_reduce_width(const unsigned maximum_width) override;
211 
212  /**
213  * Tries to reduce the height of a container.
214  *
215  * See @ref layout_algorithm for more information.
216  *
217  * @param maximum_height The wanted maximum height.
218  */
219  void reduce_height(const unsigned maximum_height);
220 
221  /** See @ref widget::request_reduce_height. */
222  virtual void request_reduce_height(const unsigned maximum_height) override;
223 
224  /** See @ref widget::demand_reduce_height. */
225  virtual void demand_reduce_height(const unsigned maximum_height) override;
226 
227  /**
228  * Recalculates the best size.
229  *
230  * This is used for scrollbar containers when they try to update their
231  * contents size before falling back to the 'global' invalidate_layout.
232  *
233  * @returns The newly calculated size.
234  */
236 
237  /**
238  * Modifies the widget alignment data of a child cell containing a specific widget.
239  *
240  * @param widget The widget whose cell to modify.
241  * @param set_flag The alignment flag to set.
242  * @param mode_mask Whether to affect horizontal or vertical alignment.
243  * Use either HORIZONTAL_MASK or VERTICAL_MASK
244  */
245  void set_child_alignment(widget* widget, unsigned set_flag, unsigned mode_mask);
246 
247 private:
248  /** See @ref widget::calculate_best_size. */
249  virtual point calculate_best_size() const override;
250 
251  /**
252  * Attempts to lay out the grid without laying out the entire window.
253  */
254  void request_placement(dispatcher& dispatcher, const event::ui_event event, bool& handled, bool& halt);
255 
256 public:
257  /** See @ref widget::can_wrap. */
258  virtual bool can_wrap() const override;
259 
260 public:
261  /** See @ref widget::place. */
262  virtual void place(const point& origin, const point& size) override;
263 
264  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
265 
266  /** See @ref widget::set_origin. */
267  virtual void set_origin(const point& origin) override;
268 
269  /** See @ref widget::set_visible_rectangle. */
270  virtual void set_visible_rectangle(const SDL_Rect& rectangle) override;
271 
272  /** See @ref widget::layout_children. */
273  virtual void layout_children() override;
274 
275  /** See @ref widget::child_populate_dirty_list. */
276  virtual void
278  const std::vector<widget*>& call_stack) override;
279 
280  /** See @ref widget::find_at. */
281  virtual widget* find_at(const point& coordinate,
282  const bool must_be_active) override;
283 
284  /** See @ref widget::find_at. */
285  virtual const widget* find_at(const point& coordinate,
286  const bool must_be_active) const override;
287 
288  /** See @ref widget::find. */
289  widget* find(const std::string& id, const bool must_be_active) override;
290 
291  /** See @ref widget::find. */
292  const widget* find(const std::string& id,
293  const bool must_be_active) const override;
294 
295  /** See @ref widget::has_widget. */
296  virtual bool has_widget(const widget& widget) const override;
297 
298  /** See @ref widget::disable_click_dismiss. */
299  bool disable_click_dismiss() const override;
300 
301  /** See @ref widget::create_walker. */
302  virtual iteration::walker_base* create_walker() override;
303 
304  /***** ***** ***** setters / getters for members ***** ****** *****/
305 
306  void set_rows(const unsigned rows);
307  unsigned int get_rows() const
308  {
309  return rows_;
310  }
311 
312  void set_cols(const unsigned cols);
313  unsigned int get_cols() const
314  {
315  return cols_;
316  }
317 
318  /**
319  * Wrapper to set_rows and set_cols.
320  *
321  * @param rows Parameter to call set_rows with.
322  * @param cols Parameter to call set_cols with.
323  */
324  void set_rows_cols(const unsigned rows, const unsigned cols);
325 
326 private:
327  /** Child item of the grid. */
328  class child
329  {
330  friend struct grid_implementation;
331 
332  public:
333  // Fixme make a class where we can store some properties in the cache
334  // regarding size etc.
335  child() : flags_(0), border_size_(0), widget_(nullptr)
336  {
337  }
338 
339  /**
340  * Move constructor.
341  *
342  * This is necessary in order that the child objects be moved instead
343  * of copied when the grid's child vector is resized. std::vector will
344  * utilize a move constructor as long as a non-throwing one is provided.
345  */
346  child(child&&) noexcept = default;
347 
348  /** Returns the best size for the cell. */
349  point get_best_size() const;
350 
351  /**
352  * Places the widget in the cell.
353  *
354  * @param origin The origin (x, y) for the widget.
355  * @param size The size for the widget.
356  */
357  void place(point origin, point size);
358 
359  /** Forwards @ref grid::layout_initialize to the cell. */
360  void layout_initialize(const bool full_initialization);
361 
362  /** Returns the can_wrap for the cell. */
363  bool can_wrap() const
364  {
365  return widget_ ? widget_->can_wrap() : false;
366  }
367 
368  /** Returns the id of the widget/ */
369  const std::string& id() const;
370 
371  unsigned get_flags() const
372  {
373  return flags_;
374  }
375 
376  void set_flags(const unsigned flags)
377  {
378  flags_ = flags;
379  }
380 
381  unsigned get_border_size() const
382  {
383  return border_size_;
384  }
385 
386  void set_border_size(const unsigned border_size)
387  {
388  border_size_ = border_size;
389  }
390 
391  const widget* get_widget() const
392  {
393  return widget_.get();
394  }
395 
396  widget* get_widget()
397  {
398  return widget_.get();
399  }
400 
401  void set_widget(widget* widget)
402  {
403  widget_.reset(widget);
404  }
405 
406  /**
407  * Releases widget from ownership by this child and returns it in the
408  * form of a new unique_ptr. widget_ will be null after this is called.
409  */
410  std::unique_ptr<widget> free_widget()
411  {
412  std::unique_ptr<widget> temp(nullptr);
413  widget_.swap(temp);
414 
415  return temp;
416  }
417 
418  private:
419  /** The flags for the border and cell setup. */
420  unsigned flags_;
421 
422  /**
423  * The size of the border, the actual configuration of the border
424  * is determined by the flags.
425  */
426  unsigned border_size_;
427 
428  /**
429  * Pointer to the widget.
430  *
431  * Once the widget is assigned to the grid we own the widget and it
432  * will be destroyed with the grid or @ref free_widget is called.
433  */
434  std::unique_ptr<widget> widget_;
435 
436  /** Returns the space needed for the border. */
437  point border_space() const;
438 
439  }; // class child
440 
441 public:
442  /** Iterator for the child items. */
443  class iterator
444  {
445 
446  public:
448  {
449  }
450 
452  {
453  return iterator(++itor_);
454  }
456  {
457  return iterator(--itor_);
458  }
459  widget* operator->()
460  {
461  return itor_->get_widget();
462  }
463  widget* operator*()
464  {
465  return itor_->get_widget();
466  }
467 
468  bool operator==(const iterator& i) const
469  {
470  return i.itor_ == this->itor_;
471  }
472 
473  bool operator!=(const iterator& i) const
474  {
475  return i.itor_ != this->itor_;
476  }
477 
478  private:
480  };
481 
483  {
484  return iterator(children_.begin());
485  }
487  {
488  return iterator(children_.end());
489  }
490 
491 private:
492  /** The number of grid rows. */
493  unsigned rows_;
494 
495  /** The number of grid columns. */
496  unsigned cols_;
497 
498  /***** ***** ***** ***** size caching ***** ***** ***** *****/
499 
500  /** The row heights in the grid. */
501  mutable std::vector<unsigned> row_height_;
502 
503  /** The column widths in the grid. */
504  mutable std::vector<unsigned> col_width_;
505 
506  /** The grow factor for all rows. */
507  std::vector<unsigned> row_grow_factor_;
508 
509  /** The grow factor for all columns. */
510  std::vector<unsigned> col_grow_factor_;
511 
512  /**
513  * The child items.
514  *
515  * All children are stored in a 1D vector and the formula to access a cell
516  * is: rows_ * col + row. All other vectors use the same access formula.
517  */
518  std::vector<child> children_;
519 
520  /**
521  * Gets the grid child in the specified cell.
522  *
523  * @param row The row of the cell.
524  * @param col The column of the cell.
525  *
526  * @returns A const reference to the specified grid child.
527  */
528  const grid::child& get_child(const unsigned row, const unsigned col) const
529  {
530  return children_[rows_ * col + row];
531  }
532 
533  /**
534  * Gets the grid child in the specified cell.
535  *
536  * @param row The row of the cell.
537  * @param col The column of the cell.
538  *
539  * @returns A const reference to the specified grid child.
540  */
541  grid::child& get_child(const unsigned row, const unsigned col)
542  {
543  return children_[rows_ * col + row];
544  }
545 
546  /**
547  * Gets the grid child containing the specified widget.
548  *
549  * @param w The widget to search for.
550  *
551  * @returns A pointer to the relevant grid child, or nullptr
552  * if no grid cell 'owns' the given widget.
553  */
554  grid::child* get_child(widget* w);
555 
556  /** Layouts the children in the grid. */
557  void layout(const point& origin);
558 
559  /** See @ref widget::impl_draw_children. */
560  virtual void impl_draw_children(surface& frame_buffer,
561  int x_offset,
562  int y_offset) override;
563 };
564 
565 /**
566  * Sets the single child in a grid.
567  *
568  * The function initializes the grid to 1 x 1 and adds the widget with the grow
569  * to client flags.
570  *
571  * @param grid The grid to add the child to.
572  * @param widget The widget to add as child to the grid.
573  */
575 
576 } // namespace gui2
unsigned get_flags() const
Definition: grid.hpp:371
static const unsigned BORDER_TOP
Definition: grid.hpp:61
virtual void set_visible_rectangle(const SDL_Rect &rectangle) override
See widget::set_visible_rectangle.
Definition: grid.cpp:603
widget * operator->()
Definition: grid.hpp:459
std::vector< unsigned > row_grow_factor_
The grow factor for all rows.
Definition: grid.hpp:507
virtual void demand_reduce_width(const unsigned maximum_width) override
See widget::demand_reduce_width.
Definition: grid.cpp:271
friend class debug_layout_graph
Definition: grid.hpp:32
widget * operator*()
Definition: grid.hpp:463
iterator begin()
Definition: grid.hpp:482
void set_row_grow_factor(const unsigned row, const unsigned factor)
Sets the grow factor for a row.
Definition: grid.hpp:86
virtual bool can_wrap() const override
See widget::can_wrap.
Definition: grid.cpp:466
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
Definition: grid.cpp:681
std::unique_ptr< widget > widget_
Pointer to the widget.
Definition: grid.hpp:434
unsigned cols_
The number of grid columns.
Definition: grid.hpp:496
Child item of the grid.
Definition: grid.hpp:328
iterator(std::vector< child >::iterator itor)
Definition: grid.hpp:447
grid::child & get_child(const unsigned row, const unsigned col)
Gets the grid child in the specified cell.
Definition: grid.hpp:541
unsigned int get_rows() const
Definition: grid.hpp:307
virtual bool has_widget(const widget &widget) const override
See widget::has_widget.
Definition: grid.cpp:666
static const unsigned BORDER_ALL
Definition: grid.hpp:65
Base class for all widgets.
Definition: widget.hpp:47
static const unsigned VERTICAL_SHIFT
Definition: grid.hpp:47
iterator operator--()
Definition: grid.hpp:455
unsigned get_border_size() const
Definition: grid.hpp:381
widget * get_widget(const unsigned row, const unsigned col)
Returns the widget in the selected cell.
Definition: grid.hpp:186
bool operator!=(const iterator &i) const
Definition: grid.hpp:473
grid & operator=(const grid &)=delete
Delete the move assignment operator.
static const unsigned HORIZONTAL_MASK
Definition: grid.hpp:59
virtual void request_reduce_width(const unsigned maximum_width) override
See widget::request_reduce_width.
Definition: grid.cpp:231
bool operator==(const iterator &i) const
Definition: grid.hpp:468
point recalculate_best_size()
Recalculates the best size.
Definition: grid.cpp:415
std::vector< child >::iterator itor_
Definition: grid.hpp:479
Generic file dialog.
Definition: field-fwd.hpp:22
unsigned rows_
The number of grid rows.
Definition: grid.hpp:493
virtual void layout_initialize(const bool full_initialization) override
See widget::layout_initialize.
Definition: grid.cpp:185
Base container class.
Definition: grid.hpp:30
const grid::child & get_child(const unsigned row, const unsigned col) const
Gets the grid child in the specified cell.
Definition: grid.hpp:528
iterator operator++()
Definition: grid.hpp:451
virtual bool can_mouse_focus() const override
Whether the mouse move/click event go &#39;through&#39; this widget.
Definition: grid.hpp:191
static const unsigned HORIZONTAL_SHIFT
Definition: grid.hpp:54
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
void set_flags(const unsigned flags)
Definition: grid.hpp:376
virtual point calculate_best_size() const override
See widget::calculate_best_size.
Definition: grid.cpp:422
void set_is_dirty(const bool is_dirty)
Definition: widget.cpp:463
The walker abstract base class.
Definition: walker.hpp:26
Iterator for the child items.
Definition: grid.hpp:443
static const unsigned HORIZONTAL_ALIGN_RIGHT
Definition: grid.hpp:58
static const unsigned BORDER_BOTTOM
Definition: grid.hpp:62
const std::string & id() const
Returns the id of the widget/.
Definition: grid.cpp:902
std::vector< unsigned > col_grow_factor_
The grow factor for all columns.
Definition: grid.hpp:510
virtual ~grid()
Definition: grid.cpp:54
std::vector< unsigned > row_height_
The row heights in the grid.
Definition: grid.hpp:501
std::unique_ptr< widget > free_widget()
Releases widget from ownership by this child and returns it in the form of a new unique_ptr.
Definition: grid.hpp:410
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
Definition: grid.cpp:655
unsigned int get_cols() const
Definition: grid.hpp:313
void layout(const point &origin)
Layouts the children in the grid.
Definition: grid.cpp:971
void request_placement(dispatcher &dispatcher, const event::ui_event event, bool &handled, bool &halt)
Attempts to lay out the grid without laying out the entire window.
Definition: grid.cpp:374
void place(point origin, point size)
Places the widget in the cell.
Definition: grid.cpp:765
std::vector< child > children_
The child items.
Definition: grid.hpp:518
virtual void place(const point &origin, const point &size) override
See widget::place.
Definition: grid.cpp:479
void set_child(widget *widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
Sets a child in the grid.
Definition: grid.cpp:69
static const unsigned VERTICAL_ALIGN_TOP
Definition: grid.hpp:49
widget * get_widget()
Definition: grid.hpp:396
std::size_t i
Definition: function.cpp:933
virtual iteration::walker_base * create_walker() override
See widget::create_walker.
Definition: grid.cpp:699
static const unsigned BORDER_RIGHT
Definition: grid.hpp:64
unsigned add_row(const unsigned count=1)
Adds a row to end of the grid.
Definition: grid.cpp:58
void reduce_width(const unsigned maximum_width)
Tries to reduce the width of a container.
Definition: grid.cpp:198
void set_widget(widget *widget)
Definition: grid.hpp:401
void layout_initialize(const bool full_initialization)
Forwards grid::layout_initialize to the cell.
Definition: grid.cpp:893
static const unsigned VERTICAL_ALIGN_CENTER
Definition: grid.hpp:50
bool can_wrap() const
Returns the can_wrap for the cell.
Definition: grid.hpp:363
static const unsigned HORIZONTAL_ALIGN_CENTER
Definition: grid.hpp:57
std::vector< unsigned > col_width_
The column widths in the grid.
Definition: grid.hpp:504
virtual void child_populate_dirty_list(window &caller, const std::vector< widget *> &call_stack) override
See widget::child_populate_dirty_list.
Definition: grid.cpp:627
Holds a 2D point.
Definition: point.hpp:23
static const unsigned VERTICAL_MASK
Definition: grid.hpp:52
void set_active(const bool active)
Activates all children.
Definition: grid.cpp:162
static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT
Definition: grid.hpp:55
int w
unsigned flags_
The flags for the border and cell setup.
Definition: grid.hpp:420
static const unsigned VERTICAL_GROW_SEND_TO_CLIENT
Definition: grid.hpp:48
virtual void set_origin(const point &origin) override
See widget::set_origin.
Definition: grid.cpp:586
virtual void request_reduce_height(const unsigned maximum_height) override
See widget::request_reduce_height.
Definition: grid.cpp:309
void set_single_child(grid &grid, widget *widget)
Sets the single child in a grid.
Definition: grid.cpp:1106
void set_rows_cols(const unsigned rows, const unsigned cols)
Wrapper to set_rows and set_cols.
Definition: grid.cpp:722
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
Definition: grid.cpp:642
static const unsigned VERTICAL_ALIGN_BOTTOM
Definition: grid.hpp:51
void set_cols(const unsigned cols)
Definition: grid.cpp:713
unsigned border_size_
The size of the border, the actual configuration of the border is determined by the flags...
Definition: grid.hpp:426
void remove_child(const unsigned row, const unsigned col)
Removes and frees a widget in a cell.
Definition: grid.cpp:140
std::unique_ptr< widget > swap_child(const std::string &id, widget *w, const bool recurse, widget *new_parent=nullptr)
Exchanges a child in the grid.
Definition: grid.cpp:98
void set_child_alignment(widget *widget, unsigned set_flag, unsigned mode_mask)
Modifies the widget alignment data of a child cell containing a specific widget.
Definition: grid.cpp:943
virtual void demand_reduce_height(const unsigned maximum_height) override
See widget::demand_reduce_height.
Definition: grid.cpp:369
virtual void layout_children() override
See widget::layout_children.
Definition: grid.cpp:618
void set_border_size(const unsigned border_size)
Definition: grid.hpp:386
static const unsigned HORIZONTAL_ALIGN_LEFT
Definition: grid.hpp:56
void set_rows(const unsigned rows)
Definition: grid.cpp:704
void set_column_grow_factor(const unsigned column, const unsigned factor)
Sets the grow factor for a column.
Definition: grid.hpp:101
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
point border_space() const
Returns the space needed for the border.
Definition: grid.cpp:908
const widget * get_widget(const unsigned row, const unsigned col) const
Returns the widget in the selected cell.
Definition: grid.hpp:180
const widget * get_widget() const
Definition: grid.hpp:391
static const unsigned BORDER_LEFT
Definition: grid.hpp:63
grid(const unsigned rows=0, const unsigned cols=0)
Definition: grid.cpp:39
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
Helper to implement private functions without modifying the header.
point get_best_size() const
Returns the best size for the cell.
Definition: grid.cpp:740
void reduce_height(const unsigned maximum_height)
Tries to reduce the height of a container.
Definition: grid.cpp:276
std::string::const_iterator iterator
Definition: tokenizer.hpp:24
static std::deque< std::string > call_stack
Definition: function.cpp:39
ui_event
The event send to the dispatcher.
Definition: handler.hpp:55
iterator end()
Definition: grid.hpp:486
virtual void impl_draw_children(surface &frame_buffer, int x_offset, int y_offset) override
See widget::impl_draw_children.
Definition: grid.cpp:993