#include <Fl_Tree.H>
Public Member Functions | |
Fl_Tree_Item * | add (const char *path) |
Adds a new item, given a 'menu style' path, eg: "/Parent/Child/item". | |
void | clear () |
Clear all children from the tree. | |
void | clear_children (Fl_Tree_Item *item) |
Clear all the children of a particular node in the tree. | |
int | close (const char *path) |
Closes the item specified by 'path', eg: "Parent/child/item". | |
void | close (Fl_Tree_Item *item) |
Closes the 'item'. | |
void | closeicon (Fl_Pixmap *val) |
Sets the icon to be used as the 'close' icon. | |
Fl_Pixmap * | closeicon () const |
Returns the icon to be used as the 'close' icon. | |
void | connectorstyle (Fl_Tree_Connector val) |
Sets the line drawing style for inter-connecting items. | |
Fl_Tree_Connector | connectorstyle () const |
Returns the line drawing style for inter-connecting items. | |
void | connectorwidth (int val) |
Sets the width of the horizontal connection lines (in pixels) that appear to the left of each tree item's label. | |
int | connectorwidth () const |
Gets the width of the horizontal connection lines (in pixels) that appear to the left of each tree item's label. | |
int | deselect (const char *path) |
De-select an item specified by 'path' (eg: "Parent/child/item"). | |
void | deselect (Fl_Tree_Item *item) |
De-select the specified item. | |
int | deselect_all (Fl_Tree_Item *item=0) |
Deselect item and all its children. | |
void | draw () |
Standard FLTK draw() method, handles draws the tree widget. | |
const Fl_Tree_Item * | find_item (const char *path) const |
A const version of Fl_Tree::find_item(const char *path). | |
Fl_Tree_Item * | find_item (const char *path) |
Find the item, given a menu style path, eg: "/Parent/Child/item". | |
Fl_Tree_Item * | first () |
Returns the first item in the tree. | |
Fl_Tree (int X, int Y, int W, int H, const char *L=0) | |
Constructor. | |
int | handle (int e) |
Standard FLTK event handler for this widget. | |
Fl_Tree_Item * | insert_above (Fl_Tree_Item *above, const char *name) |
Inserts a new item above the specified Fl_Tree_Item, with the label set to 'name'. | |
int | is_close (const char *path) const |
See if item specified by 'path' (eg: "Parent/child/item") is closed. | |
int | is_close (Fl_Tree_Item *item) const |
See if item is closed. | |
int | is_open (const char *path) const |
See if item specified by 'path' (eg: "Parent/child/item") is open. | |
int | is_open (Fl_Tree_Item *item) const |
See if item is open. | |
int | is_selected (const char *path) |
See if item specified by 'path' (eg: "Parent/child/item") is selected. | |
int | is_selected (Fl_Tree_Item *item) const |
See if the specified item is selected. | |
Fl_Tree_Item * | item_clicked () |
Return the item that was last clicked. | |
void | labelfont (int val) |
Set the default font face used for item's labels when new items are created. | |
int | labelfont () const |
Get the default font face used for item's labels when new items are created. | |
void | labelsize (int val) |
Set the default label font size used for creating new items. | |
int | labelsize () const |
Get the default label fontsize used for creating new items. | |
Fl_Tree_Item * | last () |
Returns the last item in the tree. | |
void | marginleft (int val) |
Set the amount of white space (in pixels) that should appear between the widget's left border and the left side of the tree's contents. | |
int | marginleft () const |
Get the amount of white space (in pixels) that should appear between the widget's left border and the tree's contents. | |
void | margintop (int val) |
Sets the amount of white space (in pixels) that should appear between the widget's top border and the top of the tree's contents. | |
int | margintop () const |
Get the amount of white space (in pixels) that should appear between the widget's top border and the top of the tree's contents. | |
int | open (const char *path) |
Opens the item specified by a 'menu item' style pathname (eg: "Parent/child/item"). | |
void | open (Fl_Tree_Item *item) |
Open the specified 'item'. | |
void | openicon (Fl_Pixmap *val) |
Sets the icon to be used as the 'open' icon. | |
Fl_Pixmap * | openicon () const |
Returns the icon to be used as the 'open' icon. | |
Fl_Tree_Item * | parent (Fl_Tree_Item *item) |
Return the parent for specified 'item'. | |
int | remove (Fl_Tree_Item *item) |
Remove the specified 'item' from the tree. | |
Fl_Tree_Item * | root () |
Returns the root item. | |
void | root_label (const char *new_label) |
Set the label for the root item. | |
int | select (const char *path) |
Select an item specified by 'path' (eg: "Parent/child/item"). | |
void | select (Fl_Tree_Item *item) |
Select the specified item. | |
int | select_only (Fl_Tree_Item *selitem) |
Select only this item. | |
void | select_toggle (Fl_Tree_Item *item) |
Toggle item's select state. | |
void | selectbox (Fl_Boxtype val) |
Gets the style of box used to draw selected items. | |
Fl_Boxtype | selectbox () const |
Sets the style of box used to draw selected items. | |
void | selectmode (Fl_Tree_Select val) |
Sets the tree's selection mode. | |
Fl_Tree_Select | selectmode () const |
Gets the tree's current selection mode. | |
void | show_self () |
Print the tree as 'ascii art' to stdout. | |
void | showcollapse (int val) |
Set if we should show the collapse icon or not. | |
int | showcollapse () const |
Returns 1 if the collapse icon is enabled, 0 if not. | |
void | showroot (int val) |
Set if the root item should be shown or not. | |
int | showroot () const |
Returns 1 if the root item is to be shown, or 0 if not. | |
void | sortorder (Fl_Tree_Sort val) |
Gets the sort order used to add items to the tree. | |
Fl_Tree_Sort | sortorder () const |
Set the default sort order used when items are added to the tree. | |
void | usericon (Fl_Pixmap *val) |
Sets the Fl_Pixmap to be used as the default user icon for all newly created items. | |
Fl_Pixmap * | usericon () const |
Returns the Fl_Pixmap being used as the default user icon for newly created items. | |
~Fl_Tree () | |
Destructor. | |
Protected Member Functions | |
const Fl_Tree_Item * | find_clicked () const |
Find the item that was clicked. | |
void | item_clicked (Fl_Tree_Item *val) |
Set the item that was last clicked. |
Fl_Tree // Top level widget |--- Fl_Tree_Item // Items in the tree |--- Fl_Tree_Prefs // Preferences for the tree |--- Fl_Tree_Connector (enum) // Connection modes |--- Fl_Tree_Select (enum) // Selection modes |--- Fl_Tree_Sort (enum) // Sort behavior
An expandable tree widget.
Similar to Fl_Browser, Fl_Tree is browser of Fl_Tree_Item's, which can be in a parented hierarchy. Subtrees can be expanded or closed. Items can be added, deleted, inserted, sorted and re-ordered.
The tree items may also contain other FLTK widgets, like buttons, input fields, or even "custom" widgets.
The simple way to define a tree:
Fl_Tree tree(X,Y,W,H); tree.begin(); tree.add("Flintstones/Fred"); tree.add("Flintstones/Wilma"); tree.add("Flintstones/Pebbles"); tree.add("Simpsons/Homer"); tree.add("Simpsons/Marge"); tree.add("Simpsons/Bart"); tree.add("Simpsons/Lisa"); tree.end();
Items can be added with Fl_Tree::add(), removed with Fl_Tree::remove(), inserted with Fl_Tree::insert_above(), selected/deselected with Fl_Tree::select() and Fl_Tree::deselect(). Items can be swapped with Fl_Tree_Item::swap_children(), sorting control via Fl_Tree::sortorder().
The tree can have different selection behaviors controlled by Fl_Tree::selectmode().
FLTK and custom FLTK widgets can be assigned to tree items via Fl_Tree_Item::widget().
Parent nodes can be open/closed with open() and close(), icons can be assigned or redefined with some or all items via Fl_Tree_Item::openicon(), Fl_Tree_Item::closeicon(), Fl_Tree_Item::usericon().
Various default preferences can be manipulated vi Fl_Tree_Prefs, including colors, margins, connection lines.
Fl_Tree_Item * Fl_Tree::add | ( | const char * | path | ) |
Adds a new item, given a 'menu style' path, eg: "/Parent/Child/item".
Any parent nodes that don't already exist are created automatically. Adds the item based on the value of sortorder().
void Fl_Tree::clear | ( | ) | [inline] |
Clear all children from the tree.
The tree will be left completely empty.
int Fl_Tree::close | ( | const char * | path | ) | [inline] |
Closes the item specified by 'path', eg: "Parent/child/item".
Handles redrawing if anything was actually changed.
void Fl_Tree::close | ( | Fl_Tree_Item * | item | ) | [inline] |
Closes the 'item'.
Handles redrawing if anything was actually changed.
void Fl_Tree::closeicon | ( | Fl_Pixmap * | val | ) | [inline] |
Sets the icon to be used as the 'close' icon.
This overrides the built in default '[-]' icon.
[in] | val | -- The new pixmap, or zero to use the default [-] icon. |
Fl_Pixmap* Fl_Tree::closeicon | ( | ) | const [inline] |
Returns the icon to be used as the 'close' icon.
If none was set, the internal default is returned, a simple '[-]' icon.
int Fl_Tree::deselect | ( | const char * | path | ) | [inline] |
De-select an item specified by 'path' (eg: "Parent/child/item").
Handles redrawing if anything was actually changed.
void Fl_Tree::deselect | ( | Fl_Tree_Item * | item | ) | [inline] |
De-select the specified item.
Handles redrawing if anything was actually changed.
int Fl_Tree::deselect_all | ( | Fl_Tree_Item * | item = 0 |
) |
Deselect item and all its children.
If item is NULL, root() is used. Handles calling redraw() if anything was changed. Returns count of how many items were in the 'selected' state, ie. how many items were "changed".
const Fl_Tree_Item* Fl_Tree::find_clicked | ( | ) | const [inline, protected] |
Find the item that was clicked.
You probably want to use item_clicked() instead, which is fast.
This method walks the entire tree looking for the first item that is under the mouse (ie. at Fl::event_x()/Fl:event_y().
Use this method /only/ if you've subclassed Fl_Tree, and are receiving events before Fl_Tree has been able to process and update item_clicked().
Fl_Tree_Item * Fl_Tree::find_item | ( | const char * | path | ) |
Find the item, given a menu style path, eg: "/Parent/Child/item".
There is both a const and non-const version of this method. Const version allows pure const methods to use this method to do lookups without causing compiler errors.
Fl_Tree_Item* Fl_Tree::first | ( | ) | [inline] |
Returns the first item in the tree.
Use this to walk the tree in the forward direction, eg:
for ( Fl_Tree_Item *item = tree->first(); item; item = item->next() ) { printf("Item: %s\n", item->label()); }
Fl_Tree_Item * Fl_Tree::insert_above | ( | Fl_Tree_Item * | above, | |
const char * | name | |||
) |
Inserts a new item above the specified Fl_Tree_Item, with the label set to 'name'.
int Fl_Tree::is_close | ( | const char * | path | ) | const [inline] |
See if item specified by 'path' (eg: "Parent/child/item") is closed.
int Fl_Tree::is_close | ( | Fl_Tree_Item * | item | ) | const [inline] |
See if item is closed.
int Fl_Tree::is_open | ( | const char * | path | ) | const [inline] |
See if item specified by 'path' (eg: "Parent/child/item") is open.
Items that are 'open' are themselves not necessarily visible; one of the item's parents might be closed.
int Fl_Tree::is_open | ( | Fl_Tree_Item * | item | ) | const [inline] |
See if item is open.
Items that are 'open' are themselves not necessarily visible; one of the item's parents might be closed.
int Fl_Tree::is_selected | ( | const char * | path | ) | [inline] |
See if item specified by 'path' (eg: "Parent/child/item") is selected.
int Fl_Tree::is_selected | ( | Fl_Tree_Item * | item | ) | const [inline] |
See if the specified item is selected.
Fl_Tree_Item* Fl_Tree::item_clicked | ( | ) | [inline] |
Return the item that was last clicked.
Valid only from within an Fl_Tree::callback().
void Fl_Tree::item_clicked | ( | Fl_Tree_Item * | val | ) | [inline, protected] |
Set the item that was last clicked.
Should only be used by subclasses needing to change this value. Normally Fl_Tree manages this value.
void Fl_Tree::labelfont | ( | int | val | ) | [inline] |
Set the default font face used for item's labels when new items are created.
Don't use this if you want to change an existing label() size; use item->labelfont(int) instead.
int Fl_Tree::labelfont | ( | ) | const [inline] |
Get the default font face used for item's labels when new items are created.
Don't use this if you want to change an existing label() size; use item->labelfont() instead.
void Fl_Tree::labelsize | ( | int | val | ) | [inline] |
Set the default label font size used for creating new items.
To change the font size on a per-item basis, use Fl_Tree_Item::labelsize(int)
Fl_Tree_Item* Fl_Tree::last | ( | ) | [inline] |
Returns the last item in the tree.
Use this to walk the tree in reverse, eg:
for ( Fl_Tree_Item *item = tree->last(); item; item = item->prev() ) { printf("Item: %s\n", item->label()); }
int Fl_Tree::open | ( | const char * | path | ) | [inline] |
Opens the item specified by a 'menu item' style pathname (eg: "Parent/child/item").
This causes the item's children (if any) to be shown. Handles redrawing if anything was actually changed.
void Fl_Tree::open | ( | Fl_Tree_Item * | item | ) | [inline] |
Open the specified 'item'.
This causes the item's children (if any) to be shown. Handles redrawing if anything was actually changed.
void Fl_Tree::openicon | ( | Fl_Pixmap * | val | ) | [inline] |
Sets the icon to be used as the 'open' icon.
This overrides the built in default '[+]' icon.
[in] | val | -- The new pixmap, or zero to use the default [+] icon. |
Fl_Pixmap* Fl_Tree::openicon | ( | ) | const [inline] |
Returns the icon to be used as the 'open' icon.
If none was set, the internal default is returned, a simple '[+]' icon.
Fl_Tree_Item* Fl_Tree::parent | ( | Fl_Tree_Item * | item | ) | [inline] |
Return the parent for specified 'item'.
int Fl_Tree::remove | ( | Fl_Tree_Item * | item | ) | [inline] |
Remove the specified 'item' from the tree.
If it has children, all those are removed too.
void Fl_Tree::root_label | ( | const char * | new_label | ) | [inline] |
Set the label for the root item.
Makes an internally managed copy of 'new_label'.
int Fl_Tree::select | ( | const char * | path | ) | [inline] |
Select an item specified by 'path' (eg: "Parent/child/item").
Handles redrawing if anything was actually changed.
void Fl_Tree::select | ( | Fl_Tree_Item * | item | ) | [inline] |
Select the specified item.
Use 'deselect()' to de-select it. Handles redrawing if anything was actually changed.
int Fl_Tree::select_only | ( | Fl_Tree_Item * | selitem | ) |
Select only this item.
If item is NULL, root() is used. Handles calling redraw() if anything was changed. Returns how many items were changed, if any.
void Fl_Tree::select_toggle | ( | Fl_Tree_Item * | item | ) | [inline] |
Toggle item's select state.
Handles redrawing.
void Fl_Tree::selectbox | ( | Fl_Boxtype | val | ) | [inline] |
Gets the style of box used to draw selected items.
This is an fltk Fl_Boxtype. The default is influenced by FLTK's current Fl::scheme()
Fl_Boxtype Fl_Tree::selectbox | ( | ) | const [inline] |
Sets the style of box used to draw selected items.
This is an fltk Fl_Boxtype. The default is influenced by FLTK's current Fl::scheme()
void Fl_Tree::show_self | ( | ) | [inline] |
Print the tree as 'ascii art' to stdout.
Used mainly for debugging.
void Fl_Tree::showcollapse | ( | int | val | ) | [inline] |
Set if we should show the collapse icon or not.
If collapse icons are disabled, the user will not be able to interactively collapse items in the tree, unless the application provides some other means via open() and close().
[in] | val | 1: shows collapse icons (default), 0: hides collapse icons. |
void Fl_Tree::showroot | ( | int | val | ) | [inline] |
Set if the root item should be shown or not.
[in] | val | 1 -- show the root item (default) 0 -- hide the root item. |
Fl_Tree_Sort Fl_Tree::sortorder | ( | ) | const [inline] |
Set the default sort order used when items are added to the tree.
See Fl_Tree_Sort for possible values.
void Fl_Tree::usericon | ( | Fl_Pixmap * | val | ) | [inline] |
Sets the Fl_Pixmap to be used as the default user icon for all newly created items.
If you want to specify user icons on a per-item basis, use Fl_Tree_Item::usericon() instead.
[in] | val | -- The new pixmap to be used, or zero to disable user icons. |
Fl_Pixmap* Fl_Tree::usericon | ( | ) | const [inline] |
Returns the Fl_Pixmap being used as the default user icon for newly created items.
Returns zero if no icon has been set, which is the default.