FLTK 1.3.9: Fl_Tree_Item_Array.H Source File

FLTK 1.3.9

Loading...
Searching...
No Matches
Fl_Tree_Item_Array.H
Go to the documentation of this file.
1//
2// "$Id$"
3//
4
5#ifndef _FL_TREE_ITEM_ARRAY_H
6#define _FL_TREE_ITEM_ARRAY_H
7
8#include <FL/Fl.H>
9#include "Fl_Export.H"
10
11class Fl_Tree_Item; // forward decl must *precede* first doxygen comment block
12 // or doxygen will not document our class..
13
15// FL/Fl_Tree_Item_Array.H
17//
18// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
19// Copyright (C) 2009-2010 by Greg Ercolano.
20//
21// This library is free software. Distribution and use rights are outlined in
22// the file "COPYING" which should have been included with this file. If this
23// file is missing or damaged, see the license at:
24//
25// http://www.fltk.org/COPYING.php
26//
27// Please report all bugs and problems on the following page:
28//
29// http://www.fltk.org/str.php
30//
31
36
46
47 class FL_EXPORT Fl_Tree_Item_Array {
48 Fl_Tree_Item **_items; // items array
49 int _total; // #items in array
50 int _size; // #items *allocated* for array
51 int _chunksize; // #items to enlarge mem allocation
52#if FLTK_ABI_VERSION >= 10303
53 enum {
54 MANAGE_ITEM = 1,
55 };
56 char _flags; // flags to control behavior
57#endif
58 void enlarge(int count);
59public:
60 Fl_Tree_Item_Array(int new_chunksize = 10); // CTOR
61 ~Fl_Tree_Item_Array(); // DTOR
62 Fl_Tree_Item_Array(const Fl_Tree_Item_Array *o); // COPY CTOR
64 Fl_Tree_Item *operator[](int i) {
65 return(_items[i]);
66 }
68 const Fl_Tree_Item *operator[](int i) const {
69 return(_items[i]);
70 }
72 int total() const {
73 return(_total);
74 }
76#if FLTK_ABI_VERSION >= 10301
77 // NEW -- code moved to .cxx
78 void swap(int ax, int bx);
79#else /*FLTK_ABI_VERSION*/
80 // OLD
81 void swap(int ax, int bx) {
82 Fl_Tree_Item *asave = _items[ax];
83 _items[ax] = _items[bx];
84 _items[bx] = asave;
85 }
86#endif /*FLTK_ABI_VERSION*/
87 int move(int to, int from);
88 int deparent(int pos);
89 int reparent(Fl_Tree_Item *item, Fl_Tree_Item *newparent, int pos);
90 void clear();
91 void add(Fl_Tree_Item *val);
92 void insert(int pos, Fl_Tree_Item *new_item);
93 void replace(int pos, Fl_Tree_Item *new_item);
94 void remove(int index);
95 int remove(Fl_Tree_Item *item);
96#if FLTK_ABI_VERSION >= 10303
100 void manage_item_destroy(int val) {
101 if ( val ) _flags |= MANAGE_ITEM; else _flags &= ~MANAGE_ITEM;
102 }
103 int manage_item_destroy() const {
104 return _flags & MANAGE_ITEM ? 1 : 0;
105 }
106#endif
107};
108
109#endif /*_FL_TREE_ITEM_ARRAY_H*/
110
111//
112// End of "$Id$".
113//
Fl.H
Fl static class.
Fl_Tree_Item_Array
Manages an array of Fl_Tree_Item pointers.
Definition Fl_Tree_Item_Array.H:47
Fl_Tree_Item_Array::manage_item_destroy
void manage_item_destroy(int val)
Option to control if Fl_Tree_Item_Array's destructor will also destroy the Fl_Tree_Item's.
Definition Fl_Tree_Item_Array.H:100
Fl_Tree_Item_Array::total
int total() const
Return the total items in the array, or 0 if empty.
Definition Fl_Tree_Item_Array.H:72
Fl_Tree_Item_Array::operator[]
Fl_Tree_Item * operator[](int i)
Return the item and index i.
Definition Fl_Tree_Item_Array.H:64
Fl_Tree_Item_Array::operator[]
const Fl_Tree_Item * operator[](int i) const
Const version of operator[](int i)
Definition Fl_Tree_Item_Array.H:68
Fl_Tree_Item
Tree widget item.
Definition Fl_Tree_Item.H:67