diff options
| author | Greg Ercolano <erco@seriss.com> | 2013-11-06 20:44:47 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2013-11-06 20:44:47 +0000 |
| commit | 33ab9cfed1693a3cb9577c680e1d504354cd98c0 (patch) | |
| tree | d06ccdcd4953a08c74b8a01a527dfab66b3c8b95 /src/Fl_Tree.cxx | |
| parent | 52d395ad818d28053d34e7a634d4c9c3eb8ab755 (diff) | |
Fl_Tree:
o Added new method Fl_Tree::get_selected_items()
o Modified Fl_Tree_Item_Array to usable in a general way (i.e. beyond Fl_Tree's internal use)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10016 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Tree.cxx')
| -rw-r--r-- | src/Fl_Tree.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx index 0ff40a8c7..ba37dab3f 100644 --- a/src/Fl_Tree.cxx +++ b/src/Fl_Tree.cxx @@ -924,6 +924,31 @@ Fl_Tree_Item *Fl_Tree::next_selected_item(Fl_Tree_Item *item) { return(0); } +#if FLTK_ABI_VERSION >= 10303 /* reason for this: Fl_Tree_Item_Array::manage_item_destroy() */ +/// Returns the currently selected items as an array. Example: +/// \code +/// // Get selected items as an array +/// Fl_Tree_Item_Array items; +/// tree->get_selected_items(items); +/// // Manipulate the returned array +/// for ( int t=0; t<items.total(); t++ ) { +/// Fl_Tree_Item &item = items[t]; +/// ..do stuff with each selected item.. +/// } +/// \endcode +/// \param[in] items The returned array of selected items. +/// \returns The number of items in the returned array. +/// \see first_selected_item(), next_selected_item() +/// +int Fl_Tree::get_selected_items(Fl_Tree_Item_Array &ret_items) { + ret_items.clear(); + for ( Fl_Tree_Item *i=first_selected_item(); i; i=next_selected_item(i) ) { + ret_items.add(i); + } + return ret_items.total(); +} +#endif + /// Open the specified 'item'. /// This causes the item's children (if any) to be shown. /// Handles redrawing if anything was actually changed. |
