From abdc83470530c5fa8e15370a2032093cd91dace7 Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Mon, 20 Jan 2014 21:23:24 +0000 Subject: o Added draw_item_content() to Fl_Tree_Item, a volatile method that can be overridden by subclasses to take drawing control of tree item's content. This replaces the old "item_draw_callback()" technique added a few months ago as an ABI feature; turned out the new technique is a better way to go. o The examples/tree-custom-draw-items.cxx demo adjusted accordingly. o Added missing docs for some methods that had none, including label_[xywh](). o Added related methods needed to implement this, including: Fl_Tree_Item_Array::replace() Fl_Tree_Item::replace() Fl_Tree::root(item) Fl_Tree::add() variations Fl_Tree_Item::drawbgcolor()/drawfgcolor() o Carefully worked the FLTK_ABI_VERSION macros so as to be ABI compatible with 1.3.0. o Verified 1.3.0 ABI compatibility with ABI Compliance Checker 1.99.8.5: http://ispras.linuxbase.org/index.php/ABI_compliance_checker git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10071 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Tree_Item_Array.cxx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/Fl_Tree_Item_Array.cxx') diff --git a/src/Fl_Tree_Item_Array.cxx b/src/Fl_Tree_Item_Array.cxx index 2519cf226..d83b0be12 100644 --- a/src/Fl_Tree_Item_Array.cxx +++ b/src/Fl_Tree_Item_Array.cxx @@ -150,6 +150,29 @@ void Fl_Tree_Item_Array::add(Fl_Tree_Item *val) { insert(_total, val); } +/// Replace the item at \p index with \p newitem. +/// +/// Old item at index position will be destroyed, +/// and the new item will take it's place, and stitched into the linked list. +/// +void Fl_Tree_Item_Array::replace(int index, Fl_Tree_Item *newitem) { + if ( _items[index] ) { // delete if non-zero +#if FLTK_ABI_VERSION >= 10303 + if ( _flags & MANAGE_ITEM ) +#endif + // Destroy old item + delete _items[index]; + } + _items[index] = newitem; // install new item +#if FLTK_ABI_VERSION >= 10303 + if ( _flags & MANAGE_ITEM ) +#endif + { + // Restitch into linked list + _items[index]->update_prev_next(index); + } +} + /// Remove the item at \param[in] index from the array. /// /// The item will be delete'd (if non-NULL), so its destructor will be called. -- cgit v1.2.3