37 explicit grid(
const unsigned rows = 0,
const unsigned cols = 0);
77 unsigned add_row(
const unsigned count = 1);
129 const unsigned flags,
130 const unsigned border_size);
147 std::unique_ptr<widget>
swap_child(
const std::string&
id,
148 std::unique_ptr<widget>
w,
150 widget* new_parent =
nullptr);
158 void remove_child(
const unsigned row,
const unsigned col);
168 void remove_child(
const std::string&
id,
const bool find_all =
false);
181 const widget*
get_widget(
const unsigned row,
const unsigned col)
const 259 virtual bool can_wrap()
const override;
278 const bool must_be_active)
override;
282 const bool must_be_active)
const override;
285 widget*
find(
const std::string&
id,
const bool must_be_active)
override;
288 const widget*
find(
const std::string&
id,
289 const bool must_be_active)
const override;
292 virtual bool has_widget(
const widget& widget)
const override;
320 void set_rows_cols(
const unsigned rows,
const unsigned cols);
365 const std::string&
id()
const;
409 return std::exchange(
widget_,
nullptr);
457 return itor_->get_widget();
462 return itor_->get_widget();
467 return i.
itor_ == this->itor_;
472 return i.
itor_ != this->itor_;
527 return children_[rows_ * col + row];
540 return children_[rows_ * col + row];
unsigned get_flags() const
static const unsigned BORDER_TOP
virtual void set_visible_rectangle(const SDL_Rect &rectangle) override
See widget::set_visible_rectangle.
std::unique_ptr< class walker_base > walker_ptr
std::vector< unsigned > row_grow_factor_
The grow factor for all rows.
ui_event
The event sent to the dispatcher.
virtual void demand_reduce_width(const unsigned maximum_width) override
See widget::demand_reduce_width.
friend class debug_layout_graph
void set_row_grow_factor(const unsigned row, const unsigned factor)
Sets the grow factor for a row.
virtual bool can_wrap() const override
See widget::can_wrap.
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
std::unique_ptr< widget > widget_
Pointer to the widget.
unsigned cols_
The number of grid columns.
iterator(std::vector< child >::iterator itor)
void set_single_child(grid &grid, std::unique_ptr< widget > widget)
Sets the single child in a grid.
grid::child & get_child(const unsigned row, const unsigned col)
Gets the grid child in the specified cell.
unsigned int get_rows() const
virtual bool has_widget(const widget &widget) const override
See widget::has_widget.
static const unsigned BORDER_ALL
static const unsigned VERTICAL_SHIFT
unsigned get_border_size() const
widget * get_widget(const unsigned row, const unsigned col)
Returns the widget in the selected cell.
bool operator!=(const iterator &i) const
grid & operator=(const grid &)=delete
Delete the move assignment operator.
static const unsigned HORIZONTAL_MASK
virtual void request_reduce_width(const unsigned maximum_width) override
See widget::request_reduce_width.
bool operator==(const iterator &i) const
point recalculate_best_size()
Recalculates the best size.
std::vector< child >::iterator itor_
unsigned rows_
The number of grid rows.
virtual void layout_initialize(const bool full_initialization) override
See widget::layout_initialize.
const grid::child & get_child(const unsigned row, const unsigned col) const
Gets the grid child in the specified cell.
virtual bool can_mouse_focus() const override
Whether the mouse move/click event go 'through' this widget.
static const unsigned HORIZONTAL_SHIFT
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
void set_flags(const unsigned flags)
virtual point calculate_best_size() const override
See widget::calculate_best_size.
Iterator for the child items.
static const unsigned HORIZONTAL_ALIGN_RIGHT
static const unsigned BORDER_BOTTOM
const std::string & id() const
Returns the id of the widget/.
std::vector< unsigned > col_grow_factor_
The grow factor for all columns.
std::vector< unsigned > row_height_
The row heights in the grid.
std::unique_ptr< widget > free_widget()
Releases widget from ownership by this child and returns it in the form of a new shared_ptr.
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
unsigned int get_cols() const
void layout(const point &origin)
Layouts the children in the grid.
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.
void place(point origin, point size)
Places the widget in the cell.
std::vector< child > children_
The child items.
virtual void place(const point &origin, const point &size) override
See widget::place.
void set_widget(std::unique_ptr< widget > widget)
Acquires an owning reference to the given widget.
static const unsigned VERTICAL_ALIGN_TOP
virtual iteration::walker_ptr create_walker() override
See widget::create_walker.
static const unsigned BORDER_RIGHT
unsigned add_row(const unsigned count=1)
Adds a row to end of the grid.
void reduce_width(const unsigned maximum_width)
Tries to reduce the width of a container.
void layout_initialize(const bool full_initialization)
Forwards grid::layout_initialize to the cell.
static const unsigned VERTICAL_ALIGN_CENTER
bool can_wrap() const
Returns the can_wrap for the cell.
static const unsigned HORIZONTAL_ALIGN_CENTER
std::vector< unsigned > col_width_
The column widths in the grid.
static const unsigned VERTICAL_MASK
void set_active(const bool active)
Activates all children.
static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT
unsigned flags_
The flags for the border and cell setup.
static const unsigned VERTICAL_GROW_SEND_TO_CLIENT
virtual void set_origin(const point &origin) override
See widget::set_origin.
virtual void request_reduce_height(const unsigned maximum_height) override
See widget::request_reduce_height.
virtual void impl_draw_children() override
See widget::impl_draw_children.
void set_rows_cols(const unsigned rows, const unsigned cols)
Wrapper to set_rows and set_cols.
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
static const unsigned VERTICAL_ALIGN_BOTTOM
void set_cols(const unsigned cols)
unsigned border_size_
The size of the border, the actual configuration of the border is determined by the flags...
void remove_child(const unsigned row, const unsigned col)
Removes and frees a widget in a cell.
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.
virtual void demand_reduce_height(const unsigned maximum_height) override
See widget::demand_reduce_height.
virtual void layout_children() override
See widget::layout_children.
void set_border_size(const unsigned border_size)
static const unsigned HORIZONTAL_ALIGN_LEFT
void set_rows(const unsigned rows)
void set_column_grow_factor(const unsigned column, const unsigned factor)
Sets the grow factor for a column.
std::unique_ptr< widget > swap_child(const std::string &id, std::unique_ptr< widget > w, const bool recurse, widget *new_parent=nullptr)
Exchanges a child in the grid.
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.
const widget * get_widget(const unsigned row, const unsigned col) const
Returns the widget in the selected cell.
const widget * get_widget() const
static const unsigned BORDER_LEFT
grid(const unsigned rows=0, const unsigned cols=0)
Helper to implement private functions without modifying the header.
point get_best_size() const
Returns the best size for the cell.
void reduce_height(const unsigned maximum_height)
Tries to reduce the height of a container.
std::string::const_iterator iterator
void set_child(std::unique_ptr< widget > widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
Sets a child in the grid.