diff options
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_Tree.H | 10 | ||||
| -rw-r--r-- | FL/Fl_Tree_Item.H | 4 | ||||
| -rw-r--r-- | FL/Fl_Tree_Prefs.H | 26 |
3 files changed, 38 insertions, 2 deletions
diff --git a/FL/Fl_Tree.H b/FL/Fl_Tree.H index f29161c01..ed2a2d526 100644 --- a/FL/Fl_Tree.H +++ b/FL/Fl_Tree.H @@ -96,6 +96,8 @@ /// Items can be found by their pathname using find_item(const char*), /// and an item's pathname can be found with item_pathname(). /// The selected items' colors are controlled by selection_color() (inherited from Fl_Widget). +/// A hook is provided to allow you to redefine how item's labels are drawn +/// via Fl_Tree::item_draw_callback(). /// /// \b SELECTION OF ITEMS /// @@ -465,7 +467,13 @@ public: Fl_Tree_Item_Draw_Mode item_draw_mode() const; void item_draw_mode(Fl_Tree_Item_Draw_Mode mode); void item_draw_mode(int mode); -#endif /*FLTK_ABI_VERSION*/ +#endif +#if FLTK_ABI_VERSION >= 10303 + void item_draw_callback(Fl_Tree_Item_Draw_Callback *cb, void *data=0); + Fl_Tree_Item_Draw_Callback* item_draw_callback() const; + void* item_draw_user_data() const; + void do_item_draw_callback(Fl_Tree_Item *o) const; +#endif int displayed(Fl_Tree_Item *item); void show_item(Fl_Tree_Item *item, int yoff); void show_item(Fl_Tree_Item *item); diff --git a/FL/Fl_Tree_Item.H b/FL/Fl_Tree_Item.H index 5a3a8d6db..81c73fd64 100644 --- a/FL/Fl_Tree_Item.H +++ b/FL/Fl_Tree_Item.H @@ -98,6 +98,10 @@ public: int y() const { return(_xywh[1]); } int w() const { return(_xywh[2]); } int h() const { return(_xywh[3]); } + int label_x() const { return(_label_xywh[0]); } + int label_y() const { return(_label_xywh[1]); } + int label_w() const { return(_label_xywh[2]); } + int label_h() const { return(_label_xywh[3]); } int calc_item_height(const Fl_Tree_Prefs &prefs) const; void draw(int X, int &Y, int W, Fl_Widget *tree, Fl_Tree_Item *itemfocus, const Fl_Tree_Prefs &prefs, int lastchild=1); void show_self(const char *indent = "") const; diff --git a/FL/Fl_Tree_Prefs.H b/FL/Fl_Tree_Prefs.H index b01033e78..5ced88f4b 100644 --- a/FL/Fl_Tree_Prefs.H +++ b/FL/Fl_Tree_Prefs.H @@ -93,6 +93,11 @@ enum Fl_Tree_Item_Draw_Mode { }; #endif /*FLTK_ABI_VERSION*/ +#if FLTK_ABI_VERSION >= 10303 +class Fl_Tree_Item; +typedef void (Fl_Tree_Item_Draw_Callback)(Fl_Tree_Item*, void*); +#endif + /// \class Fl_Tree_Prefs /// /// \brief Fl_Tree's Preferences class. @@ -134,6 +139,10 @@ class FL_EXPORT Fl_Tree_Prefs { Fl_Tree_Item_Reselect_Mode _itemreselectmode; // controls item selection callback() behavior Fl_Tree_Item_Draw_Mode _itemdrawmode; // controls how items draw label + widget() #endif /*FLTK_ABI_VERSION*/ +#if FLTK_ABI_VERSION >= 10303 + Fl_Tree_Item_Draw_Callback *_itemdrawcallback; // callback to handle drawing items (0=none) + void *_itemdrawuserdata; // data for drawing items (0=none) +#endif public: Fl_Tree_Prefs(); @@ -412,7 +421,22 @@ public: inline void item_draw_mode(Fl_Tree_Item_Draw_Mode val) { _itemdrawmode = val; } -#endif /*FLTK_ABI_VERSION*/ +#endif +#if FLTK_ABI_VERSION >= 10303 + void item_draw_callback(Fl_Tree_Item_Draw_Callback *cb, void *data=0) { + _itemdrawcallback = cb; + _itemdrawuserdata = data; + } + Fl_Tree_Item_Draw_Callback* item_draw_callback() const { + return(_itemdrawcallback); + } + void* item_draw_user_data() const { + return(_itemdrawuserdata); + } + void do_item_draw_callback(Fl_Tree_Item *o) const { + _itemdrawcallback(o, _itemdrawuserdata); + } +#endif }; #endif /*FL_TREE_PREFS_H*/ |
