diff options
| author | Greg Ercolano <erco@seriss.com> | 2009-12-08 08:06:44 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2009-12-08 08:06:44 +0000 |
| commit | a657069cc53cc05245762e9323efa040a9f70da2 (patch) | |
| tree | c007a095998f8a4d20ed4359eb7174803c4f8784 /FL/Fl_Tree_Item.H | |
| parent | 5bc48808b6aed5469c3e62e1402e10c797a5d02a (diff) | |
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
Diffstat (limited to 'FL/Fl_Tree_Item.H')
| -rw-r--r-- | FL/Fl_Tree_Item.H | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/FL/Fl_Tree_Item.H b/FL/Fl_Tree_Item.H index 55023d38b..674955cd4 100644 --- a/FL/Fl_Tree_Item.H +++ b/FL/Fl_Tree_Item.H @@ -7,7 +7,7 @@ #include <FL/Fl.H> #include <FL/Fl_Widget.H> -#include <FL/Fl_Pixmap.H> +#include <FL/Fl_Image.H> #include <FL/fl_draw.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 _label_xywh[4]; // xywh of label 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 *_parent; // parent item (=0 if root) + void *_userdata; // user data that can be associated with an item protected: void show_widgets(); void hide_widgets(); @@ -81,11 +82,17 @@ protected: public: Fl_Tree_Item(const Fl_Tree_Prefs &prefs); // CTOR ~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 show_self(const char *indent = "") const; void label(const char *val); 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. void labelfont(int val) { @@ -209,9 +216,9 @@ public: /// Toggle the item's selection state. void select_toggle() { if ( is_selected() ) { - deselect(); // deselect if selected + deselect(); // deselect if selected } else { - select(); // select if deselected + select(); // select if deselected } } /// Disable the item's selection state. @@ -225,11 +232,11 @@ public: int deselect_all() { int count = 0; if ( is_selected() ) { - deselect(); - ++count; + deselect(); + ++count; } for ( int t=0; t<children(); t++ ) { - count += child(t)->deselect_all(); + count += child(t)->deselect_all(); } return(count); } @@ -249,12 +256,12 @@ public: void activate(int val=1) { _active = val; if ( _widget && val != (int)_widget->active() ) { - if ( val ) { - _widget->activate(); - } else { - _widget->deactivate(); - } - _widget->redraw(); + if ( val ) { + _widget->activate(); + } else { + _widget->deactivate(); + } + _widget->redraw(); } } /// Deactivate the item; the callback() won't be invoked when clicked. @@ -271,12 +278,12 @@ public: char is_active() const { return(_active); } - /// Set the user icon's pixmap. '0' will disable. - void usericon(Fl_Pixmap *val) { + /// Set the user icon's image. '0' will disable. + void usericon(Fl_Image *val) { _usericon = val; } /// Get the user icon. Returns '0' if disabled. - Fl_Pixmap *usericon() const { + Fl_Image *usericon() const { return(_usericon); } ////////////////// |
