Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

gui2::ttree_view_node Class Reference

#include <tree_view_node.hpp>

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

List of all members.

Public Types

typedef
implementation::tbuilder_tree_view::tnode 
tnode_definition

Public Member Functions

 ttree_view_node (const std::string &id, const std::vector< tnode_definition > &node_definitions, ttree_view_node *parent_node, ttree_view &parent_tree_view, const std::map< std::string, string_map > &data)
 ~ttree_view_node ()
ttree_view_nodeadd_child (const std::string &id, const std::map< std::string, string_map > &data, const int index=-1)
 Adds a child item to the list of child nodes.
ttree_view_nodeadd_sibling (const std::string &id, const std::map< std::string, string_map > &data)
 Adds a sibbling for a node at the end of the list.
bool is_root_node () const
 Is this node the root node?
unsigned get_indention_level () const
 The indention level of the node.
bool empty () const
 Does the node have children?
bool is_folded () const
 Is the node folded?
virtual iterator::twalker_create_walker ()
 Inherited from twidget.
twidgetfind_at (const tpoint &coordinate, const bool must_be_active)
 Inherited from twidget.
const twidgetfind_at (const tpoint &coordinate, const bool must_be_active) const
 Inherited from twidget.
twidgetfind (const std::string &id, const bool must_be_active)
 Inherited from twidget.
const twidgetfind (const std::string &id, const bool must_be_active) const
 Inherited from twidget.
size_t size () const
 The "size" of the widget.
void clear ()
 Removes all child items from the widget.
ttree_view_nodeparent_node ()
 Returns the parent node.
const ttree_view_nodeparent_node () const
 The const version of parent_node.
ttree_viewtree_view ()
const ttree_viewtree_view () const

Private Member Functions

void request_reduce_width (const unsigned)
 Inherited from twidget.
void impl_populate_dirty_list (twindow &caller, const std::vector< twidget * > &call_stack)
 "Inherited" from twidget.
tpoint calculate_best_size () const
 Calculates the best size.
bool disable_click_dismiss () const
 Does the widget disable easy close?
tpoint calculate_best_size (const int indention_level, const unsigned indention_step_size) const
tpoint get_current_size () const
tpoint get_folded_size () const
tpoint get_unfolded_size () const
void set_origin (const tpoint &origin)
 Sets the origin of the widget.
void place (const tpoint &origin, const tpoint &size)
 Places the widget.
unsigned place (const unsigned indention_step_size, tpoint origin, unsigned width)
void set_visible_area (const SDL_Rect &area)
 Sets the visible area for a widget.
void impl_draw_children (surface &frame_buffer)
 See draw_children.
void impl_draw_children (surface &frame_buffer, int x_offset, int y_offset)
void signal_handler_left_button_click (const event::tevent event)
void signal_handler_label_left_button_click (const event::tevent event, bool &handled, bool &halt)
void init_grid (tgrid *grid, const std::map< std::string, string_map > &data)
const std::string & get_control_type () const

Private Attributes

ttree_view_nodeparent_node_
 Our parent node.
ttree_viewtree_view_
 The tree view that owns us.
tgrid grid_
 Grid holding our contents.
boost::ptr_vector
< ttree_view_node
children_
 Our children.
const std::vector
< tnode_definition > & 
node_definitions_
 The node definitions known to use.
ttoggle_buttonicon_
 The icon to show the folded state.
tselectable_label_
 The label to show our selected state.

Friends

struct ttree_view_node_implementation
class ttree_view

Detailed Description

Definition at line 29 of file tree_view_node.hpp.


Member Typedef Documentation

Definition at line 37 of file tree_view_node.hpp.


Constructor & Destructor Documentation

gui2::ttree_view_node::ttree_view_node ( const std::string &  id,
const std::vector< tnode_definition > &  node_definitions,
ttree_view_node parent_node,
ttree_view parent_tree_view,
const std::map< std::string, string_map > &  data 
)
gui2::ttree_view_node::~ttree_view_node (  ) 

Definition at line 107 of file tree_view_node.cpp.

References gui2::ttree_view::selected_item_, and tree_view().

Here is the call graph for this function:


Member Function Documentation

ttree_view_node & gui2::ttree_view_node::add_child ( const std::string &  id,
const std::map< std::string, string_map > &  data,
const int  index = -1 
)

Adds a child item to the list of child nodes.

Parameters:
id The id of the node definition to use for the new node.
data The data to send to the set_members of the widgets. If the member id is not an empty string it is only send to the widget that has the wanted id (if any). If the member id is an empty string, it is send to all members. Having both empty and non-empty id's gives undefined behaviour.
index The item before which to add the new item, 0 == begin, -1 == end.

Definition at line 114 of file tree_view_node.cpp.

References children_, gui2::tscrollbar_container::content_grid(), get_indention_level(), gui2::twidget::get_size(), gui2::twidget::get_width(), gui2::ttree_view::indention_step_size_, is_folded(), is_root_node(), node_definitions_, gui2::ttree_view::resize_content(), tree_view(), ttree_view_node(), gui2::tpoint::x, and gui2::tpoint::y.

Referenced by gui2::ttree_view::add_node(), add_sibling(), and gui2::tlobby_main::update_playerlist().

Here is the call graph for this function:

Here is the caller graph for this function:

ttree_view_node& gui2::ttree_view_node::add_sibling ( const std::string &  id,
const std::map< std::string, string_map > &  data 
) [inline]

Adds a sibbling for a node at the end of the list.

Parameters:
id The id of the node definition to use for the new node.
data The data to send to the set_members of the widgets. If the member id is not an empty string it is only send to the widget that has the wanted id (if any). If the member id is an empty string, it is send to all members. Having both empty and non-empty id's gives undefined behaviour.

Definition at line 78 of file tree_view_node.hpp.

References add_child(), is_root_node(), and parent_node().

Here is the call graph for this function:

tpoint gui2::ttree_view_node::calculate_best_size (  )  const [private, virtual]

Calculates the best size.

This function calculates the best size and ignores the current values in the layout phase. Note containers can call the get_best_size() of their children since it's meant to update itself.

Returns:
The best size for the widget.
Return values:
0,0 The best size is 0,0.

Implements gui2::twidget.

Definition at line 310 of file tree_view_node.cpp.

References tree_view().

Referenced by calculate_best_size().

Here is the call graph for this function:

Here is the caller graph for this function:

tpoint gui2::ttree_view_node::calculate_best_size ( const int  indention_level,
const unsigned  indention_step_size 
) const [private]
void gui2::ttree_view_node::clear (  ) 

Removes all child items from the widget.

Todo:
Also try to find the optimal width.

Definition at line 214 of file tree_view_node.cpp.

References children_, get_current_size(), is_folded(), gui2::ttree_view::resize_content(), tree_view(), and gui2::tpoint::y.

Referenced by gui2::tlobby_main::update_playerlist().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual iterator::twalker_* gui2::ttree_view_node::create_walker (  )  [inline, virtual]

Inherited from twidget.

Todo:
Implement properly.

Implements gui2::twidget.

Definition at line 129 of file tree_view_node.hpp.

bool gui2::ttree_view_node::disable_click_dismiss (  )  const [inline, private, virtual]

Does the widget disable easy close?

Implements gui2::twidget.

Definition at line 233 of file tree_view_node.hpp.

bool gui2::ttree_view_node::empty (  )  const [inline]

Does the node have children?

Definition at line 102 of file tree_view_node.hpp.

References children_.

Referenced by gui2::tsub_player_list::auto_hide(), and gui2::ttree_view::empty().

Here is the caller graph for this function:

twidget* gui2::ttree_view_node::find ( const std::string &  id,
const bool  must_be_active 
) [inline, virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 140 of file tree_view_node.hpp.

References gui2::tgrid::find(), and grid_.

Referenced by find().

Here is the call graph for this function:

Here is the caller graph for this function:

const twidget* gui2::ttree_view_node::find ( const std::string &  id,
const bool  must_be_active 
) const [inline, virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 147 of file tree_view_node.hpp.

References gui2::tgrid::find(), find(), and grid_.

Here is the call graph for this function:

twidget * gui2::ttree_view_node::find_at ( const tpoint coordinate,
const bool  must_be_active 
) [virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 278 of file tree_view_node.cpp.

const twidget * gui2::ttree_view_node::find_at ( const tpoint coordinate,
const bool  must_be_active 
) const [virtual]

Inherited from twidget.

Reimplemented from gui2::twidget.

Definition at line 286 of file tree_view_node.cpp.

const std::string & gui2::ttree_view_node::get_control_type (  )  const [private]

Definition at line 630 of file tree_view_node.cpp.

References type.

tpoint gui2::ttree_view_node::get_current_size (  )  const [private]

Definition at line 315 of file tree_view_node.cpp.

References children_, get_current_size(), get_folded_size(), gui2::twidget::get_visible(), grid_, is_folded(), parent_node_, size(), gui2::tpoint::x, and gui2::tpoint::y.

Referenced by clear(), get_current_size(), and signal_handler_left_button_click().

Here is the call graph for this function:

Here is the caller graph for this function:

tpoint gui2::ttree_view_node::get_folded_size (  )  const [private]

Definition at line 344 of file tree_view_node.cpp.

References get_indention_level(), gui2::twidget::get_size(), grid_, gui2::ttree_view::indention_step_size_, size(), tree_view(), and gui2::tpoint::x.

Referenced by get_current_size(), and signal_handler_left_button_click().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned gui2::ttree_view_node::get_indention_level (  )  const

The indention level of the node.

The root node starts at level 0.

Definition at line 161 of file tree_view_node.cpp.

References is_root_node(), game_config::images::level, and parent_node().

Referenced by add_child(), get_folded_size(), and get_unfolded_size().

Here is the call graph for this function:

Here is the caller graph for this function:

tpoint gui2::ttree_view_node::get_unfolded_size (  )  const [private]
void gui2::ttree_view_node::impl_draw_children ( surface  )  [private, virtual]

See draw_children.

Reimplemented from gui2::twidget.

Definition at line 486 of file tree_view_node.cpp.

References children_, gui2::twidget::draw_children(), grid_, impl_draw_children(), and is_folded().

Referenced by impl_draw_children().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttree_view_node::impl_draw_children ( surface frame_buffer,
int  x_offset,
int  y_offset 
) [private, virtual]

Reimplemented from gui2::twidget.

Definition at line 499 of file tree_view_node.cpp.

References children_, gui2::twidget::draw_children(), grid_, impl_draw_children(), and is_folded().

Here is the call graph for this function:

void gui2::ttree_view_node::impl_populate_dirty_list ( twindow caller,
const std::vector< twidget * > &  call_stack 
) [private]

"Inherited" from twidget.

This version needs to call its children, which are it's child nodes.

Definition at line 294 of file tree_view_node.cpp.

References children_, grid_, impl_populate_dirty_list(), is_folded(), and gui2::twidget::populate_dirty_list().

Referenced by gui2::ttree_view::child_populate_dirty_list(), and impl_populate_dirty_list().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttree_view_node::init_grid ( tgrid grid,
const std::map< std::string, string_map > &  data 
) [private]

Definition at line 590 of file tree_view_node.cpp.

References gui2::tgrid::get_cols(), gui2::tgrid::get_rows(), gui2::twidget::id(), gui2::ttoggle_panel::set_child_members(), gui2::tcontrol::set_members(), and gui2::tgrid::widget().

Referenced by ttree_view_node().

Here is the call graph for this function:

Here is the caller graph for this function:

bool gui2::ttree_view_node::is_folded (  )  const

Is the node folded?

Definition at line 196 of file tree_view_node.cpp.

References gui2::ttoggle_button::get_value(), and icon_.

Referenced by add_child(), calculate_best_size(), clear(), get_current_size(), impl_draw_children(), impl_populate_dirty_list(), place(), set_visible_area(), and signal_handler_left_button_click().

Here is the call graph for this function:

Here is the caller graph for this function:

bool gui2::ttree_view_node::is_root_node (  )  const [inline]

Is this node the root node?

When the parent tree view is created it adds one special node, the root node. This node has no parent node and some other special features so several code paths need to check whether they are the parent node.

Definition at line 92 of file tree_view_node.hpp.

References parent_node_.

Referenced by add_child(), add_sibling(), get_indention_level(), parent_node(), and place().

Here is the caller graph for this function:

const ttree_view_node & gui2::ttree_view_node::parent_node (  )  const

The const version of parent_node.

Definition at line 180 of file tree_view_node.cpp.

References is_root_node(), and parent_node_.

Here is the call graph for this function:

ttree_view_node & gui2::ttree_view_node::parent_node (  ) 

Returns the parent node.

Precondition:
is_root_node() == false.

Definition at line 174 of file tree_view_node.cpp.

References is_root_node(), and parent_node_.

Referenced by add_sibling(), and get_indention_level().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttree_view_node::place ( const tpoint origin,
const tpoint size 
) [private, virtual]

Places the widget.

This function is normally called by a layout function to do the placement of a widget.

Parameters:
origin The position of top left of the widget.
size The size of the widget.

Reimplemented from gui2::twidget.

Definition at line 426 of file tree_view_node.cpp.

References gui2::ttree_view::layout_children(), and tree_view().

Referenced by gui2::ttree_view::layout_children(), place(), and set_origin().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned gui2::ttree_view_node::place ( const unsigned  indention_step_size,
tpoint  origin,
unsigned  width 
) [private]
void gui2::ttree_view_node::request_reduce_width ( const   unsigned  )  [inline, private, virtual]

Inherited from twidget.

Implements gui2::twidget.

Definition at line 185 of file tree_view_node.hpp.

void gui2::ttree_view_node::set_origin ( const tpoint origin  )  [private, virtual]

Sets the origin of the widget.

This function can be used to move the widget without dirting it.

Parameters:
origin The new origin.

Reimplemented from gui2::twidget.

Definition at line 417 of file tree_view_node.cpp.

References gui2::twidget::get_size(), place(), and tree_view().

Here is the call graph for this function:

void gui2::ttree_view_node::set_visible_area ( const SDL_Rect &  area  )  [private, virtual]

Sets the visible area for a widget.

This function sets the drawing_state_ and the clip_rect_.

Parameters:
area The visible area in screen coordinates.

Reimplemented from gui2::twidget.

Definition at line 470 of file tree_view_node.cpp.

References children_, DBG_GUI_L, grid_, is_folded(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, set_visible_area(), and gui2::tgrid::set_visible_area().

Referenced by gui2::ttree_view::layout_children(), and set_visible_area().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttree_view_node::signal_handler_label_left_button_click ( const event::tevent  event,
bool &  handled,
bool &  halt 
) [private]

Definition at line 561 of file tree_view_node.cpp.

References DBG_GUI_E, gui2::tselectable_::get_value(), label_, LOG_HEADER, gui2::ttree_view::selected_item_, gui2::ttree_view::selection_change_callback_, gui2::tselectable_::set_value(), and tree_view().

Referenced by ttree_view_node().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::ttree_view_node::signal_handler_left_button_click ( const event::tevent  event  )  [private]

Todo:
Rewrite this sizing code for the folding/unfolding.

The code works but feels rather hacky, so better move back to the drawingboard for 1.9.

Definition at line 515 of file tree_view_node.cpp.

References DBG_GUI_E, get_current_size(), get_folded_size(), get_unfolded_size(), is_folded(), LOG_HEADER, gui2::ttree_view::resize_content(), tree_view(), gui2::tpoint::x, and gui2::tpoint::y.

Referenced by ttree_view_node().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t gui2::ttree_view_node::size (  )  const [inline]

The "size" of the widget.

Todo:
Rename this function, names to close to the size of the widget.

Definition at line 159 of file tree_view_node.hpp.

References children_.

Referenced by gui2::tsub_player_list::auto_hide(), get_current_size(), get_folded_size(), and get_unfolded_size().

Here is the caller graph for this function:

ttree_view & gui2::ttree_view_node::tree_view (  ) 
const ttree_view & gui2::ttree_view_node::tree_view (  )  const

Definition at line 191 of file tree_view_node.cpp.

References tree_view_.


Friends And Related Function Documentation

friend class ttree_view [friend]

Definition at line 33 of file tree_view_node.hpp.

friend struct ttree_view_node_implementation [friend]

Definition at line 32 of file tree_view_node.hpp.


Member Data Documentation

boost::ptr_vector<ttree_view_node> gui2::ttree_view_node::children_ [private]

Our children.

We want the returned child nodes to remain stable so store pointers.

Definition at line 205 of file tree_view_node.hpp.

Referenced by add_child(), calculate_best_size(), clear(), empty(), get_current_size(), get_unfolded_size(), impl_draw_children(), impl_populate_dirty_list(), place(), gui2::ttree_view::remove_node(), set_visible_area(), and size().

The icon to show the folded state.

Definition at line 218 of file tree_view_node.hpp.

Referenced by is_folded(), and ttree_view_node().

The label to show our selected state.

Definition at line 221 of file tree_view_node.hpp.

Referenced by signal_handler_label_left_button_click(), and ttree_view_node().

The node definitions known to use.

This list is needed to create new nodes.

Todo:
Maybe store this list in the tree_view to avoid copying the reference.

Definition at line 215 of file tree_view_node.hpp.

Referenced by add_child(), and ttree_view_node().

Our parent node.

All nodes except the root node have a parent node.

Definition at line 192 of file tree_view_node.hpp.

Referenced by get_current_size(), is_root_node(), parent_node(), gui2::ttree_view::remove_node(), and ttree_view_node().

The tree view that owns us.

Definition at line 195 of file tree_view_node.hpp.

Referenced by tree_view().


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:23:37 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs