Fl_Tree_Item Class Reference

Tree item. More...

#include <Fl_Tree_Item.H>

List of all members.

Public Member Functions

void activate (int val=1)
 Change the item's activation state to the optionally specified 'val'.
Fl_Tree_Itemadd (const Fl_Tree_Prefs &prefs, char **arr)
 Add a child recursively into tree.
Fl_Tree_Itemadd (const Fl_Tree_Prefs &prefs, const char *new_label)
 Add a new child to this item with the name 'new_label', with defaults from 'prefs'.
const Fl_Tree_Itemchild (int t) const
 Return the const child item for the given 'index'.
Fl_Tree_Itemchild (int index)
 Return the child item for the given 'index'.
int children () const
 Return the number of children this item has.
void clear_children ()
 Clear all the children for this item.
void close ()
 Close this item and all its children.
void deactivate ()
 Deactivate the item; the callback() won't be invoked when clicked.
int depth () const
 Returns how many levels deep this item is in the hierarchy.
void deselect ()
 Disable the item's selection state.
int deselect_all ()
 Deselect self and all children Returns count of how many items were in the 'selected' state, ie.
void draw (int X, int &Y, int W, Fl_Widget *tree, const Fl_Tree_Prefs &prefs, int lastchild=1)
 Draw this item and its children.
int event_on_collapse_icon (const Fl_Tree_Prefs &prefs) const
 Was the event on the 'collapse' button?
int event_on_label (const Fl_Tree_Prefs &prefs) const
 Was event on the label()?
int find_child (Fl_Tree_Item *item)
 Find the index number for the specified 'item' in the current item's list of children.
int find_child (const char *name)
 Return the index of the immediate child of this item that has the label 'name'.
Fl_Tree_Itemfind_clicked ()
 Non-const version of the above.
const Fl_Tree_Itemfind_clicked () const
 Find the item that the last event was over.
Fl_Tree_Itemfind_item (char **arr)
 Find item by by descending array of names.
const Fl_Tree_Itemfind_item (char **arr) const
 Find item by descending array of names.
 Fl_Tree_Item (const Fl_Tree_Item *o)
 Copy constructor.
 Fl_Tree_Item (const Fl_Tree_Prefs &prefs)
 Constructor.
int has_children () const
 See if this item has children.
Fl_Tree_Iteminsert (const Fl_Tree_Prefs &prefs, const char *new_label, int pos=0)
 Insert a new item into current item's children at a specified position.
Fl_Tree_Iteminsert_above (const Fl_Tree_Prefs &prefs, const char *new_label)
 Insert a new item above this item.
char is_activated () const
 See if the item is activated.
char is_active () const
 See if the item is activated.
int is_close () const
 See if the item is 'closed'.
int is_open () const
 See if the item is 'open'.
int is_root () const
 Is this item the root of the tree?
char is_selected () const
 See if the item is selected.
const char * label () const
 Return the label.
void label (const char *val)
 Set the label. Makes a copy of the name.
Fl_Color labelbgcolor () const
 Return item's background text color.
void labelbgcolor (Fl_Color val)
 Set item's label background color.
Fl_Color labelcolor () const
 Return item's label text color.
void labelcolor (Fl_Color val)
 Set item's label text color.
Fl_Color labelfgcolor () const
 Return item's label foreground text color.
void labelfgcolor (Fl_Color val)
 Set item's label foreground text color.
int labelfont () const
 Get item's label font face.
void labelfont (int val)
 Set item's label font face.
int labelsize () const
 Get item's label font size.
void labelsize (int val)
 Set item's label font size.
Fl_Tree_Itemnext ()
 Return the next item in the tree.
void open ()
 Open this item and all its children.
void open_toggle ()
 Toggle the item's open/closed state.
void parent (Fl_Tree_Item *val)
 Set the parent for this item.
const Fl_Tree_Itemparent () const
 Return the const parent for this item.
Fl_Tree_Itemparent ()
 Return the parent for this item.
Fl_Tree_Itemprev ()
 Return the previous item in the tree.
int remove_child (const char *new_label)
 Remove immediate child (and its children) by its label 'name'.
int remove_child (Fl_Tree_Item *item)
 Remove child by item.
void select (int val=1)
 Change the item's selection state to the optionally specified 'val'.
void select_toggle ()
 Toggle the item's selection state.
void show_self (const char *indent="") const
 Print the tree as 'ascii art' to stdout.
int swap_children (Fl_Tree_Item *a, Fl_Tree_Item *b)
 Swap two of our children, given item pointers.
void swap_children (int ax, int bx)
 Swap two of our children, given two child index values.
Fl_Pixmap * usericon () const
 Get the user icon. Returns '0' if disabled.
void usericon (Fl_Pixmap *val)
 Set the user icon's pixmap. '0' will disable.
Fl_Widget * widget () const
 Return FLTK widget assigned to this item.
void widget (Fl_Widget *val)
 Assign an FLTK widget to this item.

Protected Member Functions

void draw_horizontal_connector (int x1, int x2, int y, const Fl_Tree_Prefs &prefs)
 Internal: Horizontal connector line based on preference settings.
void draw_vertical_connector (int x, int y1, int y2, const Fl_Tree_Prefs &prefs)
 Internal: Vertical connector line based on preference settings.
void hide_widgets ()
 Internal: Hide the FLTK widget() for this item and all children.
void show_widgets ()
 Internal: Show the FLTK widget() for this item and all children.


Detailed Description

Tree item.

This class is a single tree item, and manages all of the item's attributes. Fl_Tree_Item is used by Fl_Tree, which is comprised of many instances of Fl_Tree_Item.

Fl_Tree_Item is hierarchical; it dynamically manages an Fl_Tree_Item_Array of children that are themselves instances of Fl_Tree_Item. Each item can have zero or more children. When an item has children, close() and open() can be used to hide or show them.

Items have their own attributes; font size, face, color. Items maintain their own hierarchy of children.

When you make changes to items, you'll need to tell the tree to redraw() for the changes to show up.


Constructor & Destructor Documentation

Fl_Tree_Item::Fl_Tree_Item ( const Fl_Tree_Prefs prefs  ) 

Constructor.

Makes a new instance of Fl_Tree_Item using defaults from 'prefs'.


Member Function Documentation

void Fl_Tree_Item::activate ( int  val = 1  )  [inline]

Change the item's activation state to the optionally specified 'val'.

When deactivated, the item will be 'grayed out'; the callback() won't be invoked if the user clicks on the label. If the item has a widget() associated with the item, its activation state will be changed as well.

If 'val' is not specified, the item will be activated.

Fl_Tree_Item * Fl_Tree_Item::add ( const Fl_Tree_Prefs prefs,
char **  arr 
)

Add a child recursively into tree.

Should be used only by Fl_Tree's internals. Adds the item based on the value of prefs.sortorder().

Fl_Tree_Item * Fl_Tree_Item::add ( const Fl_Tree_Prefs prefs,
const char *  new_label 
)

Add a new child to this item with the name 'new_label', with defaults from 'prefs'.

An internally managed copy is made of the label string. Adds the item based on the value of prefs.sortorder().

const Fl_Tree_Item * Fl_Tree_Item::child ( int  t  )  const

Return the const child item for the given 'index'.

Return child item for the specified 'index'.

void Fl_Tree_Item::deactivate (  )  [inline]

Deactivate the item; the callback() won't be invoked when clicked.

Same as activate(0)

int Fl_Tree_Item::depth (  )  const

Returns how many levels deep this item is in the hierarchy.

For instance; root has a depth of zero, and its immediate children would have a depth of 1, and so on.

int Fl_Tree_Item::deselect_all (  )  [inline]

Deselect self and all children Returns count of how many items were in the 'selected' state, ie.

how many items were "changed".

int Fl_Tree_Item::find_child ( Fl_Tree_Item item  ) 

Find the index number for the specified 'item' in the current item's list of children.

Returns:
the index, or -1 if not found.

int Fl_Tree_Item::find_child ( const char *  name  ) 

Return the index of the immediate child of this item that has the label 'name'.

Returns:
index of found item, or -1 if not found.

Fl_Tree_Item * Fl_Tree_Item::find_clicked (  ) 

Non-const version of the above.

Find the item that the last event was over.

Returns the item if its visible, and mouse is over it. Works even if widget deactivated. Use event_on_collapse_icon() to determine if collapse button was pressed.

Returns:
the visible item under the event if found, or 0 if none.

const Fl_Tree_Item * Fl_Tree_Item::find_clicked (  )  const

Find the item that the last event was over.

Returns the item if its visible, and mouse is over it. Works even if widget deactivated. Use event_on_collapse_icon() to determine if collapse button was pressed.

Returns:
const visible item under the event if found, or 0 if none.

Fl_Tree_Item * Fl_Tree_Item::find_item ( char **  arr  ) 

Find item by by descending array of names.

Only Fl_Tree should need this method.

Returns:
item, or 0 if not found

const Fl_Tree_Item * Fl_Tree_Item::find_item ( char **  arr  )  const

Find item by descending array of names.

Only Fl_Tree should need this method.

Returns:
item, or 0 if not found

void Fl_Tree_Item::hide_widgets (  )  [protected]

Internal: Hide the FLTK widget() for this item and all children.

Used by close() to hide widgets.

Fl_Tree_Item * Fl_Tree_Item::next (  ) 

Return the next item in the tree.

This method can be used to walk the tree forward. For an example of how to use this method, see Fl_Tree::first().

Returns:
the next item in the tree, or 0 if there's no more items.

void Fl_Tree_Item::parent ( Fl_Tree_Item val  )  [inline]

Set the parent for this item.

Should only be used by Fl_Tree's internals.

Fl_Tree_Item * Fl_Tree_Item::prev (  ) 

Return the previous item in the tree.

This method can be used to walk the tree backwards. For an example of how to use this method, see Fl_Tree::last().

Returns:
the previous item in the tree, or 0 if there's no item above this one (hit the root).

int Fl_Tree_Item::remove_child ( const char *  name  ) 

Remove immediate child (and its children) by its label 'name'.

Returns 0 if removed, -1 if not found.

int Fl_Tree_Item::remove_child ( Fl_Tree_Item item  ) 

Remove child by item.

Returns 0 if removed, -1 if item not an immediate child.

void Fl_Tree_Item::select ( int  val = 1  )  [inline]

Change the item's selection state to the optionally specified 'val'.

If 'val' is not specified, the item will be selected.

void Fl_Tree_Item::show_self ( const char *  indent = ""  )  const

Print the tree as 'ascii art' to stdout.

Used mainly for debugging.

void Fl_Tree_Item::show_widgets (  )  [protected]

Internal: Show the FLTK widget() for this item and all children.

Used by open() to re-show widgets that were hidden by a previous close()

int Fl_Tree_Item::swap_children ( Fl_Tree_Item a,
Fl_Tree_Item b 
)

Swap two of our children, given item pointers.

Use this eg. for sorting.

This method is SLOW because it involves linear lookups. For speed, use swap_children(int,int) instead.

Returns:
  • 0 : OK
  • -1 : failed: 'a' or 'b' is not our immediate child

void Fl_Tree_Item::swap_children ( int  ax,
int  bx 
)

Swap two of our children, given two child index values.

Use this eg. for sorting.

This method is FAST, and does not involve lookups.

No range checking is done on either index value.

Returns:
  • 0 : OK
  • -1 : failed: 'a' or 'b' is not our immediate child


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

Generated on Thu Jun 4 05:05:42 2009 for Fl_Tree by  doxygen 1.5.6