Checked in SebHoll's API mods, fixed indents.

o Added user_data() to Fl_Tree_Item
	o Added insert() and add() methods that allow specification of Fl_Tree_Prefs
	o Changed Fl_Pixmap args to Fl_Image for more flexibility
	o Fixes for positioning of items in the presence of user icons
	o find_children() changed from protected -> public



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6956 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Greg Ercolano
2009-12-08 08:06:44 +00:00
parent 5bc48808b6
commit a657069cc5
8 changed files with 251 additions and 222 deletions
+40 -37
View File
@@ -101,12 +101,12 @@
/// ///
class Fl_Tree : public Fl_Group { class Fl_Tree : public Fl_Group {
Fl_Tree_Item *_root; // can be null! Fl_Tree_Item *_root; // can be null!
Fl_Tree_Item *_item_clicked; Fl_Tree_Item *_item_clicked;
Fl_Tree_Prefs _prefs; // all the tree's settings Fl_Tree_Prefs _prefs; // all the tree's settings
Fl_Scrollbar *_vscroll; Fl_Scrollbar *_vscroll;
protected: public:
/// Find the item that was clicked. /// Find the item that was clicked.
/// You probably want to use item_clicked() instead, which is fast. /// You probably want to use item_clicked() instead, which is fast.
/// ///
@@ -122,6 +122,7 @@ protected:
if ( ! _root ) return(0); if ( ! _root ) return(0);
return(_root->find_clicked(_prefs)); return(_root->find_clicked(_prefs));
} }
protected:
/// Set the item that was last clicked. /// Set the item that was last clicked.
/// Should only be used by subclasses needing to change this value. /// Should only be used by subclasses needing to change this value.
/// Normally Fl_Tree manages this value. /// Normally Fl_Tree manages this value.
@@ -157,7 +158,9 @@ public:
// Item creation/removal methods // Item creation/removal methods
//////////////////////////////// ////////////////////////////////
Fl_Tree_Item *add(const char *path); Fl_Tree_Item *add(const char *path);
Fl_Tree_Item* add(Fl_Tree_Item *item, const char *name);
Fl_Tree_Item *insert_above(Fl_Tree_Item *above, const char *name); Fl_Tree_Item *insert_above(Fl_Tree_Item *above, const char *name);
Fl_Tree_Item* insert(Fl_Tree_Item *item, const char *name, int pos);
/// Remove the specified 'item' from the tree. /// Remove the specified 'item' from the tree.
/// If it has children, all those are removed too. /// If it has children, all those are removed too.
@@ -166,11 +169,11 @@ public:
int remove(Fl_Tree_Item *item) { int remove(Fl_Tree_Item *item) {
if ( !item ) return(0); if ( !item ) return(0);
if ( item == _root ) { if ( item == _root ) {
clear(); clear();
} else { } else {
Fl_Tree_Item *parent = item->parent(); // find item's parent Fl_Tree_Item *parent = item->parent(); // find item's parent
if ( ! parent ) return(-1); if ( ! parent ) return(-1);
parent->remove_child(item); // remove child + children parent->remove_child(item); // remove child + children
} }
return(0); return(0);
} }
@@ -185,8 +188,8 @@ public:
/// Clear all the children of a particular node in the tree. /// Clear all the children of a particular node in the tree.
void clear_children(Fl_Tree_Item *item) { void clear_children(Fl_Tree_Item *item) {
if ( item->has_children() ) { if ( item->has_children() ) {
item->clear_children(); item->clear_children();
redraw(); // redraw only if there were children to clear redraw(); // redraw only if there were children to clear
} }
} }
@@ -242,7 +245,7 @@ public:
if ( ! _root ) return(0); if ( ! _root ) return(0);
Fl_Tree_Item *item = _root; Fl_Tree_Item *item = _root;
while ( item->has_children() ) { while ( item->has_children() ) {
item = item->child(item->children()-1); item = item->child(item->children()-1);
} }
return(item); return(item);
} }
@@ -257,8 +260,8 @@ public:
/// ///
void open(Fl_Tree_Item *item) { void open(Fl_Tree_Item *item) {
if ( ! item->is_open() ) { if ( ! item->is_open() ) {
item->open(); item->open();
redraw(); redraw();
} }
} }
/// Opens the item specified by a 'menu item' style pathname (eg: "Parent/child/item"). /// Opens the item specified by a 'menu item' style pathname (eg: "Parent/child/item").
@@ -272,8 +275,8 @@ public:
int open(const char *path) { int open(const char *path) {
Fl_Tree_Item *item = find_item(path); Fl_Tree_Item *item = find_item(path);
if ( item ) { if ( item ) {
open(item); open(item);
return(0); return(0);
} }
return(-1); return(-1);
} }
@@ -282,8 +285,8 @@ public:
/// ///
void close(Fl_Tree_Item *item) { void close(Fl_Tree_Item *item) {
if ( ! item->is_close() ) { if ( ! item->is_close() ) {
item->close(); item->close();
redraw(); redraw();
} }
} }
/// Closes the item specified by 'path', eg: "Parent/child/item". /// Closes the item specified by 'path', eg: "Parent/child/item".
@@ -297,8 +300,8 @@ public:
int close(const char *path) { int close(const char *path) {
Fl_Tree_Item *item = find_item(path); Fl_Tree_Item *item = find_item(path);
if ( item ) { if ( item ) {
close(item); close(item);
return(0); return(0);
} }
return(-1); return(-1);
} }
@@ -359,8 +362,8 @@ public:
/// ///
void select(Fl_Tree_Item *item) { void select(Fl_Tree_Item *item) {
if ( ! item->is_selected() ) { if ( ! item->is_selected() ) {
item->select(); item->select();
redraw(); redraw();
} }
} }
/// Select an item specified by 'path' (eg: "Parent/child/item"). /// Select an item specified by 'path' (eg: "Parent/child/item").
@@ -373,8 +376,8 @@ public:
int select(const char *path) { int select(const char *path) {
Fl_Tree_Item *item = find_item(path); Fl_Tree_Item *item = find_item(path);
if ( item ) { if ( item ) {
select(item); select(item);
return(0); return(0);
} }
return(-1); return(-1);
} }
@@ -390,8 +393,8 @@ public:
/// ///
void deselect(Fl_Tree_Item *item) { void deselect(Fl_Tree_Item *item) {
if ( item->is_selected() ) { if ( item->is_selected() ) {
item->deselect(); item->deselect();
redraw(); redraw();
} }
} }
/// De-select an item specified by 'path' (eg: "Parent/child/item"). /// De-select an item specified by 'path' (eg: "Parent/child/item").
@@ -404,8 +407,8 @@ public:
int deselect(const char *path) { int deselect(const char *path) {
Fl_Tree_Item *item = find_item(path); Fl_Tree_Item *item = find_item(path);
if ( item ) { if ( item ) {
deselect(item); deselect(item);
return(0); return(0);
} }
return(-1); return(-1);
} }
@@ -524,22 +527,22 @@ public:
_prefs.connectorwidth(val); _prefs.connectorwidth(val);
redraw(); redraw();
} }
/// Returns the Fl_Pixmap being used as the default user icon for newly created items. /// Returns the Fl_Image being used as the default user icon for newly created items.
/// Returns zero if no icon has been set, which is the default. /// Returns zero if no icon has been set, which is the default.
/// ///
Fl_Pixmap *usericon() const { Fl_Image *usericon() const {
return(_prefs.usericon()); return(_prefs.usericon());
} }
/// Sets the Fl_Pixmap to be used as the default user icon for all /// Sets the Fl_Image to be used as the default user icon for all
/// newly created items. /// newly created items.
/// ///
/// If you want to specify user icons on a per-item basis, /// If you want to specify user icons on a per-item basis,
/// use Fl_Tree_Item::usericon() instead. /// use Fl_Tree_Item::usericon() instead.
/// ///
/// \param[in] val -- The new pixmap to be used, or /// \param[in] val -- The new image to be used, or
/// zero to disable user icons. /// zero to disable user icons.
/// ///
void usericon(Fl_Pixmap *val) { void usericon(Fl_Image *val) {
_prefs.usericon(val); _prefs.usericon(val);
redraw(); redraw();
} }
@@ -547,15 +550,15 @@ public:
/// If none was set, the internal default is returned, /// If none was set, the internal default is returned,
/// a simple '[+]' icon. /// a simple '[+]' icon.
/// ///
Fl_Pixmap *openicon() const { Fl_Image *openicon() const {
return(_prefs.openicon()); return(_prefs.openicon());
} }
/// Sets the icon to be used as the 'open' icon. /// Sets the icon to be used as the 'open' icon.
/// This overrides the built in default '[+]' icon. /// This overrides the built in default '[+]' icon.
/// ///
/// \param[in] val -- The new pixmap, or zero to use the default [+] icon. /// \param[in] val -- The new image, or zero to use the default [+] icon.
/// ///
void openicon(Fl_Pixmap *val) { void openicon(Fl_Image *val) {
_prefs.openicon(val); _prefs.openicon(val);
redraw(); redraw();
} }
@@ -563,15 +566,15 @@ public:
/// If none was set, the internal default is returned, /// If none was set, the internal default is returned,
/// a simple '[-]' icon. /// a simple '[-]' icon.
/// ///
Fl_Pixmap *closeicon() const { Fl_Image *closeicon() const {
return(_prefs.closeicon()); return(_prefs.closeicon());
} }
/// Sets the icon to be used as the 'close' icon. /// Sets the icon to be used as the 'close' icon.
/// This overrides the built in default '[-]' icon. /// This overrides the built in default '[-]' icon.
/// ///
/// \param[in] val -- The new pixmap, or zero to use the default [-] icon. /// \param[in] val -- The new image, or zero to use the default [-] icon.
/// ///
void closeicon(Fl_Pixmap *val) { void closeicon(Fl_Image *val) {
_prefs.closeicon(val); _prefs.closeicon(val);
redraw(); redraw();
} }
+24 -17
View File
@@ -7,7 +7,7 @@
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/Fl_Widget.H> #include <FL/Fl_Widget.H>
#include <FL/Fl_Pixmap.H> #include <FL/Fl_Image.H>
#include <FL/fl_draw.H> #include <FL/fl_draw.H>
#include <FL/Fl_Tree_Item_Array.H> #include <FL/Fl_Tree_Item_Array.H>
@@ -70,9 +70,10 @@ class Fl_Tree_Item {
int _collapse_xywh[4]; // xywh of collapse icon (if any) int _collapse_xywh[4]; // xywh of collapse icon (if any)
int _label_xywh[4]; // xywh of label int _label_xywh[4]; // xywh of label
Fl_Widget *_widget; // item's label widget (optional) Fl_Widget *_widget; // item's label widget (optional)
Fl_Pixmap *_usericon; // item's user-specific icon (optional) Fl_Image *_usericon; // item's user-specific icon (optional)
Fl_Tree_Item_Array _children; // array of child items Fl_Tree_Item_Array _children; // array of child items
Fl_Tree_Item *_parent; // parent item (=0 if root) Fl_Tree_Item *_parent; // parent item (=0 if root)
void *_userdata; // user data that can be associated with an item
protected: protected:
void show_widgets(); void show_widgets();
void hide_widgets(); void hide_widgets();
@@ -81,11 +82,17 @@ protected:
public: public:
Fl_Tree_Item(const Fl_Tree_Prefs &prefs); // CTOR Fl_Tree_Item(const Fl_Tree_Prefs &prefs); // CTOR
~Fl_Tree_Item(); // DTOR ~Fl_Tree_Item(); // DTOR
Fl_Tree_Item(const Fl_Tree_Item *o); // COPY CTOR Fl_Tree_Item(const Fl_Tree_Item *o); // COPY CTOR
void draw(int X, int &Y, int W, Fl_Widget *tree, const Fl_Tree_Prefs &prefs, int lastchild=1); void draw(int X, int &Y, int W, Fl_Widget *tree, const Fl_Tree_Prefs &prefs, int lastchild=1);
void show_self(const char *indent = "") const; void show_self(const char *indent = "") const;
void label(const char *val); void label(const char *val);
const char *label() const; const char *label() const;
/// Set a user-data value for the item.
inline void user_data( void* data ) { _userdata = data; }
/// Retrieve the user-data value that has been assigned to the item.
inline void* user_data() const { return _userdata; }
/// Set item's label font face. /// Set item's label font face.
void labelfont(int val) { void labelfont(int val) {
@@ -209,9 +216,9 @@ public:
/// Toggle the item's selection state. /// Toggle the item's selection state.
void select_toggle() { void select_toggle() {
if ( is_selected() ) { if ( is_selected() ) {
deselect(); // deselect if selected deselect(); // deselect if selected
} else { } else {
select(); // select if deselected select(); // select if deselected
} }
} }
/// Disable the item's selection state. /// Disable the item's selection state.
@@ -225,11 +232,11 @@ public:
int deselect_all() { int deselect_all() {
int count = 0; int count = 0;
if ( is_selected() ) { if ( is_selected() ) {
deselect(); deselect();
++count; ++count;
} }
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
count += child(t)->deselect_all(); count += child(t)->deselect_all();
} }
return(count); return(count);
} }
@@ -249,12 +256,12 @@ public:
void activate(int val=1) { void activate(int val=1) {
_active = val; _active = val;
if ( _widget && val != (int)_widget->active() ) { if ( _widget && val != (int)_widget->active() ) {
if ( val ) { if ( val ) {
_widget->activate(); _widget->activate();
} else { } else {
_widget->deactivate(); _widget->deactivate();
} }
_widget->redraw(); _widget->redraw();
} }
} }
/// Deactivate the item; the callback() won't be invoked when clicked. /// Deactivate the item; the callback() won't be invoked when clicked.
@@ -271,12 +278,12 @@ public:
char is_active() const { char is_active() const {
return(_active); return(_active);
} }
/// Set the user icon's pixmap. '0' will disable. /// Set the user icon's image. '0' will disable.
void usericon(Fl_Pixmap *val) { void usericon(Fl_Image *val) {
_usericon = val; _usericon = val;
} }
/// Get the user icon. Returns '0' if disabled. /// Get the user icon. Returns '0' if disabled.
Fl_Pixmap *usericon() const { Fl_Image *usericon() const {
return(_usericon); return(_usericon);
} }
////////////////// //////////////////
+3 -3
View File
@@ -6,11 +6,11 @@
#define _FL_TREE_ITEM_ARRAY_H #define _FL_TREE_ITEM_ARRAY_H
class Fl_Tree_Item; // forward decl must *precede* first doxygen comment block class Fl_Tree_Item; // forward decl must *precede* first doxygen comment block
// or doxygen will not document our class.. // or doxygen will not document our class..
////////////////////// //////////////////////////
// FL/Fl_Tree_Item_Array.H // FL/Fl_Tree_Item_Array.H
////////////////////// //////////////////////////
// //
// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK // Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
// Copyright (C) 2009 by Greg Ercolano. // Copyright (C) 2009 by Greg Ercolano.
+20 -20
View File
@@ -88,11 +88,11 @@ class Fl_Tree_Prefs {
int _margintop; // -- int _margintop; // --
int _marginleft; // |- tree's margins int _marginleft; // |- tree's margins
//int _marginright; // | //int _marginright; // |
//int _marginbottom; // -- //int _marginbottom; // --
int _openchild_marginbottom; // extra space below an open child tree int _openchild_marginbottom; // extra space below an open child tree
int _usericonmarginleft; // space to left of user icon (if any) int _usericonmarginleft; // space to left of user icon (if any)
int _labelmarginleft; // space to left of label int _labelmarginleft; // space to left of label
int _connectorwidth; // connector width (right of open/close icon) int _connectorwidth; // connector width (right of open/close icon)
int _linespacing; // vertical space between lines int _linespacing; // vertical space between lines
// Colors // Colors
Fl_Color _fgcolor; // label's foreground color Fl_Color _fgcolor; // label's foreground color
@@ -101,9 +101,9 @@ class Fl_Tree_Prefs {
Fl_Color _inactivecolor; // inactive color Fl_Color _inactivecolor; // inactive color
Fl_Color _connectorcolor; // connector dotted line color Fl_Color _connectorcolor; // connector dotted line color
Fl_Tree_Connector _connectorstyle; // connector line style Fl_Tree_Connector _connectorstyle; // connector line style
Fl_Pixmap *_openpixmap; // the 'open' icon [+] Fl_Image *_openimage; // the 'open' icon [+]
Fl_Pixmap *_closepixmap; // the 'close' icon [-] Fl_Image *_closeimage; // the 'close' icon [-]
Fl_Pixmap *_userpixmap; // user's own icon Fl_Image *_userimage; // user's own icon
char _showcollapse; // 1=show collapse icons, 0=don't char _showcollapse; // 1=show collapse icons, 0=don't
char _showroot; // show the root item as part of the tree char _showroot; // show the root item as part of the tree
Fl_Tree_Sort _sortorder; // none, ascening, descending, etc. Fl_Tree_Sort _sortorder; // none, ascening, descending, etc.
@@ -268,28 +268,28 @@ public:
// Icons // Icons
//////////////////////////// ////////////////////////////
/// Get the current default 'open' icon. /// Get the current default 'open' icon.
/// Returns the Fl_Pixmap* of the icon, or 0 if none. /// Returns the Fl_Image* of the icon, or 0 if none.
/// ///
inline Fl_Pixmap *openicon() const { inline Fl_Image *openicon() const {
return(_openpixmap); return(_openimage);
} }
void openicon(Fl_Pixmap *val); void openicon(Fl_Image *val);
/// Gets the default 'close' icon /// Gets the default 'close' icon
/// Returns the Fl_Pixmap* of the icon, or 0 if none. /// Returns the Fl_Image* of the icon, or 0 if none.
/// ///
inline Fl_Pixmap *closeicon() const { inline Fl_Image *closeicon() const {
return(_closepixmap); return(_closeimage);
} }
void closeicon(Fl_Pixmap *val); void closeicon(Fl_Image *val);
/// Gets the default 'user icon' (default is 0) /// Gets the default 'user icon' (default is 0)
inline Fl_Pixmap *usericon() const { inline Fl_Image *usericon() const {
return(_userpixmap); return(_userimage);
} }
/// Sets the default 'user icon' /// Sets the default 'user icon'
/// Returns the Fl_Pixmap* of the icon, or 0 if none (default). /// Returns the Fl_Image* of the icon, or 0 if none (default).
/// ///
inline void usericon(Fl_Pixmap *val) { inline void usericon(Fl_Image *val) {
_userpixmap = val; _userimage = val;
} }
//////////////////////////// ////////////////////////////
+42 -28
View File
@@ -123,6 +123,18 @@ Fl_Tree_Item* Fl_Tree::insert_above(Fl_Tree_Item *above, const char *name) {
return(above->insert_above(_prefs, name)); return(above->insert_above(_prefs, name));
} }
/// Insert a new item into a tree-item's children at a specified position.
/// \returns the item that was added.
Fl_Tree_Item* Fl_Tree::insert(Fl_Tree_Item *item, const char *name, int pos) {
return(item->insert(_prefs, name, pos));
}
/// Add a new child to a tree-item.
/// \returns the item that was added.
Fl_Tree_Item* Fl_Tree::add(Fl_Tree_Item *item, const char *name) {
return(item->add(_prefs, name));
}
/// Find the item, given a menu style path, eg: "/Parent/Child/item". /// Find the item, given a menu style path, eg: "/Parent/Child/item".
/// ///
/// There is both a const and non-const version of this method. /// There is both a const and non-const version of this method.
@@ -209,11 +221,11 @@ int Fl_Tree::handle(int e) {
if ( ! _root ) return(ret); if ( ! _root ) return(ret);
switch ( e ) { switch ( e ) {
case FL_PUSH: { case FL_PUSH: {
lastselect = 0; lastselect = 0;
item_clicked(0); // assume no item was clicked item_clicked(0); // assume no item was clicked
Fl_Tree_Item *o = _root->find_clicked(_prefs); Fl_Tree_Item *o = _root->find_clicked(_prefs);
if ( o ) { if ( o ) {
ret |= 1; // handled ret |= 1; // handled
if ( Fl::event_button() == FL_LEFT_MOUSE ) { if ( Fl::event_button() == FL_LEFT_MOUSE ) {
// Was collapse icon clicked? // Was collapse icon clicked?
if ( o->event_on_collapse_icon(_prefs) ) { if ( o->event_on_collapse_icon(_prefs) ) {
@@ -226,9 +238,10 @@ int Fl_Tree::handle(int e) {
callback() && callback() &&
(!_vscroll->visible() || !Fl::event_inside(_vscroll)) ) { (!_vscroll->visible() || !Fl::event_inside(_vscroll)) ) {
item_clicked(o); // save item clicked item_clicked(o); // save item clicked
// Handle selection behavior // Handle selection behavior
switch ( _prefs.selectmode() ) { switch ( _prefs.selectmode() ) {
case FL_TREE_SELECT_NONE: { // no selection changes case FL_TREE_SELECT_NONE: { // no selection changes
break; break;
} }
case FL_TREE_SELECT_SINGLE: { case FL_TREE_SELECT_SINGLE: {
@@ -243,7 +256,7 @@ int Fl_Tree::handle(int e) {
changed = 1; // changed changed = 1; // changed
} }
} else if ( state & FL_CTRL ) { } else if ( state & FL_CTRL ) {
changed = 1; // changed changed = 1; // changed
o->select_toggle(); // toggle selection state o->select_toggle(); // toggle selection state
lastselect = o; // save we toggled it (prevents oscillation) lastselect = o; // save we toggled it (prevents oscillation)
} else { } else {
@@ -252,8 +265,9 @@ int Fl_Tree::handle(int e) {
break; break;
} }
} }
if ( changed ) { if ( changed ) {
redraw(); // make change(s) visible redraw(); // make change(s) visible
if ( when() & FL_WHEN_CHANGED ) { if ( when() & FL_WHEN_CHANGED ) {
set_changed(); set_changed();
do_callback((Fl_Widget*)this, user_data()); // item callback do_callback((Fl_Widget*)this, user_data()); // item callback
@@ -261,22 +275,22 @@ int Fl_Tree::handle(int e) {
} }
} }
} }
} }
break; break;
} }
case FL_DRAG: { case FL_DRAG: {
Fl_Tree_Item *o = _root->find_clicked(_prefs); Fl_Tree_Item *o = _root->find_clicked(_prefs);
if ( o ) { if ( o ) {
ret |= 1; // handled ret |= 1; // handled
// Item's label clicked? // Item's label clicked?
if ( o->event_on_label(_prefs) && if ( o->event_on_label(_prefs) &&
(!o->widget() || !Fl::event_inside(o->widget())) && (!o->widget() || !Fl::event_inside(o->widget())) &&
callback() && callback() &&
(!_vscroll->visible() || !Fl::event_inside(_vscroll)) ) { (!_vscroll->visible() || !Fl::event_inside(_vscroll)) ) {
item_clicked(o); // save item clicked item_clicked(o); // save item clicked
// Handle selection behavior // Handle selection behavior
switch ( _prefs.selectmode() ) { switch ( _prefs.selectmode() ) {
case FL_TREE_SELECT_NONE: { // no selection changes case FL_TREE_SELECT_NONE: { // no selection changes
break; break;
} }
case FL_TREE_SELECT_SINGLE: { case FL_TREE_SELECT_SINGLE: {
@@ -301,20 +315,20 @@ int Fl_Tree::handle(int e) {
} }
} }
if ( changed ) { if ( changed ) {
redraw(); // make change(s) visible redraw(); // make change(s) visible
if ( when() & FL_WHEN_CHANGED ) { if ( when() & FL_WHEN_CHANGED ) {
set_changed(); set_changed();
do_callback((Fl_Widget*)this, user_data()); // item callback do_callback((Fl_Widget*)this, user_data()); // item callback
} }
} }
} }
} }
} }
case FL_RELEASE: { case FL_RELEASE: {
if ( Fl::event_button() == FL_LEFT_MOUSE ) { if ( Fl::event_button() == FL_LEFT_MOUSE ) {
ret |= 1; ret |= 1;
} }
break; break;
} }
} }
return(ret); return(ret);
@@ -327,7 +341,7 @@ int Fl_Tree::handle(int e) {
/// ie. how many items were "changed". /// ie. how many items were "changed".
/// ///
int Fl_Tree::deselect_all(Fl_Tree_Item *item) { int Fl_Tree::deselect_all(Fl_Tree_Item *item) {
item = item ? item : root(); // NULL? use root() item = item ? item : root(); // NULL? use root()
int count = item->deselect_all(); int count = item->deselect_all();
if ( count ) redraw(); // anything changed? cause redraw if ( count ) redraw(); // anything changed? cause redraw
return(count); return(count);
@@ -343,17 +357,17 @@ int Fl_Tree::select_only(Fl_Tree_Item *selitem) {
int changed = 0; int changed = 0;
for ( Fl_Tree_Item *item = first(); item; item = item->next() ) { for ( Fl_Tree_Item *item = first(); item; item = item->next() ) {
if ( item == selitem ) { if ( item == selitem ) {
if ( item->is_selected() ) continue; // don't count if already selected if ( item->is_selected() ) continue; // don't count if already selected
item->select(); item->select();
++changed; ++changed;
} else { } else {
if ( item->is_selected() ) { if ( item->is_selected() ) {
item->deselect(); item->deselect();
++changed; ++changed;
} }
} }
} }
if ( changed ) redraw(); // anything changed? redraw if ( changed ) redraw(); // anything changed? redraw
return(changed); return(changed);
} }
+104 -99
View File
@@ -74,7 +74,7 @@ Fl_Tree_Item::~Fl_Tree_Item() {
_label = 0; _label = 0;
} }
_widget = 0; // Fl_Group will handle destruction _widget = 0; // Fl_Group will handle destruction
_usericon = 0; // user handled allocation _usericon = 0; // user handled allocation
//_children.clear(); // array's destructor handles itself //_children.clear(); // array's destructor handles itself
} }
@@ -103,6 +103,7 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Item *o) {
_label_xywh[2] = o->_label_xywh[2]; _label_xywh[2] = o->_label_xywh[2];
_label_xywh[3] = o->_label_xywh[3]; _label_xywh[3] = o->_label_xywh[3];
_usericon = o->usericon(); _usericon = o->usericon();
_userdata = 0;
_parent = o->_parent; _parent = o->_parent;
} }
@@ -119,7 +120,7 @@ void Fl_Tree_Item::show_self(const char *indent) const {
strcpy(i2, indent); strcpy(i2, indent);
strcat(i2, " |"); strcat(i2, " |");
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
child(t)->show_self(i2); child(t)->show_self(i2);
} }
} }
fflush(stdout); fflush(stdout);
@@ -153,11 +154,11 @@ void Fl_Tree_Item::clear_children() {
int Fl_Tree_Item::find_child(const char *name) { int Fl_Tree_Item::find_child(const char *name) {
if ( name ) { if ( name ) {
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
if ( child(t)->label() ) { if ( child(t)->label() ) {
if ( strcmp(child(t)->label(), name) == 0 ) { if ( strcmp(child(t)->label(), name) == 0 ) {
return(t); return(t);
} }
} }
} }
} }
return(-1); return(-1);
@@ -171,13 +172,13 @@ int Fl_Tree_Item::find_child(const char *name) {
const Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) const { const Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) const {
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
if ( child(t)->label() ) { if ( child(t)->label() ) {
if ( strcmp(child(t)->label(), *arr) == 0 ) { // match? if ( strcmp(child(t)->label(), *arr) == 0 ) { // match?
if ( *(arr+1) ) { // more in arr? descend if ( *(arr+1) ) { // more in arr? descend
return(_children[t]->find_item(arr+1)); return(_children[t]->find_item(arr+1));
} else { // end of arr? done } else { // end of arr? done
return(_children[t]); return(_children[t]);
} }
} }
} }
} }
return(0); return(0);
@@ -191,13 +192,13 @@ const Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) const {
Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) { Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) {
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
if ( child(t)->label() ) { if ( child(t)->label() ) {
if ( strcmp(child(t)->label(), *arr) == 0 ) { // match? if ( strcmp(child(t)->label(), *arr) == 0 ) { // match?
if ( *(arr+1) ) { // more in arr? descend if ( *(arr+1) ) { // more in arr? descend
return(_children[t]->find_item(arr+1)); return(_children[t]->find_item(arr+1));
} else { // end of arr? done } else { // end of arr? done
return(_children[t]); return(_children[t]);
} }
} }
} }
} }
return(0); return(0);
@@ -211,7 +212,7 @@ Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) {
int Fl_Tree_Item::find_child(Fl_Tree_Item *item) { int Fl_Tree_Item::find_child(Fl_Tree_Item *item) {
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
if ( item == child(t) ) { if ( item == child(t) ) {
return(t); return(t);
} }
} }
return(-1); return(-1);
@@ -227,30 +228,30 @@ Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs, const char *new_labe
item->_parent = this; item->_parent = this;
switch ( prefs.sortorder() ) { switch ( prefs.sortorder() ) {
case FL_TREE_SORT_NONE: { case FL_TREE_SORT_NONE: {
_children.add(item); _children.add(item);
return(item); return(item);
} }
case FL_TREE_SORT_ASCENDING: { case FL_TREE_SORT_ASCENDING: {
for ( int t=0; t<_children.total(); t++ ) { for ( int t=0; t<_children.total(); t++ ) {
Fl_Tree_Item *c = _children[t]; Fl_Tree_Item *c = _children[t];
if ( c->label() && strcmp(c->label(), new_label) > 0 ) { if ( c->label() && strcmp(c->label(), new_label) > 0 ) {
_children.insert(t, item); _children.insert(t, item);
return(item); return(item);
} }
} }
_children.add(item); _children.add(item);
return(item); return(item);
} }
case FL_TREE_SORT_DESCENDING: { case FL_TREE_SORT_DESCENDING: {
for ( int t=0; t<_children.total(); t++ ) { for ( int t=0; t<_children.total(); t++ ) {
Fl_Tree_Item *c = _children[t]; Fl_Tree_Item *c = _children[t];
if ( c->label() && strcmp(c->label(), new_label) < 0 ) { if ( c->label() && strcmp(c->label(), new_label) < 0 ) {
_children.insert(t, item); _children.insert(t, item);
return(item); return(item);
} }
} }
_children.add(item); _children.add(item);
return(item); return(item);
} }
} }
return(item); return(item);
@@ -292,7 +293,7 @@ Fl_Tree_Item *Fl_Tree_Item::insert_above(const Fl_Tree_Prefs &prefs, const char
for ( int t=0; t<p->children(); t++ ) { for ( int t=0; t<p->children(); t++ ) {
Fl_Tree_Item *c = p->child(t); Fl_Tree_Item *c = p->child(t);
if ( this == c ) { if ( this == c ) {
return(p->insert(prefs, new_label, t)); return(p->insert(prefs, new_label, t));
} }
} }
return(0); return(0);
@@ -304,9 +305,9 @@ Fl_Tree_Item *Fl_Tree_Item::insert_above(const Fl_Tree_Prefs &prefs, const char
int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) { int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) {
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
if ( child(t) == item ) { if ( child(t) == item ) {
item->clear_children(); item->clear_children();
_children.remove(t); _children.remove(t);
return(0); return(0);
} }
} }
return(-1); return(-1);
@@ -318,10 +319,10 @@ int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) {
int Fl_Tree_Item::remove_child(const char *name) { int Fl_Tree_Item::remove_child(const char *name) {
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
if ( child(t)->label() ) { if ( child(t)->label() ) {
if ( strcmp(child(t)->label(), name) == 0 ) { if ( strcmp(child(t)->label(), name) == 0 ) {
_children.remove(t); _children.remove(t);
return(0); return(0);
} }
} }
} }
return(-1); return(-1);
@@ -368,17 +369,17 @@ void Fl_Tree_Item::draw_horizontal_connector(int x1, int x2, int y, const Fl_Tre
fl_color(prefs.connectorcolor()); fl_color(prefs.connectorcolor());
switch ( prefs.connectorstyle() ) { switch ( prefs.connectorstyle() ) {
case FL_TREE_CONNECTOR_SOLID: case FL_TREE_CONNECTOR_SOLID:
y |= 1; // force alignment w/dot pattern y |= 1; // force alignment w/dot pattern
fl_line(x1,y,x2,y); fl_line(x1,y,x2,y);
return; return;
case FL_TREE_CONNECTOR_DOTTED: case FL_TREE_CONNECTOR_DOTTED:
y |= 1; // force alignment w/dot pattern y |= 1; // force alignment w/dot pattern
for ( int xx=x1; xx<=x2; xx++ ) { for ( int xx=x1; xx<=x2; xx++ ) {
if ( !(xx & 1) ) fl_point(xx, y); if ( !(xx & 1) ) fl_point(xx, y);
} }
return; return;
case FL_TREE_CONNECTOR_NONE: case FL_TREE_CONNECTOR_NONE:
return; return;
} }
} }
@@ -387,19 +388,19 @@ void Fl_Tree_Item::draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_
fl_color(prefs.connectorcolor()); fl_color(prefs.connectorcolor());
switch ( prefs.connectorstyle() ) { switch ( prefs.connectorstyle() ) {
case FL_TREE_CONNECTOR_SOLID: case FL_TREE_CONNECTOR_SOLID:
y1 |= 1; // force alignment w/dot pattern y1 |= 1; // force alignment w/dot pattern
y2 |= 1; // force alignment w/dot pattern y2 |= 1; // force alignment w/dot pattern
fl_line(x,y1,x,y2); fl_line(x,y1,x,y2);
return; return;
case FL_TREE_CONNECTOR_DOTTED: case FL_TREE_CONNECTOR_DOTTED:
y1 |= 1; // force alignment w/dot pattern y1 |= 1; // force alignment w/dot pattern
y2 |= 1; // force alignment w/dot pattern y2 |= 1; // force alignment w/dot pattern
for ( int yy=y1; yy<=y2; yy++ ) { for ( int yy=y1; yy<=y2; yy++ ) {
if ( yy & 1 ) fl_point(x, yy); if ( yy & 1 ) fl_point(x, yy);
} }
return; return;
case FL_TREE_CONNECTOR_NONE: case FL_TREE_CONNECTOR_NONE:
return; return;
} }
} }
@@ -418,15 +419,15 @@ const Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) const
} else { } else {
// See if event is over us // See if event is over us
if ( event_inside(_xywh) ) { // event within this item? if ( event_inside(_xywh) ) { // event within this item?
return(this); // found return(this); // found
} }
} }
if ( is_open() ) { // open? check children of this item if ( is_open() ) { // open? check children of this item
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
const Fl_Tree_Item *item; const Fl_Tree_Item *item;
if ( ( item = _children[t]->find_clicked(prefs) ) != NULL) { // check child and its descendents if ( ( item = _children[t]->find_clicked(prefs) ) != NULL) { // check child and its descendents
return(item); // found? return(item); // found?
} }
} }
} }
return(0); return(0);
@@ -448,15 +449,15 @@ Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) {
} else { } else {
// See if event is over us // See if event is over us
if ( event_inside(_xywh) ) { // event within this item? if ( event_inside(_xywh) ) { // event within this item?
return(this); // found return(this); // found
} }
} }
if ( is_open() ) { // open? check children of this item if ( is_open() ) { // open? check children of this item
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
Fl_Tree_Item *item; Fl_Tree_Item *item;
if ( ( item = _children[t]->find_clicked(prefs) ) != NULL ) { // check child and its descendents if ( ( item = _children[t]->find_clicked(prefs) ) != NULL ) { // check child and its descendents
return(item); // found? return(item); // found?
} }
} }
} }
return(0); return(0);
@@ -467,7 +468,9 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree,
const Fl_Tree_Prefs &prefs, int lastchild) { const Fl_Tree_Prefs &prefs, int lastchild) {
if ( ! _visible ) return; if ( ! _visible ) return;
fl_font(_labelfont, _labelsize); fl_font(_labelfont, _labelsize);
int H = _labelsize + fl_descent() + prefs.linespacing(); int H = _labelsize;
if(usericon() && H < usericon()->h()) H = usericon()->h();
H += prefs.linespacing() + fl_descent();
// Colors, fonts // Colors, fonts
Fl_Color fg = _selected ? prefs.bgcolor() : _labelfgcolor; Fl_Color fg = _selected ? prefs.bgcolor() : _labelfgcolor;
Fl_Color bg = _selected ? prefs.selectcolor() : _labelbgcolor; Fl_Color bg = _selected ? prefs.selectcolor() : _labelbgcolor;
@@ -500,95 +503,97 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree,
if ( drawthis ) { if ( drawthis ) {
// Draw connectors // Draw connectors
if ( prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) { if ( prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) {
// Horiz connector between center of icon and text // Horiz connector between center of icon and text
draw_horizontal_connector(hstartx, hendx, textycenter, prefs); draw_horizontal_connector(hstartx, hendx, textycenter, prefs);
if ( has_children() && is_open() ) { if ( has_children() && is_open() ) {
// Small vertical line down to children // Small vertical line down to children
draw_vertical_connector(hcenterx, textycenter, Y+H, prefs); draw_vertical_connector(hcenterx, textycenter, Y+H, prefs);
} }
// Connectors for last child // Connectors for last child
if ( ! is_root() ) { if ( ! is_root() ) {
if ( lastchild ) { if ( lastchild ) {
draw_vertical_connector(hstartx, Y, textycenter, prefs); draw_vertical_connector(hstartx, Y, textycenter, prefs);
} else { } else {
draw_vertical_connector(hstartx, Y, Y+H, prefs); draw_vertical_connector(hstartx, Y, Y+H, prefs);
} }
} }
} }
// Draw collapse icon // Draw collapse icon
if ( has_children() && prefs.showcollapse() ) { if ( has_children() && prefs.showcollapse() ) {
// Draw icon image // Draw icon image
if ( is_open() ) { if ( is_open() ) {
prefs.closeicon()->draw(icon_x,icon_y); prefs.closeicon()->draw(icon_x,icon_y);
} else { } else {
prefs.openicon()->draw(icon_x,icon_y); prefs.openicon()->draw(icon_x,icon_y);
} }
} }
// Background for this item // Background for this item
int &bx = _label_xywh[0] = X+(icon_w/2-1+prefs.connectorwidth()); int &bx = _label_xywh[0] = X+(icon_w/2-1+prefs.connectorwidth());
int &by = _label_xywh[1] = Y; int &by = _label_xywh[1] = Y;
int &bw = _label_xywh[2] = W-(icon_w/2-1+prefs.connectorwidth()); int &bw = _label_xywh[2] = W-(icon_w/2-1+prefs.connectorwidth());
int &bh = _label_xywh[3] = texth; int &bh = _label_xywh[3] = H;
// Draw bg only if different from tree's bg // Draw bg only if different from tree's bg
if ( bg != tree->color() || is_selected() ) { if ( bg != tree->color() || is_selected() ) {
if ( is_selected() ) { if ( is_selected() ) {
// Selected? Use selectbox() style // Selected? Use selectbox() style
fl_draw_box(prefs.selectbox(), bx, by, bw, bh, bg); fl_draw_box(prefs.selectbox(), bx, by, bw, bh, bg);
} else { } else {
// Not Selected? use plain filled rectangle // Not Selected? use plain filled rectangle
fl_color(bg); fl_color(bg);
fl_rectf(bx, by, bw, bh); fl_rectf(bx, by, bw, bh);
} }
} }
// Draw user icon (if any) // Draw user icon (if any)
int useroff = (icon_w/2-1+prefs.connectorwidth()); int useroff = (icon_w/2-1+prefs.connectorwidth());
if ( usericon() ) { if ( usericon() ) {
// Item has user icon? Use it // Item has user icon? Use it
useroff += prefs.usericonmarginleft(); useroff += prefs.usericonmarginleft();
usericon()->draw(X+useroff,icon_y); icon_y = textycenter - (usericon()->h() >> 1);
useroff += usericon()->w(); usericon()->draw(X+useroff,icon_y);
useroff += usericon()->w();
} else if ( prefs.usericon() ) { } else if ( prefs.usericon() ) {
// Prefs has user icon? Use it // Prefs has user icon? Use it
useroff += prefs.usericonmarginleft(); useroff += prefs.usericonmarginleft();
prefs.usericon()->draw(X+useroff,icon_y); icon_y = textycenter - (prefs.usericon()->h() >> 1);
useroff += prefs.usericon()->w(); prefs.usericon()->draw(X+useroff,icon_y);
useroff += prefs.usericon()->w();
} }
useroff += prefs.labelmarginleft(); useroff += prefs.labelmarginleft();
// Draw label // Draw label
if ( widget() ) { if ( widget() ) {
// Widget? Draw it // Widget? Draw it
int lx = X+useroff; int lx = X+useroff;
int ly = by; int ly = by;
int lw = widget()->w(); int lw = widget()->w();
int lh = bh; int lh = bh;
if ( widget()->x() != lx || widget()->y() != ly || if ( widget()->x() != lx || widget()->y() != ly ||
widget()->w() != lw || widget()->h() != lh ) { widget()->w() != lw || widget()->h() != lh ) {
widget()->resize(lx, ly, lw, lh); // fltk will handle drawing this widget()->resize(lx, ly, lw, lh); // fltk will handle drawing this
} }
} else { } else {
// No label widget? Draw text label // No label widget? Draw text label
if ( _label ) { if ( _label ) {
fl_color(fg); fl_color(fg);
fl_draw(_label, X+useroff, Y+H-fl_descent()-1); fl_draw(_label, X+useroff, Y+H-fl_descent()-1);
} }
} }
Y += H; Y += H;
} // end drawthis } // end drawthis
// Draw children // Draw children
if ( has_children() && is_open() ) { if ( has_children() && is_open() ) {
int child_x = drawthis ? // offset children to right, int child_x = drawthis ? // offset children to right,
(hcenterx - (icon_w/2) + 1) : X; // unless didn't drawthis (hcenterx - (icon_w/2) + 1) : X; // unless didn't drawthis
int child_w = W - (child_x-X); int child_w = W - (child_x-X);
int child_y_start = Y; int child_y_start = Y;
for ( int t=0; t<children(); t++ ) { for ( int t=0; t<children(); t++ ) {
int lastchild = ((t+1)==children()) ? 1 : 0; int lastchild = ((t+1)==children()) ? 1 : 0;
_children[t]->draw(child_x, Y, child_w, tree, prefs, lastchild); _children[t]->draw(child_x, Y, child_w, tree, prefs, lastchild);
} }
if ( has_children() && is_open() ) { if ( has_children() && is_open() ) {
Y += prefs.openchild_marginbottom(); // offset below open child tree Y += prefs.openchild_marginbottom(); // offset below open child tree
} }
if ( ! lastchild ) { if ( ! lastchild ) {
draw_vertical_connector(hstartx, child_y_start, Y, prefs); draw_vertical_connector(hstartx, child_y_start, Y, prefs);
} }
} }
} }
@@ -620,7 +625,7 @@ void Fl_Tree_Item::show_widgets() {
if ( _widget ) _widget->show(); if ( _widget ) _widget->show();
if ( is_open() ) { if ( is_open() ) {
for ( int t=0; t<_children.total(); t++ ) { for ( int t=0; t<_children.total(); t++ ) {
_children[t]->show_widgets(); _children[t]->show_widgets();
} }
} }
} }
@@ -681,9 +686,9 @@ Fl_Tree_Item *Fl_Tree_Item::next() {
return(c->child(0)); return(c->child(0));
} }
while ( ( p = c->parent() ) != NULL ) { // loop upwards through parents while ( ( p = c->parent() ) != NULL ) { // loop upwards through parents
int t = p->find_child(c); // find our position in parent's children[] array int t = p->find_child(c); // find our position in parent's children[] array
if ( ++t < p->children() ) // not last child? if ( ++t < p->children() ) // not last child?
return(p->child(t)); // return next child return(p->child(t)); // return next child
c = p; // child becomes parent to move up generation c = p; // child becomes parent to move up generation
} // loop: moves up to next parent } // loop: moves up to next parent
return(0); // hit root? done return(0); // hit root? done
@@ -698,13 +703,13 @@ Fl_Tree_Item *Fl_Tree_Item::next() {
/// ///
Fl_Tree_Item *Fl_Tree_Item::prev() { Fl_Tree_Item *Fl_Tree_Item::prev() {
Fl_Tree_Item *p=parent(); // start with parent Fl_Tree_Item *p=parent(); // start with parent
if ( ! p ) return(0); // hit root? done if ( ! p ) return(0); // hit root? done
int t = p->find_child(this); // find our position in parent's children[] array int t = p->find_child(this); // find our position in parent's children[] array
if ( --t == -1 ) { // are we first child? if ( --t == -1 ) { // are we first child?
return(p); // return immediate parent return(p); // return immediate parent
} }
p = p->child(t); // take parent's previous child p = p->child(t); // take parent's previous child
while ( p->has_children() ) { // has children? while ( p->has_children() ) { // has children?
p = p->child(p->children()-1); // take last child p = p->child(p->children()-1); // take last child
} }
return(p); return(p);
+7 -7
View File
@@ -68,8 +68,8 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) {
void Fl_Tree_Item_Array::clear() { void Fl_Tree_Item_Array::clear() {
if ( _items ) { if ( _items ) {
for ( int t=0; t<_total; t++ ) { for ( int t=0; t<_total; t++ ) {
delete _items[t]; delete _items[t];
_items[t] = 0; _items[t] = 0;
} }
free((void*)_items); _items = 0; free((void*)_items); _items = 0;
} }
@@ -88,9 +88,9 @@ void Fl_Tree_Item_Array::enlarge(int count) {
int newsize = _size + _chunksize; int newsize = _size + _chunksize;
Fl_Tree_Item **newitems = (Fl_Tree_Item**)malloc(newsize * sizeof(Fl_Tree_Item*)); Fl_Tree_Item **newitems = (Fl_Tree_Item**)malloc(newsize * sizeof(Fl_Tree_Item*));
if ( _items ) { if ( _items ) {
// Copy old array -> new, delete old // Copy old array -> new, delete old
memmove(newitems, _items, _size * sizeof(Fl_Tree_Item*)); memmove(newitems, _items, _size * sizeof(Fl_Tree_Item*));
free((void*)_items); _items = 0; free((void*)_items); _items = 0;
} }
// Adjust items/sizeitems // Adjust items/sizeitems
_items = newitems; _items = newitems;
@@ -145,8 +145,8 @@ void Fl_Tree_Item_Array::remove(int index) {
int Fl_Tree_Item_Array::remove(Fl_Tree_Item *item) { int Fl_Tree_Item_Array::remove(Fl_Tree_Item *item) {
for ( int t=0; t<_total; t++ ) { for ( int t=0; t<_total; t++ ) {
if ( item == _items[t] ) { if ( item == _items[t] ) {
remove(t); remove(t);
return(0); return(0);
} }
} }
return(-1); return(-1);
+11 -11
View File
@@ -73,19 +73,19 @@ static Fl_Pixmap L_closepixmap(L_close_xpm);
/// when items are add()ed to the tree. /// when items are add()ed to the tree.
/// This overrides the built in default '[+]' icon. /// This overrides the built in default '[+]' icon.
/// ///
/// \param[in] val -- The new pixmap, or zero to use the default [+] icon. /// \param[in] val -- The new image, or zero to use the default [+] icon.
/// ///
void Fl_Tree_Prefs::openicon(Fl_Pixmap *val) { void Fl_Tree_Prefs::openicon(Fl_Image *val) {
_openpixmap = val ? val : &L_openpixmap; _openimage = val ? val : &L_openpixmap;
} }
/// Sets the icon to be used as the 'close' icon. /// Sets the icon to be used as the 'close' icon.
/// This overrides the built in default '[-]' icon. /// This overrides the built in default '[-]' icon.
/// ///
/// \param[in] val -- The new pixmap, or zero to use the default [-] icon. /// \param[in] val -- The new image, or zero to use the default [-] icon.
/// ///
void Fl_Tree_Prefs::closeicon(Fl_Pixmap *val) { void Fl_Tree_Prefs::closeicon(Fl_Image *val) {
_closepixmap = val ? val : &L_closepixmap; _closeimage = val ? val : &L_closepixmap;
} }
/// Fl_Tree_Prefs constructor /// Fl_Tree_Prefs constructor
@@ -106,9 +106,9 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
_inactivecolor = FL_GRAY; _inactivecolor = FL_GRAY;
_connectorcolor = Fl_Color(43); _connectorcolor = Fl_Color(43);
_connectorstyle = FL_TREE_CONNECTOR_DOTTED; _connectorstyle = FL_TREE_CONNECTOR_DOTTED;
_openpixmap = &L_openpixmap; _openimage = &L_openpixmap;
_closepixmap = &L_closepixmap; _closeimage = &L_closepixmap;
_userpixmap = 0; _userimage = 0;
_showcollapse = 1; _showcollapse = 1;
_showroot = 1; _showroot = 1;
_connectorwidth = 17; _connectorwidth = 17;
@@ -118,9 +118,9 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
// Let fltk's current 'scheme' affect defaults // Let fltk's current 'scheme' affect defaults
if ( Fl::scheme() ) { if ( Fl::scheme() ) {
if ( strcmp(Fl::scheme(), "gtk+") == 0 ) { if ( strcmp(Fl::scheme(), "gtk+") == 0 ) {
_selectbox = _FL_GTK_THIN_UP_BOX; _selectbox = _FL_GTK_THIN_UP_BOX;
} else if ( strcmp(Fl::scheme(), "plastic") == 0 ) { } else if ( strcmp(Fl::scheme(), "plastic") == 0 ) {
_selectbox = _FL_PLASTIC_THIN_UP_BOX; _selectbox = _FL_PLASTIC_THIN_UP_BOX;
} }
} }
} }