summaryrefslogtreecommitdiff
path: root/src/Fl_Tree_Item_Array.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Tree_Item_Array.cxx')
-rw-r--r--src/Fl_Tree_Item_Array.cxx31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/Fl_Tree_Item_Array.cxx b/src/Fl_Tree_Item_Array.cxx
index dca358288..9186baff9 100644
--- a/src/Fl_Tree_Item_Array.cxx
+++ b/src/Fl_Tree_Item_Array.cxx
@@ -50,7 +50,8 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) {
_size = o->_size;
_chunksize = o->_chunksize;
_flags = o->_flags;
- for ( int t=0; t<o->_total; t++ ) {
+ int t;
+ for (t =0; t<o->_total; t++ ) {
if ( _flags & MANAGE_ITEM ) {
_items[t] = new Fl_Tree_Item(o->_items[t]); // make new copy of item
++_total;
@@ -69,7 +70,8 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) {
///
void Fl_Tree_Item_Array::clear() {
if ( _items ) {
- for ( int t=0; t<_total; t++ ) {
+ int t;
+ for (t =0; t<_total; t++ ) {
if ( _flags & MANAGE_ITEM )
{
delete _items[t];
@@ -169,7 +171,8 @@ void Fl_Tree_Item_Array::remove(int index) {
}
_items[index] = 0;
_total--;
- for ( int i=index; i<_total; i++ ) { // reshuffle the array
+ int i;
+ for (i =index; i<_total; i++ ) { // reshuffle the array
_items[i] = _items[i+1];
}
if ( _flags & MANAGE_ITEM )
@@ -188,7 +191,8 @@ void Fl_Tree_Item_Array::remove(int index) {
/// \returns 0 if removed, or -1 if the item was not in the array.
///
int Fl_Tree_Item_Array::remove(Fl_Tree_Item *item) {
- for ( int t=0; t<_total; t++ ) {
+ int t;
+ for (t =0; t<_total; t++ ) {
if ( item == _items[t] ) {
remove(t);
return(0);
@@ -223,16 +227,19 @@ int Fl_Tree_Item_Array::move(int to, int from) {
if ( to<0 || to>=_total || from<0 || from>=_total ) return -1;
Fl_Tree_Item *item = _items[from];
// Remove item..
- if ( from < to )
- for ( int t=from; t<to && t<(_total+1); t++ )
+ int t;
+ if ( from < to ) {
+ for (t =from; t<to && t<(_total+1); t++ )
_items[t] = _items[t+1];
- else
- for ( int t=from; t>to && t>0; t-- )
+ } else {
+ for (t =from; t>to && t>0; t-- )
_items[t] = _items[t-1];
+ }
// Move to new position
_items[to] = item;
// Update all children
- for ( int r=0; r<_total; r++ ) // XXX: excessive to do all children,
+ int r;
+ for (r =0; r<_total; r++ ) // XXX: excessive to do all children,
_items[r]->update_prev_next(r); // XXX: but avoids weird boundary issues
return 0;
}
@@ -252,7 +259,8 @@ int Fl_Tree_Item_Array::deparent(int pos) {
Fl_Tree_Item *next = item->next_sibling();
// Remove from parent's list of children
_total -= 1;
- for ( int t=pos; t<_total; t++ )
+ int t;
+ for (t =pos; t<_total; t++ )
_items[t] = _items[t+1]; // delete, no destroy
// Now an orphan: remove association with old parent and siblings
item->update_prev_next(-1); // become an orphan
@@ -272,7 +280,8 @@ int Fl_Tree_Item_Array::reparent(Fl_Tree_Item *item, Fl_Tree_Item* newparent, in
// Add item to new parent
enlarge(1);
_total += 1;
- for ( int t=_total-1; t>pos; --t ) // shuffle array to make room for new entry
+ int t;
+ for (t =_total-1; t>pos; --t ) // shuffle array to make room for new entry
_items[t] = _items[t-1];
_items[pos] = item; // insert new entry
// Attach to new parent and siblings