#include <grid.hpp>
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. | |
twidget * | find_widget (const tpoint &coordinate, const bool must_be_active) |
Inherited from twidget. | |
const twidget * | find_widget (const tpoint &coordinate, const bool must_be_active) const |
Inherited from twidget. | |
twidget * | find_widget (const std::string &id, const bool must_be_active) |
Inherited from twidget. | |
const twidget * | find_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 twidget * | widget (const unsigned row, const unsigned col) const |
Returns the widget in the selected cell. | |
twidget * | widget (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 tchild & | child (const unsigned row, const unsigned col) const |
tchild & | child (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< tchild > | children_ |
Contains all cells. | |
Classes | |
class | iterator |
class | tchild |
Definition at line 26 of file grid.hpp.
gui2::tgrid::tgrid | ( | const unsigned | rows = 0 , |
|
const unsigned | cols = 0 | |||
) |
void gui2::tgrid::add_child | ( | twidget * | widget, | |
const unsigned | row, | |||
const unsigned | col, | |||
const unsigned | flags, | |||
const unsigned | border_size | |||
) |
Definition at line 72 of file grid.cpp.
References child(), clear_cache(), cols_, gui2::twidget::id(), gui2::tgrid::tchild::id(), rows_, gui2::tgrid::tchild::set_border_size(), gui2::tgrid::tchild::set_flags(), gui2::tgrid::tchild::set_id(), gui2::twidget::set_parent(), gui2::tgrid::tchild::set_widget(), gui2::tgrid::tchild::widget(), and WRN_G.
Referenced by gui2::tcontainer_::add_child(), gui2::tbuilder_grid::build(), and gui2::tbuilder_listbox::build().
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] |
Definition at line 57 of file grid.hpp.
References rows_.
Referenced by gui2::tlistbox::finalize_setup(), gui2::tcontainer_::get_rows(), gui2::tlistbox::trow::init_in_grid(), and gui2::tlistbox::trow::select_in_grid().
unsigned gui2::tgrid::add_row | ( | const unsigned | count = 1 |
) |
Addes a row to end of the grid.
count | Number of rows to add, should be > 0. |
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] |
Definition at line 69 of file grid.hpp.
References cols_.
Referenced by gui2::tlistbox::finalize_setup(), gui2::tcontainer_::get_cols(), gui2::tlistbox::trow::init_in_grid(), and gui2::tlistbox::trow::select_in_grid().
void gui2::tgrid::set_rows_cols | ( | const unsigned | rows, | |
const unsigned | cols | |||
) |
Definition at line 131 of file grid.cpp.
References children_, clear_cache(), col_grow_factor_, cols_, row_grow_factor_, rows_, and WRN_G.
Referenced by add_row(), gui2::tbuilder_grid::build(), gui2::tbuilder_listbox::build(), set_cols(), set_rows(), and gui2::tcontainer_::set_rows_cols().
void gui2::tgrid::set_row_grow_factor | ( | const unsigned | row, | |
const unsigned | factor | |||
) | [inline] |
Definition at line 73 of file grid.hpp.
References row_grow_factor_, and gui2::twidget::set_dirty().
Referenced by gui2::tbuilder_grid::build(), and gui2::tcontainer_::set_row_grow_factor().
void gui2::tgrid::set_col_grow_factor | ( | const unsigned | col, | |
const unsigned | factor | |||
) | [inline] |
Definition at line 80 of file grid.hpp.
References col_grow_factor_, and gui2::twidget::set_dirty().
Referenced by gui2::tbuilder_grid::build(), gui2::tbuilder_listbox::build(), and gui2::tcontainer_::set_col_grow_factor().
void gui2::tgrid::remove_child | ( | const unsigned | row, | |
const unsigned | col | |||
) |
Definition at line 149 of file grid.cpp.
References child(), clear_cache(), cols_, rows_, gui2::tgrid::tchild::set_id(), and gui2::tgrid::tchild::set_widget().
void gui2::tgrid::remove_child | ( | const std::string & | id, | |
const bool | find_all = false | |||
) |
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.
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] |
Inherited from twidget.
Reimplemented from gui2::twidget.
Definition at line 290 of file grid.cpp.
References best_col_width_, best_row_height_, col_grow_factor_, col_width_, cols_, DBG_G, get_best_size(), lg::gui, gui2::twidget::has_vertical_scrollbar(), has_vertical_scrollbar(), layout(), log_scope2, row_grow_factor_, row_height_, rows_, gui2::twidget::set_size(), size, widget(), gui2::tpoint::x, and gui2::tpoint::y.
Referenced by gui2::tcontainer_::set_client_size(), and gui2::tlistbox::set_size().
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] |
Returns the widget in the selected cell.
Definition at line 132 of file grid.hpp.
References child(), and gui2::tgrid::tchild::widget().
Referenced by gui2::tlistbox::finalize_setup(), find_widget(), gui2::tlistbox::trow::init_in_grid(), layout(), gui2::tlistbox::trow::select_in_grid(), set_active(), and set_size().
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] |
void gui2::tgrid::clear_cache | ( | ) | [private] |
Definition at line 527 of file grid.cpp.
References best_col_width_, best_row_height_, minimum_col_width_, and minimum_row_height_.
Referenced by add_child(), child(), find_widget(), remove_child(), and set_rows_cols().
void gui2::tgrid::layout | ( | const tpoint & | origin | ) | [private] |
Definition at line 536 of file grid.cpp.
References child(), col_width_, cols_, DBG_G, row_height_, rows_, gui2::tgrid::tchild::set_size(), size, widget(), gui2::tpoint::x, and gui2::tpoint::y.
Referenced by set_size().
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.
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. |
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().
const unsigned gui2::tgrid::VERTICAL_GROW_SEND_TO_CLIENT = 1 << 0 [static] |
Definition at line 31 of file grid.hpp.
Referenced by gui2::tbuilder_listbox::build(), gui2::read_flags(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::VERTICAL_ALIGN_TOP = 3 << 1 [static] |
Definition at line 33 of file grid.hpp.
Referenced by gui2::get_v_align(), gui2::twindow::recalculate_size(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::VERTICAL_ALIGN_CENTER = 2 << 1 [static] |
Definition at line 34 of file grid.hpp.
Referenced by gui2::tbuilder_listbox::build(), gui2::get_v_align(), gui2::twindow::recalculate_size(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::VERTICAL_ALIGN_BOTTOM = 1 << 1 [static] |
Definition at line 35 of file grid.hpp.
Referenced by gui2::get_v_align(), gui2::twindow::recalculate_size(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::HORIZONTAL_GROW_SEND_TO_CLIENT = 1 << 3 [static] |
Definition at line 37 of file grid.hpp.
Referenced by gui2::tbuilder_listbox::build(), gui2::read_flags(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::HORIZONTAL_ALIGN_LEFT = 3 << 4 [static] |
Definition at line 39 of file grid.hpp.
Referenced by gui2::get_h_align(), gui2::twindow::recalculate_size(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::HORIZONTAL_ALIGN_CENTER = 2 << 4 [static] |
Definition at line 40 of file grid.hpp.
Referenced by gui2::tbuilder_listbox::build(), gui2::get_h_align(), gui2::twindow::recalculate_size(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::HORIZONTAL_ALIGN_RIGHT = 1 << 4 [static] |
Definition at line 41 of file grid.hpp.
Referenced by gui2::get_h_align(), gui2::twindow::recalculate_size(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::BORDER_TOP = 1 << 6 [static] |
Definition at line 43 of file grid.hpp.
Referenced by gui2::tgrid::tchild::border_space(), gui2::get_border(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::BORDER_BOTTOM = 1 << 7 [static] |
Definition at line 44 of file grid.hpp.
Referenced by gui2::tgrid::tchild::border_space(), gui2::get_border(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::BORDER_LEFT = 1 << 8 [static] |
Definition at line 45 of file grid.hpp.
Referenced by gui2::tgrid::tchild::border_space(), gui2::get_border(), and gui2::tgrid::tchild::set_size().
const unsigned gui2::tgrid::BORDER_RIGHT = 1 << 9 [static] |
Definition at line 46 of file grid.hpp.
Referenced by gui2::tgrid::tchild::border_space(), gui2::get_border(), and gui2::tgrid::tchild::set_size().
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] |
Definition at line 254 of file grid.hpp.
Referenced by add_child(), add_row(), get_cols(), get_size(), layout(), remove_child(), set_cols(), set_rows(), set_rows_cols(), and set_size().
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] |
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] |
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().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |