gui2::tgrid Class Reference

Base container class which needs to size children. More...

#include <grid.hpp>

Inheritance diagram for gui2::tgrid:

Inheritance graph
[legend]
Collaboration diagram for gui2::tgrid:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 tgrid (const unsigned rows=0, const unsigned cols=0)
virtual ~tgrid ()
void add_child (twidget *widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
void set_rows (const unsigned rows)
unsigned int get_rows () const
unsigned add_row (const unsigned count=1)
 Addes a row to end of the grid.
void set_cols (const unsigned cols)
unsigned int get_cols () const
void set_rows_cols (const unsigned rows, const unsigned cols)
void set_row_grow_factor (const unsigned row, const unsigned factor)
void set_col_grow_factor (const unsigned col, const unsigned factor)
void remove_child (const unsigned row, const unsigned col)
void remove_child (const std::string &id, const bool find_all=false)
void set_active (const bool active)
 Activates all children.
bool has_vertical_scrollbar () const
 Inherited from twidget.
tpoint get_minimum_size () const
 Inherited from twidget.
tpoint get_best_size () const
 Gets the best size for the object, 0,0 means no size required.
tpoint get_maximum_size () const
 Gets the best size for an object, 0,0 means no limits.
void set_size (const SDL_Rect &rect)
 Inherited from twidget.
twidgetfind_widget (const tpoint &coordinate, const bool must_be_active)
 Inherited from twidget.
const twidgetfind_widget (const tpoint &coordinate, const bool must_be_active) const
 Inherited from twidget.
twidgetfind_widget (const std::string &id, const bool must_be_active)
 Inherited from twidget.
const twidgetfind_widget (const std::string &id, const bool must_be_active) const
 Inherited from twidget.
bool has_widget (const twidget *widget) const
 Inherited from twidget.
void draw (surface &surface)
 Inherited from twidget.
const twidgetwidget (const unsigned row, const unsigned col) const
 Returns the widget in the selected cell.
twidgetwidget (const unsigned row, const unsigned col)
 Returns the widget in the selected cell.
iterator begin ()
iterator end ()

Static Public Attributes

static const unsigned VERTICAL_GROW_SEND_TO_CLIENT = 1 << 0
static const unsigned VERTICAL_ALIGN_TOP = 3 << 1
static const unsigned VERTICAL_ALIGN_CENTER = 2 << 1
static const unsigned VERTICAL_ALIGN_BOTTOM = 1 << 1
static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT = 1 << 3
static const unsigned HORIZONTAL_ALIGN_LEFT = 3 << 4
static const unsigned HORIZONTAL_ALIGN_CENTER = 2 << 4
static const unsigned HORIZONTAL_ALIGN_RIGHT = 1 << 4
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

Private Member Functions

const tchildchild (const unsigned row, const unsigned col) const
tchildchild (const unsigned row, const unsigned col)
void clear_cache ()
void layout (const tpoint &origin)
tpoint get_size (const std::string &id, std::vector< unsigned > &width, std::vector< unsigned > &height, tpoint(tchild::*size_proc)() const) const
 Helper function to get the best or minimum size.

Private Attributes

unsigned rows_
 The number of rows / columns.
unsigned cols_
std::vector< unsigned > best_row_height_
 The optimal row heights / col widths.
std::vector< unsigned > best_col_width_
std::vector< unsigned > minimum_row_height_
 The minimal row heights / col widths.
std::vector< unsigned > minimum_col_width_
std::vector< unsigned > row_height_
 The row heights / col widths currently used.
std::vector< unsigned > col_width_
std::vector< unsigned > row_grow_factor_
 The resize factors for rows / cols.
std::vector< unsigned > col_grow_factor_
std::vector< tchildchildren_
 Contains all cells.

Classes

class  iterator
class  tchild


Detailed Description

Base container class which needs to size children.

Definition at line 26 of file grid.hpp.


Constructor & Destructor Documentation

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

Definition at line 46 of file grid.cpp.

gui2::tgrid::~tgrid (  )  [virtual]

Definition at line 61 of file grid.cpp.

References children_.


Member Function Documentation

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

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

Definition at line 102 of file grid.cpp.

References cols_, rows_, and set_rows_cols().

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

unsigned int gui2::tgrid::get_rows (  )  const [inline]

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

Addes a row to end of the grid.

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

Definition at line 111 of file grid.cpp.

References cols_, rows_, and set_rows_cols().

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

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

Definition at line 122 of file grid.cpp.

References cols_, rows_, and set_rows_cols().

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

unsigned int gui2::tgrid::get_cols (  )  const [inline]

void gui2::tgrid::set_rows_cols ( const unsigned  rows,
const unsigned  cols 
)

void gui2::tgrid::set_row_grow_factor ( const unsigned  row,
const unsigned  factor 
) [inline]

void gui2::tgrid::set_col_grow_factor ( const unsigned  col,
const unsigned  factor 
) [inline]

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

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

Definition at line 160 of file grid.cpp.

References children_, and clear_cache().

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:
active Parameter for set_active.

Definition at line 177 of file grid.cpp.

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

Referenced by set_active().

bool gui2::tgrid::has_vertical_scrollbar (  )  const [virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 200 of file grid.cpp.

References children_, and gui2::twidget::has_vertical_scrollbar().

Referenced by set_size().

tpoint gui2::tgrid::get_minimum_size (  )  const [virtual]

Inherited from twidget.

Implements gui2::twidget.

Definition at line 216 of file grid.cpp.

References gui2::tgrid::tchild::get_minimum_size(), get_size(), minimum_col_width_, and minimum_row_height_.

tpoint gui2::tgrid::get_best_size (  )  const [virtual]

Gets the best size for the object, 0,0 means no size required.

Implements gui2::twidget.

Definition at line 228 of file grid.cpp.

References best_col_width_, best_row_height_, gui2::tgrid::tchild::get_best_size(), and get_size().

Referenced by gui2::tlistbox::get_best_size(), gui2::tcontainer_::get_best_size(), gui2::tlistbox::set_size(), and set_size().

tpoint gui2::tgrid::get_maximum_size (  )  const [virtual]

Gets the best size for an object, 0,0 means no limits.

Implements gui2::twidget.

Definition at line 222 of file grid.cpp.

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

void gui2::tgrid::set_size ( const SDL_Rect &  rect  )  [virtual]

twidget * gui2::tgrid::find_widget ( const tpoint coordinate,
const bool  must_be_active 
) [virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 416 of file grid.cpp.

References children_, clear_cache(), gui2::twidget::find_widget(), and widget().

Referenced by gui2::tlistbox::find_widget(), and gui2::tcontainer_::find_widget().

const twidget * gui2::tgrid::find_widget ( const tpoint coordinate,
const bool  must_be_active 
) const [virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 437 of file grid.cpp.

References children_, gui2::twidget::find_widget(), and widget().

twidget * gui2::tgrid::find_widget ( const std::string &  id,
const bool  must_be_active 
) [virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 458 of file grid.cpp.

References children_, clear_cache(), gui2::twidget::find_widget(), and widget().

const twidget * gui2::tgrid::find_widget ( const std::string &  id,
const bool  must_be_active 
) const [virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 479 of file grid.cpp.

References children_, gui2::twidget::find_widget(), and widget().

bool gui2::tgrid::has_widget ( const twidget widget  )  const [virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 500 of file grid.cpp.

References children_.

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

void gui2::tgrid::draw ( surface surface  )  [virtual]

Inherited from twidget.

Implements gui2::twidget.

Definition at line 512 of file grid.cpp.

References begin(), end(), lg::gui_draw, log_scope2, and gui2::twidget::set_dirty().

Referenced by gui2::tlistbox::draw(), and gui2::tcontainer_::draw().

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 136 of file grid.hpp.

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

iterator gui2::tgrid::begin (  )  [inline]

Definition at line 248 of file grid.hpp.

References children_.

Referenced by gui2::tcontainer_::begin(), and draw().

iterator gui2::tgrid::end (  )  [inline]

Definition at line 249 of file grid.hpp.

References children_.

Referenced by draw(), and gui2::tcontainer_::end().

const tchild& gui2::tgrid::child ( const unsigned  row,
const unsigned  col 
) const [inline, private]

Definition at line 274 of file grid.hpp.

References children_, and rows_.

Referenced by add_child(), get_size(), layout(), remove_child(), and widget().

tchild& gui2::tgrid::child ( const unsigned  row,
const unsigned  col 
) [inline, private]

Definition at line 276 of file grid.hpp.

References children_, clear_cache(), and rows_.

void gui2::tgrid::clear_cache (  )  [private]

void gui2::tgrid::layout ( const tpoint origin  )  [private]

tpoint gui2::tgrid::get_size ( const std::string &  id,
std::vector< unsigned > &  width,
std::vector< unsigned > &  height,
tpoint(tchild::*)() const   size_proc 
) const [private]

Helper function to get the best or minimum size.

Parameters:
id Name to use in debug output.
width Reference to the vector width cache for the size function of the caller.
height Reference to the vector height cache for the size function of the caller.
size_proc The function to call on the cells in order to get their sizes.
Returns:
The wanted size.

Definition at line 245 of file grid.cpp.

References child(), cols_, DBG_G, rows_, size, gui2::tpoint::x, and gui2::tpoint::y.

Referenced by get_best_size(), and get_minimum_size().


Member Data Documentation

const unsigned gui2::tgrid::VERTICAL_GROW_SEND_TO_CLIENT = 1 << 0 [static]

const unsigned gui2::tgrid::VERTICAL_ALIGN_TOP = 3 << 1 [static]

const unsigned gui2::tgrid::VERTICAL_ALIGN_CENTER = 2 << 1 [static]

const unsigned gui2::tgrid::VERTICAL_ALIGN_BOTTOM = 1 << 1 [static]

const unsigned gui2::tgrid::HORIZONTAL_GROW_SEND_TO_CLIENT = 1 << 3 [static]

const unsigned gui2::tgrid::HORIZONTAL_ALIGN_LEFT = 3 << 4 [static]

const unsigned gui2::tgrid::HORIZONTAL_ALIGN_CENTER = 2 << 4 [static]

const unsigned gui2::tgrid::HORIZONTAL_ALIGN_RIGHT = 1 << 4 [static]

const unsigned gui2::tgrid::BORDER_TOP = 1 << 6 [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]

unsigned gui2::tgrid::rows_ [private]

The number of rows / columns.

Definition at line 253 of file grid.hpp.

Referenced by add_child(), add_row(), child(), get_rows(), get_size(), layout(), remove_child(), set_cols(), set_rows(), set_rows_cols(), and set_size().

unsigned gui2::tgrid::cols_ [private]

std::vector<unsigned> gui2::tgrid::best_row_height_ [mutable, private]

The optimal row heights / col widths.

Definition at line 257 of file grid.hpp.

Referenced by clear_cache(), get_best_size(), and set_size().

std::vector<unsigned> gui2::tgrid::best_col_width_ [mutable, private]

Definition at line 258 of file grid.hpp.

Referenced by clear_cache(), get_best_size(), and set_size().

std::vector<unsigned> gui2::tgrid::minimum_row_height_ [mutable, private]

The minimal row heights / col widths.

Definition at line 261 of file grid.hpp.

Referenced by clear_cache(), and get_minimum_size().

std::vector<unsigned> gui2::tgrid::minimum_col_width_ [mutable, private]

Definition at line 262 of file grid.hpp.

Referenced by clear_cache(), and get_minimum_size().

std::vector<unsigned> gui2::tgrid::row_height_ [private]

The row heights / col widths currently used.

Definition at line 265 of file grid.hpp.

Referenced by layout(), and set_size().

std::vector<unsigned> gui2::tgrid::col_width_ [private]

Definition at line 266 of file grid.hpp.

Referenced by layout(), and set_size().

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

The resize factors for rows / cols.

Definition at line 269 of file grid.hpp.

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

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

Definition at line 270 of file grid.hpp.

Referenced by set_col_grow_factor(), set_rows_cols(), and set_size().

std::vector<tchild> gui2::tgrid::children_ [private]

Contains all cells.

Definition at line 273 of file grid.hpp.

Referenced by begin(), child(), end(), find_widget(), has_vertical_scrollbar(), has_widget(), remove_child(), set_active(), set_rows_cols(), and ~tgrid().


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

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs