Abstract base class for the generator. More...
#include <generator.hpp>


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 tgrid & | item (const unsigned index)=0 |
| Gets the grid of an item. | |
| virtual const tgrid & | item (const unsigned index) const =0 |
| Gets the grid of an item. | |
| virtual tgrid & | create_item (const int index, tbuilder_grid_const_ptr list_builder, const string_map &item_data, void(*callback)(twidget *))=0 |
| Creates a new item. | |
| virtual tgrid & | create_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 twidget * | find_at (const tpoint &coordinate, const bool must_be_active)=0 |
| Inherited from twidget. | |
| virtual const twidget * | find_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 |
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.
Determines how the items are placed.
Definition at line 48 of file generator.hpp.
| virtual gui2::tgenerator_::~tgenerator_ | ( | ) | [inline, virtual] |
Definition at line 45 of file generator.hpp.
| tgenerator_ * gui2::tgenerator_::build | ( | const bool | has_minimum, | |
| const bool | has_maximum, | |||
| const tplacement | placement, | |||
| const bool | select | |||
| ) | [static] |
Create a new generator.
| 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. |
Definition at line 786 of file generator.cpp.
Referenced by gui2::tmulti_page::tmulti_page(), and gui2::tstacked_widget::tstacked_widget().

| virtual tpoint gui2::tgenerator_::calculate_best_size | ( | ) | const [pure virtual] |
Inherited from twidget.
Implements 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().

| 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().

| 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.
| 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. |
Referenced by gui2::tmulti_page::add_page(), gui2::tlistbox::add_row(), and gui2::tstacked_widget::finalize().

| 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.
| 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< 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.
| 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.
| 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().

| 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().

| virtual void gui2::tgenerator_::do_deselect_item | ( | const unsigned | index | ) | [protected, pure virtual] |
Deselects a selected item.
| 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().

| virtual void gui2::tgenerator_::do_select_item | ( | const unsigned | index | ) | [protected, pure virtual] |
Selects a not selected item.
| 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().

| virtual twidget* gui2::tgenerator_::find_at | ( | const tpoint & | coordinate, | |
| const bool | must_be_active | |||
| ) | [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.
| virtual const twidget* gui2::tgenerator_::find_at | ( | const tpoint & | coordinate, | |
| const bool | must_be_active | |||
| ) | const [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.
| virtual unsigned gui2::tgenerator_::get_item_count | ( | ) | const [pure virtual] |
Returns the number of items.
Referenced by gui2::tstacked_widget::finalize(), gui2::tlistbox::get_item_count(), gui2::tmulti_page::get_page_count(), gui2::tstacked_widget::layout_children(), and gui2::tlistbox::list_item_clicked().

| 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.
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().

| 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().

| virtual void gui2::tgenerator_::handle_key_down_arrow | ( | SDLMod | modifier, | |
| bool & | handled | |||
| ) | [pure virtual] |
Down arrow key pressed.
| 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().

| virtual void gui2::tgenerator_::handle_key_left_arrow | ( | SDLMod | modifier, | |
| bool & | handled | |||
| ) | [pure virtual] |
Left arrow key pressed.
| 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().

| virtual void gui2::tgenerator_::handle_key_right_arrow | ( | SDLMod | modifier, | |
| bool & | handled | |||
| ) | [pure virtual] |
Right arrow key pressed.
| 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().

| virtual void gui2::tgenerator_::handle_key_up_arrow | ( | SDLMod | modifier, | |
| bool & | handled | |||
| ) | [pure virtual] |
Up arrow key pressed.
| 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().

| 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().

| 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] |
Gets the grid of an item.
Referenced by gui2::tlistbox::get_row_grid(), 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::tstacked_widget::layout_children(), gui2::tlistbox::list_item_clicked(), gui2::tmulti_page::page_grid(), gui2::tlistbox::place(), gui2::tlistbox::remove_row(), and gui2::tlistbox::set_row_active().

| virtual void gui2::tgenerator_::layout_init | ( | const bool | full_initialization | ) | [pure virtual] |
Inherited from twidget.
Reimplemented from gui2::twidget.
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().

| virtual void gui2::tgenerator_::request_reduce_height | ( | const unsigned | maximum_height | ) | [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.
| virtual void gui2::tgenerator_::request_reduce_width | ( | const unsigned | maximum_width | ) | [pure virtual] |
Inherited from twidget.
Implements gui2::twidget.
Implemented in gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, and gui2::policy::placement::tindependent.
| virtual void gui2::tgenerator_::select_item | ( | const unsigned | index, | |
| const bool | select = true | |||
| ) | [pure virtual] |
(De)selects an item.
| 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().

| 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.
| 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().

| virtual void gui2::tgenerator_::set_origin | ( | const tpoint & | origin | ) | [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.
| void gui2::tgenerator_::set_visible_area | ( | const SDL_Rect & | area | ) | [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.
| void gui2::tgenerator_::toggle_item | ( | const unsigned | index | ) | [inline] |
Toggles the selection state of an item.
| 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().


friend class tdebug_layout_graph [friend] |
Reimplemented from gui2::twidget.
Definition at line 42 of file generator.hpp.
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:22:49 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |