DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2409
Version: 1.3-feature
Link: http://www.fltk.org/str.php?L2409
Version: 1.3-feature
Index: src/Fl_Group.cxx
===================================================================
--- src/Fl_Group.cxx (revision 7680)
+++ src/Fl_Group.cxx (working copy)
@@ -391,14 +391,14 @@
while (children_) {
Fl_Widget* o = child(0); // *first* child widget
if (o->parent() == this) { // should always be true
- remove(o); // remove child widget first
+ remove(0); // remove child widget first
delete o; // then delete it
} else { // this should never happen !
#ifdef DEBUG_CLEAR
printf ("Fl_Group::clear() widget:%p, parent: %p != this (%p)\n",
o, o->parent(), this); fflush(stdout);
#endif // DEBUG_CLEAR
- remove(o); // remove it
+ remove(0); // remove it
}
}
}
@@ -463,17 +463,14 @@
void Fl_Group::add(Fl_Widget &o) {insert(o, children_);}
/**
- Removes a widget from the group but does not delete it.
+ Removes the widget at \p index from the group but does not delete it.
- This method does nothing if the widget is not a child of the group.
-
This method differs from the clear() method in that it only affects
a single widget and does not delete it from memory.
*/
-void Fl_Group::remove(Fl_Widget &o) {
- if (!children_) return;
- int i = find(o);
- if (i >= children_) return;
+void Fl_Group::remove(int index) {
+ if (index >= children_) return;
+ Fl_Widget &o = *array_[index];
if (&o == savedfocus_) savedfocus_ = 0;
if (o.parent_ == this) { // this should always be true
o.parent_ = 0;
@@ -489,15 +486,29 @@
children_--;
if (children_ == 1) { // go from 2 to 1 child
- Fl_Widget *t = array_[!i];
+ Fl_Widget *t = array_[!index];
free((void*)array_);
array_ = (Fl_Widget**)t;
} else if (children_ > 1) { // delete from array
- for (; i < children_; i++) array_[i] = array_[i+1];
+ for (; index < children_; index++) array_[index] = array_[index+1];
}
init_sizes();
}
+/**
+ Removes a widget from the group but does not delete it.
+
+ This method does nothing if the widget is not a child of the group.
+
+ This method differs from the clear() method in that it only affects
+ a single widget and does not delete it from memory.
+*/
+void Fl_Group::remove(Fl_Widget &o) {
+ if (!children_) return;
+ int i = find(o);
+ if ( i < children_ ) remove(i);
+}
+
////////////////////////////////////////////////////////////////
// Rather lame kludge here, I need to detect windows and ignore the
Index: FL/Fl_Group.H
===================================================================
--- FL/Fl_Group.H (revision 7680)
+++ FL/Fl_Group.H (working copy)
@@ -106,6 +106,7 @@
widget if \p before is not in the group.
*/
void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));}
+ void remove(int index);
void remove(Fl_Widget&);
/**
Removes the widget \p o from the group.
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs