Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends

gui2::tgenerator_ Class Reference

Abstract base class for the generator. More...

#include <generator.hpp>

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

List of all members.

Public Types

enum  tplacement { horizontal_list, vertical_list, grid, independent }
 

Determines how the items are placed.

More...

Public Member Functions

virtual ~tgenerator_ ()
virtual void delete_item (const unsigned index)=0
 Deletes an item.
virtual void clear ()=0
 Deletes all items.
virtual void select_item (const unsigned index, const bool select=true)=0
 (De)selects an item.
void toggle_item (const unsigned index)
 Toggles the selection state of an item.
virtual bool is_selected (const unsigned index) const =0
 Returns whether the item is selected.
virtual void set_item_shown (const unsigned index, const bool show)=0
 Shows or hides an item.
virtual bool get_item_shown (const unsigned index) const =0
 Returns whether the item is shown.
virtual unsigned get_item_count () const =0
 Returns the number of items.
virtual unsigned get_selected_item_count () const =0
 Returns the number of selected items.
virtual int get_selected_item () const =0
 Returns the selected item.
virtual tgriditem (const unsigned index)=0
 Gets the grid of an item.
virtual const tgriditem (const unsigned index) const =0
 Gets the grid of an item.
virtual tgridcreate_item (const int index, tbuilder_grid_const_ptr list_builder, const string_map &item_data, void(*callback)(twidget *))=0
 Creates a new item.
virtual tgridcreate_item (const int index, tbuilder_grid_const_ptr list_builder, const std::map< std::string, string_map > &data, void(*callback)(twidget *))=0
 Creates a new item.
virtual void create_items (const int index, tbuilder_grid_const_ptr list_builder, const std::vector< string_map > &data, void(*callback)(twidget *))=0
 Creates one or more new item(s).
virtual void create_items (const int index, tbuilder_grid_const_ptr list_builder, const std::vector< std::map< std::string, string_map > > &data, void(*callback)(twidget *))=0
 Creates one or more new item(s).
virtual void layout_init (const bool full_initialization)=0
 Inherited from twidget.
virtual void request_reduce_width (const unsigned maximum_width)=0
 Inherited from twidget.
virtual void request_reduce_height (const unsigned maximum_height)=0
 Inherited from twidget.
virtual tpoint calculate_best_size () const =0
 Inherited from twidget.
virtual void place (const tpoint &origin, const tpoint &size)=0
 Inherited from twidget.
virtual void set_origin (const tpoint &origin)=0
 Inherited from twidget.
void set_visible_area (const SDL_Rect &area)=0
 Inherited from twidget.
virtual void impl_draw_children (surface &frame_buffer)=0
 Inherited from twidget.
virtual void impl_draw_children (surface &frame_buffer, int x_offset, int y_offset)=0
virtual twidgetfind_at (const tpoint &coordinate, const bool must_be_active)=0
 Inherited from twidget.
virtual const twidgetfind_at (const tpoint &coordinate, const bool must_be_active) const =0
 Inherited from twidget.
virtual void handle_key_up_arrow (SDLMod modifier, bool &handled)=0
 Up arrow key pressed.
virtual void handle_key_down_arrow (SDLMod modifier, bool &handled)=0
 Down arrow key pressed.
virtual void handle_key_left_arrow (SDLMod modifier, bool &handled)=0
 Left arrow key pressed.
virtual void handle_key_right_arrow (SDLMod modifier, bool &handled)=0
 Right arrow key pressed.

Static Public Member Functions

static tgenerator_build (const bool has_minimum, const bool has_maximum, const tplacement placement, const bool select)
 Create a new generator.

Protected Member Functions

virtual void child_populate_dirty_list (twindow &caller, const std::vector< twidget * > &call_stack)=0
 Inherited from twidget.
virtual void do_select_item (const unsigned index)=0
 Selects a not selected item.
virtual void do_deselect_item (const unsigned index)=0
 Deselects a selected item.

Friends

class tdebug_layout_graph

Detailed Description

Abstract base class for the generator.

A generator is a class which holds multiple grids and controls their placement on the screen. The final class is policy based, more info about the possible policies is documented in the build() function. This function is the factory to generate the classes as well.

Definition at line 39 of file generator.hpp.


Member Enumeration Documentation

Determines how the items are placed.

Enumerator:
horizontal_list 
vertical_list 
grid 
independent 

Definition at line 48 of file generator.hpp.


Constructor & Destructor Documentation

virtual gui2::tgenerator_::~tgenerator_ (  )  [inline, virtual]

Definition at line 45 of file generator.hpp.


Member Function Documentation

tgenerator_ * gui2::tgenerator_::build ( const bool  has_minimum,
const bool  has_maximum,
const tplacement  placement,
const bool  select 
) [static]

Create a new generator.

Parameters:
has_minimum Does one item need to be selected.
has_maximum Is one the maximum number of items that can be selected?
placement The placement of the grids, see tplacement for more info.
select If a grid is selected, what should happen? If true the grid is selected, if false the grid is shown.
Returns:
A pointer to a new object. The caller gets ownership of the new object.

Definition at line 786 of file generator.cpp.

Referenced by gui2::tmulti_page::tmulti_page(), and gui2::tstacked_widget::tstacked_widget().

Here is the caller graph for this function:

virtual tpoint gui2::tgenerator_::calculate_best_size (  )  const [pure virtual]
virtual void gui2::tgenerator_::child_populate_dirty_list ( twindow caller,
const std::vector< twidget * > &  call_stack 
) [protected, pure virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

virtual void gui2::tgenerator_::clear (  )  [pure virtual]

Deletes all items.

Referenced by gui2::tmulti_page::clear().

Here is the caller graph for this function:

virtual tgrid& gui2::tgenerator_::create_item ( const int  index,
tbuilder_grid_const_ptr  list_builder,
const string_map item_data,
void(*)(twidget *)  callback 
) [pure virtual]

Creates a new item.

The item_data is used for the first widget found, this normally should be used when there's one widget in an item.

Parameters:
index The item before which to add the new item, 0 == begin, -1 == end.
list_builder A grid builder that's will build the contents of the new item.
item_data The data to initialize the parameters of the new item.
callback The callback function to call when an item in the grid is (de)selected.
Returns:
A reference to the newly created grid.

Referenced by gui2::tmulti_page::add_page(), gui2::tlistbox::add_row(), and gui2::tstacked_widget::finalize().

Here is the caller graph for this function:

virtual tgrid& gui2::tgenerator_::create_item ( const int  index,
tbuilder_grid_const_ptr  list_builder,
const std::map< std::string, string_map > &  data,
void(*)(twidget *)  callback 
) [pure virtual]

Creates a new item.

The item_data is used by id, and is meant to set multiple widgets in an item.

Parameters:
index The item before which to add the new item, 0 == begin, -1 == end.
list_builder A grid builder that's will build the contents of the new item.
data The data to initialize the parameters of the new item.
callback The callback function to call when an item in the grid is (de)selected.
Returns:
A reference to the newly created grid.
virtual void gui2::tgenerator_::create_items ( const int  index,
tbuilder_grid_const_ptr  list_builder,
const std::vector< std::map< std::string, string_map > > &  data,
void(*)(twidget *)  callback 
) [pure virtual]

Creates one or more new item(s).

For every item in item_data a new item is generated. This version expects multiple widgets per item.

Parameters:
index The item before which to add the new item, 0 == begin, -1 == end.
list_builder A grid builder that's will build the contents of the new item.
data The data to initialize the parameters of the new item.
callback The callback function to call when an item in the grid is (de)selected.
virtual void gui2::tgenerator_::create_items ( const int  index,
tbuilder_grid_const_ptr  list_builder,
const std::vector< string_map > &  data,
void(*)(twidget *)  callback 
) [pure virtual]

Creates one or more new item(s).

For every item in item_data a new item is generated. This version expects one widget per item.

Parameters:
index The item before which to add the new item, 0 == begin, -1 == end.
list_builder A grid builder that's will build the contents of the new item.
data The data to initialize the parameters of the new item.
callback The callback function to call when an item in the grid is (de)selected.

Referenced by gui2::tmulti_page::finalize(), and gui2::tlistbox::finalize().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::delete_item ( const unsigned  index  )  [pure virtual]

Deletes an item.

Implemented in gui2::policy::minimum_selection::tone, and gui2::policy::minimum_selection::tnone.

Referenced by gui2::tmulti_page::remove_page(), and gui2::tlistbox::remove_row().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::do_deselect_item ( const unsigned  index  )  [protected, pure virtual]

Deselects a selected item.

Parameters:
index The index of a selected item.

Referenced by gui2::policy::minimum_selection::tnone::delete_item(), gui2::policy::minimum_selection::tone::delete_item(), gui2::policy::minimum_selection::tnone::deselect_item(), and gui2::policy::maximum_selection::tone::select_item().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::do_select_item ( const unsigned  index  )  [protected, pure virtual]

Selects a not selected item.

Parameters:
index The index of a not selected item.

Referenced by gui2::policy::maximum_selection::tinfinite::select_item(), and gui2::policy::maximum_selection::tone::select_item().

Here is the caller graph for this function:

virtual twidget* gui2::tgenerator_::find_at ( const tpoint coordinate,
const bool  must_be_active 
) [pure virtual]
virtual const twidget* gui2::tgenerator_::find_at ( const tpoint coordinate,
const bool  must_be_active 
) const [pure virtual]
virtual unsigned gui2::tgenerator_::get_item_count (  )  const [pure virtual]
virtual bool gui2::tgenerator_::get_item_shown ( const unsigned  index  )  const [pure virtual]

Returns whether the item is shown.

virtual int gui2::tgenerator_::get_selected_item (  )  const [pure virtual]

Returns the selected item.

If a list has multiple selected items it looks whether it knows the last item acutally selected, if that item is selected that one is chosen. Else is goes through all selected items and returns the first one selected.

Note:
tstacked_widget depends on that behaviour it always has all items selected and thus shown and by default the last selected item (the top one) is active.
Returns:
The selected item, -1 if none selected.

Referenced by gui2::tmulti_page::get_selected_page(), gui2::tlistbox::get_selected_row(), gui2::tlistbox::handle_key_down_arrow(), gui2::tlistbox::handle_key_left_arrow(), gui2::tlistbox::handle_key_right_arrow(), gui2::tlistbox::handle_key_up_arrow(), gui2::tlistbox::place(), and gui2::policy::maximum_selection::tone::select_item().

Here is the caller graph for this function:

virtual unsigned gui2::tgenerator_::get_selected_item_count (  )  const [pure virtual]

Returns the number of selected items.

Referenced by gui2::policy::minimum_selection::tone::delete_item(), and gui2::policy::maximum_selection::tone::select_item().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::handle_key_down_arrow ( SDLMod  modifier,
bool &  handled 
) [pure virtual]

Down arrow key pressed.

Parameters:
modifier The SDL keyboard modifier when the key was pressed.
handled If the function handles the key it should set handled to true else do not modify it. This is used in the keyboard event changing.

Implemented in gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, and gui2::policy::placement::tindependent.

Referenced by gui2::tlistbox::handle_key_down_arrow().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::handle_key_left_arrow ( SDLMod  modifier,
bool &  handled 
) [pure virtual]

Left arrow key pressed.

Parameters:
modifier The SDL keyboard modifier when the key was pressed.
handled If the function handles the key it should set handled to true else do not modify it. This is used in the keyboard event changing.

Implemented in gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, and gui2::policy::placement::tindependent.

Referenced by gui2::tlistbox::handle_key_left_arrow().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::handle_key_right_arrow ( SDLMod  modifier,
bool &  handled 
) [pure virtual]

Right arrow key pressed.

Parameters:
modifier The SDL keyboard modifier when the key was pressed.
handled If the function handles the key it should set handled to true else do not modify it. This is used in the keyboard event changing.

Implemented in gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, and gui2::policy::placement::tindependent.

Referenced by gui2::tlistbox::handle_key_right_arrow().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::handle_key_up_arrow ( SDLMod  modifier,
bool &  handled 
) [pure virtual]

Up arrow key pressed.

Parameters:
modifier The SDL keyboard modifier when the key was pressed.
handled If the function handles the key it should set handled to true else do not modify it. This is used in the keyboard event changing.

Implemented in gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, and gui2::policy::placement::tindependent.

Referenced by gui2::tlistbox::handle_key_up_arrow().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::impl_draw_children ( surface frame_buffer,
int  x_offset,
int  y_offset 
) [pure virtual]

Reimplemented from gui2::twidget.

virtual void gui2::tgenerator_::impl_draw_children ( surface frame_buffer  )  [pure virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

virtual bool gui2::tgenerator_::is_selected ( const unsigned  index  )  const [pure virtual]

Returns whether the item is selected.

Referenced by gui2::policy::minimum_selection::tnone::delete_item(), and toggle_item().

Here is the caller graph for this function:

virtual const tgrid& gui2::tgenerator_::item ( const unsigned  index  )  const [pure virtual]

Gets the grid of an item.

virtual tgrid& gui2::tgenerator_::item ( const unsigned  index  )  [pure virtual]
virtual void gui2::tgenerator_::layout_init ( const bool  full_initialization  )  [pure virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

virtual void gui2::tgenerator_::place ( const tpoint origin,
const tpoint size 
) [pure virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Implemented in gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, and gui2::policy::placement::tindependent.

Referenced by gui2::tlistbox::set_row_shown().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::request_reduce_height ( const unsigned  maximum_height  )  [pure virtual]
virtual void gui2::tgenerator_::request_reduce_width ( const unsigned  maximum_width  )  [pure virtual]
virtual void gui2::tgenerator_::select_item ( const unsigned  index,
const bool  select = true 
) [pure virtual]

(De)selects an item.

Parameters:
index The item to (de)select.
select If true selects, if false deselects.

Referenced by gui2::tstacked_widget::finalize(), gui2::tmulti_page::select_page(), gui2::tlistbox::select_row(), and toggle_item().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::set_item_shown ( const unsigned  index,
const bool  show 
) [pure virtual]

Shows or hides an item.

The caller is responsible for reformatting the grid.

Parameters:
index The item to show or hide.
show If true shows the item, else hides it.

Implemented in gui2::policy::minimum_selection::tone, and gui2::policy::minimum_selection::tnone.

Referenced by gui2::tlistbox::set_row_shown().

Here is the caller graph for this function:

virtual void gui2::tgenerator_::set_origin ( const tpoint origin  )  [pure virtual]
void gui2::tgenerator_::set_visible_area ( const SDL_Rect &  area  )  [pure virtual]
void gui2::tgenerator_::toggle_item ( const unsigned  index  )  [inline]

Toggles the selection state of an item.

Parameters:
index The item to toggle.

Definition at line 95 of file generator.hpp.

References is_selected(), and select_item().

Referenced by gui2::tlistbox::list_item_clicked().

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class tdebug_layout_graph [friend]

Reimplemented from gui2::twidget.

Definition at line 42 of file generator.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:22:49 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs