2009-11-18 15:22:51 +03:00
|
|
|
//
|
|
|
|
// "$Id$"
|
|
|
|
//
|
|
|
|
|
2009-11-14 18:49:12 +03:00
|
|
|
#ifndef _FL_TREE_ITEM_ARRAY_H
|
|
|
|
#define _FL_TREE_ITEM_ARRAY_H
|
|
|
|
|
2012-01-19 16:44:26 +04:00
|
|
|
#include <FL/Fl.H>
|
2010-09-02 23:38:08 +04:00
|
|
|
#include "Fl_Export.H"
|
|
|
|
|
|
|
|
class FL_EXPORT Fl_Tree_Item; // forward decl must *precede* first doxygen comment block
|
2009-12-08 11:06:44 +03:00
|
|
|
// or doxygen will not document our class..
|
2009-11-14 18:49:12 +03:00
|
|
|
|
2009-12-08 11:06:44 +03:00
|
|
|
//////////////////////////
|
2009-11-14 18:49:12 +03:00
|
|
|
// FL/Fl_Tree_Item_Array.H
|
2009-12-08 11:06:44 +03:00
|
|
|
//////////////////////////
|
2009-11-14 18:49:12 +03:00
|
|
|
//
|
|
|
|
// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
|
2010-11-29 00:06:39 +03:00
|
|
|
// Copyright (C) 2009-2010 by Greg Ercolano.
|
2009-11-14 18:49:12 +03:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/COPYING.php
|
|
|
|
//
|
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
2009-11-14 18:49:12 +03:00
|
|
|
//
|
|
|
|
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief This file defines a class that manages an array of Fl_Tree_Item pointers.
|
|
|
|
///
|
|
|
|
|
|
|
|
/// \brief Manages an array of Fl_Tree_Item pointers.
|
|
|
|
///
|
|
|
|
/// Because FLTK 1.x.x. has mandated that templates and STL not be used,
|
|
|
|
/// we use this class to dynamically manage the arrays.
|
|
|
|
///
|
|
|
|
/// None of the methods do range checking on index values; the caller
|
|
|
|
/// must be sure that index values are within the range 0<index<total()
|
|
|
|
/// (unless otherwise noted).
|
|
|
|
///
|
|
|
|
|
2010-09-02 23:38:08 +04:00
|
|
|
class FL_EXPORT Fl_Tree_Item_Array {
|
2009-11-14 18:49:12 +03:00
|
|
|
Fl_Tree_Item **_items; // items array
|
|
|
|
int _total; // #items in array
|
|
|
|
int _size; // #items *allocated* for array
|
|
|
|
int _chunksize; // #items to enlarge mem allocation
|
2013-11-07 00:44:47 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
|
|
|
enum {
|
|
|
|
MANAGE_ITEM = 1, ///> manage the Fl_Tree_Item's internals (internal use only)
|
|
|
|
};
|
|
|
|
char _flags; // flags to control behavior
|
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
void enlarge(int count);
|
|
|
|
public:
|
|
|
|
Fl_Tree_Item_Array(int new_chunksize = 10); // CTOR
|
|
|
|
~Fl_Tree_Item_Array(); // DTOR
|
|
|
|
Fl_Tree_Item_Array(const Fl_Tree_Item_Array *o); // COPY CTOR
|
|
|
|
/// Return the item and index \p i.
|
|
|
|
Fl_Tree_Item *operator[](int i) {
|
|
|
|
return(_items[i]);
|
|
|
|
}
|
|
|
|
/// Const version of operator[](int i)
|
|
|
|
const Fl_Tree_Item *operator[](int i) const {
|
|
|
|
return(_items[i]);
|
|
|
|
}
|
|
|
|
/// Return the total items in the array, or 0 if empty.
|
|
|
|
int total() const {
|
|
|
|
return(_total);
|
|
|
|
}
|
|
|
|
/// Swap the two items at index positions \p ax and \p bx.
|
2012-11-07 00:46:14 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10301
|
2012-01-19 16:44:26 +04:00
|
|
|
// NEW -- code moved to .cxx
|
|
|
|
void swap(int ax, int bx);
|
|
|
|
#else /*FLTK_ABI_VERSION*/
|
|
|
|
// OLD
|
2009-11-14 18:49:12 +03:00
|
|
|
void swap(int ax, int bx) {
|
|
|
|
Fl_Tree_Item *asave = _items[ax];
|
|
|
|
_items[ax] = _items[bx];
|
|
|
|
_items[bx] = asave;
|
|
|
|
}
|
2012-01-19 16:44:26 +04:00
|
|
|
#endif /*FLTK_ABI_VERSION*/
|
2014-09-04 22:56:52 +04:00
|
|
|
int move(int to, int from);
|
|
|
|
int deparent(int pos);
|
|
|
|
int reparent(Fl_Tree_Item *item, Fl_Tree_Item *newparent, int pos);
|
2009-11-14 18:49:12 +03:00
|
|
|
void clear();
|
|
|
|
void add(Fl_Tree_Item *val);
|
|
|
|
void insert(int pos, Fl_Tree_Item *new_item);
|
2014-01-21 01:23:24 +04:00
|
|
|
void replace(int pos, Fl_Tree_Item *new_item);
|
2009-11-14 18:49:12 +03:00
|
|
|
void remove(int index);
|
|
|
|
int remove(Fl_Tree_Item *item);
|
2013-11-07 00:44:47 +04:00
|
|
|
#if FLTK_ABI_VERSION >= 10303
|
|
|
|
/// Option to control if Fl_Tree_Item_Array's destructor will also destroy the Fl_Tree_Item's.
|
|
|
|
/// If set: items and item array is destroyed.
|
|
|
|
/// If clear: only the item array is destroyed, not items themselves.
|
|
|
|
void manage_item_destroy(int val) {
|
|
|
|
if ( val ) _flags |= MANAGE_ITEM; else _flags &= ~MANAGE_ITEM;
|
|
|
|
}
|
|
|
|
int manage_item_destroy() const {
|
|
|
|
return _flags & MANAGE_ITEM ? 1 : 0;
|
|
|
|
}
|
|
|
|
#endif
|
2009-11-14 18:49:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*_FL_TREE_ITEM_ARRAY_H*/
|
2009-11-18 15:22:51 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// End of "$Id$".
|
|
|
|
//
|