The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
gui2::tgrid Class Reference

Base container class. More...

#include <grid.hpp>

Inheritance diagram for gui2::tgrid:
Inheritance graph

Classes

class  iterator
 Iterator for the tchild items. More...
 
class  tchild
 Child item of the grid. More...
 

Public Member Functions

 tgrid (const unsigned rows=0, const unsigned cols=0)
 
virtual ~tgrid ()
 
unsigned add_row (const unsigned count=1)
 Adds a row to end of the grid. More...
 
void set_row_grow_factor (const unsigned row, const unsigned factor)
 Sets the grow factor for a row. More...
 
void set_column_grow_factor (const unsigned column, const unsigned factor)
 Sets the grow factor for a column. More...
 
void set_child (twidget *widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
 Sets a child in the grid. More...
 
twidgetswap_child (const std::string &id, twidget *widget, const bool recurse, twidget *new_parent=nullptr)
 Exchanges a child in the grid. More...
 
void remove_child (const unsigned row, const unsigned col)
 Removes and frees a widget in a cell. More...
 
void remove_child (const std::string &id, const bool find_all=false)
 Removes and frees a widget in a cell by it's id. More...
 
void set_active (const bool active)
 Activates all children. More...
 
const twidgetwidget (const unsigned row, const unsigned col) const
 Returns the widget in the selected cell. More...
 
twidgetwidget (const unsigned row, const unsigned col)
 Returns the widget in the selected cell. More...
 
virtual bool can_mouse_focus () const override
 Whether the mouse move/click event go 'through' this widget. More...
 
virtual void layout_initialise (const bool full_initialisation) override
 See twidget::layout_initialise. More...
 
void reduce_width (const unsigned maximum_width)
 Tries to reduce the width of a container. More...
 
virtual void request_reduce_width (const unsigned maximum_width) override
 See twidget::request_reduce_width. More...
 
virtual void demand_reduce_width (const unsigned maximum_width) override
 See twidget::demand_reduce_width. More...
 
void reduce_height (const unsigned maximum_height)
 Tries to reduce the height of a container. More...
 
virtual void request_reduce_height (const unsigned maximum_height) override
 See twidget::request_reduce_height. More...
 
virtual void demand_reduce_height (const unsigned maximum_height) override
 See twidget::demand_reduce_height. More...
 
tpoint recalculate_best_size ()
 Recalculates the best size. More...
 
virtual bool can_wrap () const override
 See twidget::can_wrap. More...
 
virtual void place (const tpoint &origin, const tpoint &size) override
 See twidget::place. More...
 
virtual void set_origin (const tpoint &origin) override
 See twidget::set_origin. More...
 
virtual void set_visible_rectangle (const SDL_Rect &rectangle) override
 See twidget::set_visible_rectangle. More...
 
virtual void layout_children () override
 See twidget::layout_children. More...
 
virtual void child_populate_dirty_list (twindow &caller, const std::vector< twidget * > &call_stack) override
 See twidget::child_populate_dirty_list. More...
 
virtual twidgetfind_at (const tpoint &coordinate, const bool must_be_active) override
 See twidget::find_at. More...
 
virtual const twidgetfind_at (const tpoint &coordinate, const bool must_be_active) const override
 See twidget::find_at. More...
 
twidgetfind (const std::string &id, const bool must_be_active) override
 See twidget::find. More...
 
const twidgetfind (const std::string &id, const bool must_be_active) const override
 See twidget::find. More...
 
virtual bool has_widget (const twidget &widget) const override
 See twidget::has_widget. More...
 
bool disable_click_dismiss () const override
 See twidget::disable_click_dismiss. More...
 
virtual iterator::twalker_create_walker () override
 See twidget::create_walker. More...
 
void set_rows (const unsigned rows)
 
unsigned int get_rows () const
 
void set_cols (const unsigned cols)
 
unsigned int get_cols () const
 
void set_rows_cols (const unsigned rows, const unsigned cols)
 Wrapper to set_rows and set_cols. More...
 
iterator begin ()
 
iterator end ()
 
- Public Member Functions inherited from gui2::twidget
 twidget ()
 
 twidget (const tbuilder_widget &builder)
 Constructor. More...
 
virtual ~twidget () override
 
void set_id (const std::string &id)
 
const std::stringid () const
 
twindowget_window ()
 Get the parent window. More...
 
const twindowget_window () const
 The constant version of get_window. More...
 
tdialogdialog ()
 Returns the top-level dialogue. More...
 
void set_parent (twidget *parent)
 
twidgetparent ()
 
tpoint get_best_size () const
 Gets the best size for the widget. More...
 
virtual void set_size (const tpoint &size)
 Sets the size of the widget. More...
 
virtual void move (const int x_offset, const int y_offset)
 Moves a widget. More...
 
tpoint get_origin () const
 Returns the screen origin of the widget. More...
 
tpoint get_size () const
 Returns the size of the widget. More...
 
SDL_Rect get_rectangle () const
 Gets the bounding rectangle of the widget on the screen. More...
 
int get_x () const
 
int get_y () const
 
unsigned get_width () const
 
unsigned get_height () const
 
void set_linked_group (const std::string &linked_group)
 
SDL_Rect calculate_blitting_rectangle (const int x_offset, const int y_offset)
 Calculates the blitting rectangle of the widget. More...
 
SDL_Rect calculate_clipping_rectangle (const int x_offset, const int y_offset)
 Calculates the clipping rectangle of the widget. More...
 
void draw_background (surface &frame_buffer, int x_offset, int y_offset)
 Draws the background of a widget. More...
 
void draw_children (surface &frame_buffer, int x_offset, int y_offset)
 Draws the children of a widget. More...
 
void draw_foreground (surface &frame_buffer, int x_offset, int y_offset)
 Draws the foreground of the widget. More...
 
void populate_dirty_list (twindow &caller, std::vector< twidget * > &call_stack)
 Adds a widget to the dirty list if it is dirty. More...
 
SDL_Rect get_dirty_rectangle () const
 Gets the dirty rectangle of the widget. More...
 
void set_is_dirty (const bool is_dirty)
 
bool get_is_dirty () const
 
void set_visible (const tvisible::scoped_enum visible)
 
tvisible::scoped_enum get_visible () const
 
tredraw_action::scoped_enum get_drawing_action () const
 
void set_debug_border_mode (const unsigned debug_border_mode)
 
void set_debug_border_colour (const unsigned debug_border_colour)
 
- Public Member Functions inherited from gui2::tevent_executor
 tevent_executor ()
 
virtual ~tevent_executor ()
 
void set_wants_mouse_hover (const bool hover=true)
 
bool wants_mouse_hover () const
 
void set_wants_mouse_left_double_click (const bool click=true)
 
bool wants_mouse_left_double_click () const
 
void set_wants_mouse_middle_double_click (const bool click=true)
 
bool wants_mouse_middle_double_click () const
 
tevent_executorset_wants_mouse_right_double_click (const bool click=true)
 
bool wants_mouse_right_double_click () const
 
- Public Member Functions inherited from gui2::event::tdispatcher
 tdispatcher ()
 
virtual ~tdispatcher ()
 
void connect ()
 Connects the dispatcher to the event handler. More...
 
bool has_event (const tevent event, const tevent_type event_type)
 
bool fire (const tevent event, twidget &target)
 Fires an event which has no extra parameters. More...
 
bool fire (const tevent event, twidget &target, const tpoint &coordinate)
 Fires an event which takes a coordinate parameter. More...
 
bool fire (const tevent event, twidget &target, const SDLKey key, const SDLMod modifier, const utf8::string &unicode)
 Fires an event which takes keyboard parameters. More...
 
bool fire (const tevent event, twidget &target, void *)
 Fires an event which takes notification parameters. More...
 
bool fire (const tevent event, twidget &target, tmessage &message)
 Fires an event which takes message parameters. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event, boost::mpl::int_
< E > > >::type 
connect_signal (const tsignal_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event, boost::mpl::int_
< E > > >::type 
disconnect_signal (const tsignal_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_mouse,
boost::mpl::int_< E >
> >::type 
connect_signal (const tsignal_mouse_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event_mouse. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_mouse,
boost::mpl::int_< E >
> >::type 
disconnect_signal (const tsignal_mouse_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event_mouse. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_keyboard,
boost::mpl::int_< E >
> >::type 
connect_signal (const tsignal_keyboard_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event_keyboard. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_keyboard,
boost::mpl::int_< E >
> >::type 
disconnect_signal (const tsignal_keyboard_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event_keyboard. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_notification,
boost::mpl::int_< E >
> >::type 
connect_signal (const tsignal_notification_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event_notification. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_notification,
boost::mpl::int_< E >
> >::type 
disconnect_signal (const tsignal_notification_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event_notification. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_message,
boost::mpl::int_< E >
> >::type 
connect_signal (const tsignal_message_function &signal, const tposition position=back_child)
 Connect a signal for callback in tset_event_message. More...
 
template<tevent E>
boost::enable_if
< boost::mpl::has_key
< tset_event_message,
boost::mpl::int_< E >
> >::type 
disconnect_signal (const tsignal_message_function &signal, const tposition position=back_child)
 Disconnect a signal for callback in tset_event_message. More...
 
void capture_mouse ()
 Captures the mouse. More...
 
void release_mouse ()
 Releases the mouse capture. More...
 
void set_mouse_behavior (const tmouse_behavior mouse_behavior)
 
tmouse_behavior get_mouse_behavior () const
 
void set_want_keyboard_input (const bool want_keyboard_input)
 
bool get_want_keyboard_input () const
 
void register_hotkey (const hotkey::HOTKEY_COMMAND id, const thotkey_function &function)
 Registers a hotkey. More...
 
bool execute_hotkey (const hotkey::HOTKEY_COMMAND id)
 Executes a hotkey. More...
 

Static Public Attributes

static const unsigned VERTICAL_SHIFT = 0
 
static const unsigned VERTICAL_GROW_SEND_TO_CLIENT = 1 << VERTICAL_SHIFT
 
static const unsigned VERTICAL_ALIGN_TOP = 2 << VERTICAL_SHIFT
 
static const unsigned VERTICAL_ALIGN_CENTER = 3 << VERTICAL_SHIFT
 
static const unsigned VERTICAL_ALIGN_BOTTOM = 4 << VERTICAL_SHIFT
 
static const unsigned VERTICAL_MASK = 7 << VERTICAL_SHIFT
 
static const unsigned HORIZONTAL_SHIFT = 3
 
static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT
 
static const unsigned HORIZONTAL_ALIGN_LEFT = 2 << HORIZONTAL_SHIFT
 
static const unsigned HORIZONTAL_ALIGN_CENTER = 3 << HORIZONTAL_SHIFT
 
static const unsigned HORIZONTAL_ALIGN_RIGHT = 4 << HORIZONTAL_SHIFT
 
static const unsigned HORIZONTAL_MASK = 7 << HORIZONTAL_SHIFT
 
static const unsigned BORDER_TOP = 1 << 6
 
static const unsigned BORDER_BOTTOM = 1 << 7
 
static const unsigned BORDER_LEFT = 1 << 8
 
static const unsigned BORDER_RIGHT = 1 << 9
 
static const unsigned BORDER_ALL
 

Private Member Functions

virtual tpoint calculate_best_size () const override
 See twidget::calculate_best_size. More...
 
const tchildchild (const unsigned row, const unsigned col) const
 
tchildchild (const unsigned row, const unsigned col)
 
void layout (const tpoint &origin)
 Layouts the children in the grid. More...
 
virtual void impl_draw_children (surface &frame_buffer, int x_offset, int y_offset) override
 See twidget::impl_draw_children. More...
 

Private Attributes

unsigned rows_
 The number of grid rows. More...
 
unsigned cols_
 The number of grid columns. More...
 
std::vector< unsigned > row_height_
 The row heights in the grid. More...
 
std::vector< unsigned > col_width_
 The column widths in the grid. More...
 
std::vector< unsigned > row_grow_factor_
 The grow factor for all rows. More...
 
std::vector< unsigned > col_grow_factor_
 The grow factor for all columns. More...
 
std::vector< tchildchildren_
 The child items. More...
 

Friends

class tdebug_layout_graph
 
struct tgrid_implementation
 

Additional Inherited Members

- Public Types inherited from gui2::event::tdispatcher
enum  tevent_type { pre = 1, child = 2, post = 4 }
 
enum  tposition {
  front_pre_child, back_pre_child, front_child, back_child,
  front_post_child, back_post_child
}
 The position where to add a new callback in the signal handler. More...
 
enum  tmouse_behavior { all, hit, none }
 The behavior of the mouse events. More...
 
- Protected Member Functions inherited from gui2::twidget
void set_layout_size (const tpoint &size)
 
const tpointlayout_size () const
 

Detailed Description

Base container class.

This class holds a number of widgets and their wanted layout parameters. It also layouts the items in the grid and handles their drawing.

Definition at line 29 of file grid.hpp.

Constructor & Destructor Documentation

gui2::tgrid::tgrid ( const unsigned  rows = 0,
const unsigned  cols = 0 
)
explicit

Definition at line 37 of file grid.cpp.

gui2::tgrid::~tgrid ( )
virtual

Definition at line 48 of file grid.cpp.

References child(), children_, and gui2::tgrid::tchild::widget().

Member Function Documentation

unsigned gui2::tgrid::add_row ( const unsigned  count = 1)

Adds a row to end of the grid.

Parameters
countNumber of rows to add, should be > 0.
Returns
The row number of the first row added.

Definition at line 58 of file grid.cpp.

References cols_, rows_, and set_rows_cols().

Referenced by gui2::tcontainer_::add_row().

iterator gui2::tgrid::begin ( )
inline
tpoint gui2::tgrid::calculate_best_size ( ) const
overrideprivatevirtual
virtual bool gui2::tgrid::can_mouse_focus ( ) const
inlineoverridevirtual

Whether the mouse move/click event go 'through' this widget.

Reimplemented from gui2::twidget.

Definition at line 187 of file grid.hpp.

bool gui2::tgrid::can_wrap ( ) const
overridevirtual
const tchild& gui2::tgrid::child ( const unsigned  row,
const unsigned  col 
) const
inlineprivate
tchild& gui2::tgrid::child ( const unsigned  row,
const unsigned  col 
)
inlineprivate

Definition at line 481 of file grid.hpp.

void gui2::tgrid::child_populate_dirty_list ( twindow caller,
const std::vector< twidget * > &  call_stack 
)
overridevirtual
iterator::twalker_ * gui2::tgrid::create_walker ( )
overridevirtual

See twidget::create_walker.

Implements gui2::twidget.

Definition at line 656 of file grid.cpp.

Referenced by gui2::tselect_orb_colors::setup_orb_group().

void gui2::tgrid::demand_reduce_height ( const unsigned  maximum_height)
overridevirtual

See twidget::demand_reduce_height.

Todo:
Implement.

Reimplemented from gui2::twidget.

Definition at line 366 of file grid.cpp.

Referenced by gui2::tcontainer_::demand_reduce_height().

void gui2::tgrid::demand_reduce_width ( const unsigned  maximum_width)
overridevirtual

See twidget::demand_reduce_width.

Todo:
Implement.

Reimplemented from gui2::twidget.

Definition at line 275 of file grid.cpp.

Referenced by gui2::tcontainer_::demand_reduce_width().

bool gui2::tgrid::disable_click_dismiss ( ) const
overridevirtual
iterator gui2::tgrid::end ( )
inline
twidget * gui2::tgrid::find ( const std::string id,
const bool  must_be_active 
)
overridevirtual
const twidget * gui2::tgrid::find ( const std::string id,
const bool  must_be_active 
) const
overridevirtual

See twidget::find.

Reimplemented from gui2::twidget.

Definition at line 617 of file grid.cpp.

References gui2::twidget::id().

twidget * gui2::tgrid::find_at ( const tpoint coordinate,
const bool  must_be_active 
)
overridevirtual
const twidget * gui2::tgrid::find_at ( const tpoint coordinate,
const bool  must_be_active 
) const
overridevirtual

See twidget::find_at.

Reimplemented from gui2::twidget.

Definition at line 605 of file grid.cpp.

unsigned int gui2::tgrid::get_cols ( ) const
inline
unsigned int gui2::tgrid::get_rows ( ) const
inline
bool gui2::tgrid::has_widget ( const twidget widget) const
overridevirtual
void gui2::tgrid::impl_draw_children ( surface frame_buffer,
int  x_offset,
int  y_offset 
)
overrideprivatevirtual
void gui2::tgrid::layout ( const tpoint origin)
private

Layouts the children in the grid.

Definition at line 886 of file grid.cpp.

References child(), col_width_, cols_, DBG_GUI_L, LOG_HEADER, gui2::tgrid::tchild::place(), row_height_, rows_, widget(), gui2::tpoint::x, and gui2::tpoint::y.

Referenced by place().

void gui2::tgrid::layout_children ( )
overridevirtual
void gui2::tgrid::layout_initialise ( const bool  full_initialisation)
overridevirtual
void gui2::tgrid::place ( const tpoint origin,
const tpoint size 
)
overridevirtual
tpoint gui2::tgrid::recalculate_best_size ( )

Recalculates the best size.

This is used for scrollbar containers when they try to update their contents size before falling back to the 'global' invalidate_layout.

Returns
The newly calculated size.

Definition at line 371 of file grid.cpp.

References calculate_best_size(), and gui2::twidget::set_layout_size().

Referenced by gui2::tscrollbar_container::content_resize_request().

void gui2::tgrid::reduce_height ( const unsigned  maximum_height)

Tries to reduce the height of a container.

See Layout algorithm for more information.

Parameters
maximum_heightThe wanted maximum height.
Todo:
Implement.

Definition at line 280 of file grid.cpp.

References DBG_GUI_L, gui2::twidget::get_best_size(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, request_reduce_height(), and gui2::tpoint::y.

Referenced by gui2::tcontainer_::reduce_height().

void gui2::tgrid::reduce_width ( const unsigned  maximum_width)

Tries to reduce the width of a container.

See Layout algorithm for more information.

Parameters
maximum_widthThe wanted maximum width.
Todo:
Implement.

Definition at line 204 of file grid.cpp.

References DBG_GUI_L, gui2::twidget::get_best_size(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, request_reduce_width(), and gui2::tpoint::x.

Referenced by gui2::tcontainer_::reduce_width().

void gui2::tgrid::remove_child ( const unsigned  row,
const unsigned  col 
)

Removes and frees a widget in a cell.

Parameters
rowThe row of the cell.
colThe columnof the cell.

Definition at line 140 of file grid.cpp.

References child(), cols_, rows_, gui2::tgrid::tchild::set_widget(), and gui2::tgrid::tchild::widget().

Referenced by gui2::twindow::~twindow().

void gui2::tgrid::remove_child ( const std::string id,
const bool  find_all = false 
)

Removes and frees a widget in a cell by it's id.

Parameters
idThe id of the widget to free.
find_allIf true if removes all items with the id, otherwise it stops after removing the first item (or once all children have been tested).

Definition at line 152 of file grid.cpp.

References child(), children_, gui2::twidget::id(), gui2::tgrid::tchild::id(), gui2::tgrid::tchild::set_widget(), and gui2::tgrid::tchild::widget().

void gui2::tgrid::request_reduce_height ( const unsigned  maximum_height)
overridevirtual

See twidget::request_reduce_height.

Todo:
this point shouldn't be reached, find out why it does.
Todo:
Improve this code.

Now we try every item to be reduced, maybe items need a flag whether or not to try to reduce and also evaluate whether the force reduction is still needed.

Reimplemented from gui2::twidget.

Definition at line 313 of file grid.cpp.

References calculate_best_size(), DBG_GUI_L, gui2::twidget::get_best_size(), LOG_HEADER, row_height_, gui2::tgrid_implementation::row_request_reduce_height(), rows_, gui2::twidget::set_layout_size(), and gui2::tpoint::y.

Referenced by reduce_height(), gui2::tcontainer_::request_reduce_height(), gui2::tscrollbar_container::request_reduce_height(), and gui2::policy::placement::tindependent::request_reduce_height().

void gui2::tgrid::request_reduce_width ( const unsigned  maximum_width)
overridevirtual
void gui2::tgrid::set_active ( const bool  active)

Activates all children.

If a child inherits from tcontrol or is a tgrid it will call set_active() for the child otherwise it ignores the widget.

Parameters
activeParameter for set_active.

Definition at line 168 of file grid.cpp.

References child(), children_, preferences::grid(), gui2::tcontrol::set_active(), set_active(), widget(), and gui2::tgrid::tchild::widget().

Referenced by gui2::tcontainer_::set_active(), set_active(), and gui2::tlistbox::set_row_active().

void gui2::tgrid::set_child ( twidget widget,
const unsigned  row,
const unsigned  col,
const unsigned  flags,
const unsigned  border_size 
)

Sets a child in the grid.

When the child is added to the grid the grid 'owns' the widget. The widget is put in a cell, and every cell can only contain 1 widget if the wanted cell already contains a widget, that widget is freed and removed.

Parameters
widgetThe widget to put in the grid.
rowThe row of the cell.
colThe columnof the cell.
flagsThe flags for the widget in the cell.
border_sizeThe size of the border for the cell, how the border is applied depends on the flags.

Definition at line 69 of file grid.cpp.

References child(), cols_, HORIZONTAL_MASK, gui2::tgrid::tchild::id(), LOG_HEADER, rows_, gui2::tgrid::tchild::set_border_size(), gui2::tgrid::tchild::set_flags(), gui2::twidget::set_parent(), gui2::tgrid::tchild::set_widget(), VERTICAL_MASK, gui2::tgrid::tchild::widget(), and WRN_GUI_G.

Referenced by add_widget(), gui2::implementation::tbuilder_scrollbar_panel::build(), gui2::tbuilder_grid::build(), gui2::implementation::tbuilder_listbox::build(), gui2::ttree_view::finalize_setup(), gui2::tcontainer_::set_child(), and gui2::set_single_child().

void gui2::tgrid::set_cols ( const unsigned  cols)

Definition at line 670 of file grid.cpp.

References cols_, rows_, and set_rows_cols().

Referenced by gui2::tcontainer_::set_cols().

void gui2::tgrid::set_column_grow_factor ( const unsigned  column,
const unsigned  factor 
)
inline

Sets the grow factor for a column.

Todo:
refer to a page with the layout manipulation info.
Parameters
columnThe column to modify.
factorThe grow factor.

Definition at line 96 of file grid.hpp.

References col_grow_factor_, and gui2::twidget::set_is_dirty().

Referenced by gui2::implementation::tbuilder_scrollbar_panel::build(), gui2::tbuilder_grid::build(), and gui2::tcontainer_::set_column_grow_factor().

void gui2::tgrid::set_origin ( const tpoint origin)
overridevirtual
void gui2::tgrid::set_row_grow_factor ( const unsigned  row,
const unsigned  factor 
)
inline

Sets the grow factor for a row.

Todo:
refer to a page with the layout manipulation info.
Parameters
rowThe row to modify.
factorThe grow factor.

Definition at line 81 of file grid.hpp.

References row_grow_factor_, and gui2::twidget::set_is_dirty().

Referenced by gui2::implementation::tbuilder_scrollbar_panel::build(), gui2::tbuilder_grid::build(), and gui2::tcontainer_::set_row_grow_factor().

void gui2::tgrid::set_rows ( const unsigned  rows)

Definition at line 661 of file grid.cpp.

References cols_, rows_, and set_rows_cols().

Referenced by gui2::tcontainer_::set_rows().

void gui2::tgrid::set_rows_cols ( const unsigned  rows,
const unsigned  cols 
)
void gui2::tgrid::set_visible_rectangle ( const SDL_Rect &  rectangle)
overridevirtual
twidget * gui2::tgrid::swap_child ( const std::string id,
twidget widget,
const bool  recurse,
twidget new_parent = nullptr 
)

Exchanges a child in the grid.

It replaced the child with a certain id with the new widget but doesn't touch the other settings of the child.

Parameters
idThe id of the widget to free.
widgetThe widget to put in the grid.
recurseDo we want to decent into the child grids.
new_parentThe new parent for the swapped out widget.

returns The widget which got removed (the parent of the widget is cleared). If no widget found and thus not replace nullptr will returned.

Definition at line 99 of file grid.cpp.

References child(), children_, gui2::twidget::get_visible(), preferences::grid(), gui2::twidget::id(), gui2::tgrid::tchild::id(), gui2::twidget::set_parent(), gui2::twidget::set_visible(), gui2::tgrid::tchild::set_widget(), swap_child(), and gui2::tgrid::tchild::widget().

Referenced by gui2::tscrollbar_container::finalize_setup(), gui2::tpreferences::initialize_members(), and swap_child().

const twidget* gui2::tgrid::widget ( const unsigned  row,
const unsigned  col 
) const
inline
twidget* gui2::tgrid::widget ( const unsigned  row,
const unsigned  col 
)
inline

Returns the widget in the selected cell.

Definition at line 182 of file grid.hpp.

References child(), and gui2::tgrid::tchild::widget().

Friends And Related Function Documentation

friend class tdebug_layout_graph
friend

Definition at line 31 of file grid.hpp.

friend struct tgrid_implementation
friend

Definition at line 32 of file grid.hpp.

Member Data Documentation

const unsigned gui2::tgrid::BORDER_ALL
static
const unsigned gui2::tgrid::BORDER_BOTTOM = 1 << 7
static
const unsigned gui2::tgrid::BORDER_LEFT = 1 << 8
static
const unsigned gui2::tgrid::BORDER_RIGHT = 1 << 9
static
const unsigned gui2::tgrid::BORDER_TOP = 1 << 6
static
std::vector<tchild> gui2::tgrid::children_
private

The child items.

All children are stored in a 1D vector and the formula to access a cell is: rows_ * col + row. All other vectors use the same access formula.

Definition at line 476 of file grid.hpp.

Referenced by begin(), can_wrap(), child_populate_dirty_list(), disable_click_dismiss(), end(), has_widget(), impl_draw_children(), layout_children(), layout_initialise(), remove_child(), set_active(), set_origin(), set_rows_cols(), set_visible_rectangle(), swap_child(), and ~tgrid().

std::vector<unsigned> gui2::tgrid::col_grow_factor_
private

The grow factor for all columns.

Definition at line 468 of file grid.hpp.

Referenced by place(), set_column_grow_factor(), and set_rows_cols().

std::vector<unsigned> gui2::tgrid::col_width_
mutableprivate

The column widths in the grid.

Definition at line 462 of file grid.hpp.

Referenced by calculate_best_size(), layout(), place(), and request_reduce_width().

unsigned gui2::tgrid::cols_
private
const unsigned gui2::tgrid::HORIZONTAL_ALIGN_CENTER = 3 << HORIZONTAL_SHIFT
static
const unsigned gui2::tgrid::HORIZONTAL_ALIGN_LEFT = 2 << HORIZONTAL_SHIFT
static
const unsigned gui2::tgrid::HORIZONTAL_ALIGN_RIGHT = 4 << HORIZONTAL_SHIFT
static
const unsigned gui2::tgrid::HORIZONTAL_GROW_SEND_TO_CLIENT
static
const unsigned gui2::tgrid::HORIZONTAL_MASK = 7 << HORIZONTAL_SHIFT
static

Definition at line 53 of file grid.hpp.

Referenced by gui2::tgrid::tchild::place(), and set_child().

const unsigned gui2::tgrid::HORIZONTAL_SHIFT = 3
static

Definition at line 47 of file grid.hpp.

std::vector<unsigned> gui2::tgrid::row_grow_factor_
private

The grow factor for all rows.

Definition at line 465 of file grid.hpp.

Referenced by place(), set_row_grow_factor(), and set_rows_cols().

std::vector<unsigned> gui2::tgrid::row_height_
mutableprivate

The row heights in the grid.

Definition at line 459 of file grid.hpp.

Referenced by calculate_best_size(), layout(), place(), and request_reduce_height().

unsigned gui2::tgrid::rows_
private
const unsigned gui2::tgrid::VERTICAL_ALIGN_BOTTOM = 4 << VERTICAL_SHIFT
static
const unsigned gui2::tgrid::VERTICAL_ALIGN_CENTER = 3 << VERTICAL_SHIFT
static
const unsigned gui2::tgrid::VERTICAL_ALIGN_TOP = 2 << VERTICAL_SHIFT
static
const unsigned gui2::tgrid::VERTICAL_GROW_SEND_TO_CLIENT = 1 << VERTICAL_SHIFT
static
const unsigned gui2::tgrid::VERTICAL_MASK = 7 << VERTICAL_SHIFT
static

Definition at line 45 of file grid.hpp.

Referenced by gui2::tgrid::tchild::place(), and set_child().

const unsigned gui2::tgrid::VERTICAL_SHIFT = 0
static

Definition at line 40 of file grid.hpp.


The documentation for this class was generated from the following files: