summaryrefslogtreecommitdiff
path: root/src/Fl_Group.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Group.cxx')
-rw-r--r--src/Fl_Group.cxx159
1 files changed, 76 insertions, 83 deletions
diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx
index 2ec83d493..4a614e1e4 100644
--- a/src/Fl_Group.cxx
+++ b/src/Fl_Group.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Group widget for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2020 by Bill Spitzak and others.
@@ -11,9 +9,9 @@
//
// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// https://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
// The Fl_Group is the only defined container type in FLTK.
@@ -36,8 +34,8 @@ Fl_Group* Fl_Group::current_;
/**
Returns a pointer to the array of children.
- \note This pointer is only valid until the next time a child
- is added or removed.
+ \note This pointer is only valid until the next time a child
+ is added or removed.
*/
Fl_Widget*const* Fl_Group::array() const {
return children_ <= 1 ? (Fl_Widget**)(&array_) : array_;
@@ -177,12 +175,12 @@ int Fl_Group::handle(int event) {
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && Fl::event_inside(o) && send(o,FL_SHORTCUT))
- return 1;
+ return 1;
}
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && !Fl::event_inside(o) && send(o,FL_SHORTCUT))
- return 1;
+ return 1;
}
if ((Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter)) return navigation(FL_Down);
return 0;
@@ -192,12 +190,12 @@ int Fl_Group::handle(int event) {
for (i = children(); i--;) {
o = a[i];
if (o->visible() && Fl::event_inside(o)) {
- if (o->contains(Fl::belowmouse())) {
- return send(o,FL_MOVE);
- } else {
- Fl::belowmouse(o);
- if (send(o,FL_ENTER)) return 1;
- }
+ if (o->contains(Fl::belowmouse())) {
+ return send(o,FL_MOVE);
+ } else {
+ Fl::belowmouse(o);
+ if (send(o,FL_ENTER)) return 1;
+ }
}
}
Fl::belowmouse(this);
@@ -208,12 +206,12 @@ int Fl_Group::handle(int event) {
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && Fl::event_inside(o)) {
- if (o->contains(Fl::belowmouse())) {
- return send(o,FL_DND_DRAG);
- } else if (send(o,FL_DND_ENTER)) {
- if (!o->contains(Fl::belowmouse())) Fl::belowmouse(o);
- return 1;
- }
+ if (o->contains(Fl::belowmouse())) {
+ return send(o,FL_DND_DRAG);
+ } else if (send(o,FL_DND_ENTER)) {
+ if (!o->contains(Fl::belowmouse())) Fl::belowmouse(o);
+ return 1;
+ }
}
}
Fl::belowmouse(this);
@@ -223,11 +221,11 @@ int Fl_Group::handle(int event) {
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && Fl::event_inside(o)) {
- Fl_Widget_Tracker wp(o);
- if (send(o,FL_PUSH)) {
- if (Fl::pushed() && wp.exists() && !o->contains(Fl::pushed())) Fl::pushed(o);
- return 1;
- }
+ Fl_Widget_Tracker wp(o);
+ if (send(o,FL_PUSH)) {
+ if (Fl::pushed() && wp.exists() && !o->contains(Fl::pushed())) Fl::pushed(o);
+ return 1;
+ }
}
}
return 0;
@@ -239,10 +237,10 @@ int Fl_Group::handle(int event) {
else if (o) send(o,event);
else {
for (i = children(); i--;) {
- o = a[i];
- if (o->takesevents() && Fl::event_inside(o)) {
- if (send(o,event)) return 1;
- }
+ o = a[i];
+ if (o->takesevents() && Fl::event_inside(o)) {
+ if (send(o,event)) return 1;
+ }
}
}
return 0;
@@ -251,12 +249,12 @@ int Fl_Group::handle(int event) {
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && Fl::event_inside(o) && send(o,FL_MOUSEWHEEL))
- return 1;
+ return 1;
}
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && !Fl::event_inside(o) && send(o,FL_MOUSEWHEEL))
- return 1;
+ return 1;
}
return 0;
@@ -274,10 +272,10 @@ int Fl_Group::handle(int event) {
o = *a++;
if (event == FL_HIDE && o == Fl::focus()) {
// Give up input focus...
- int old_event = Fl::e_number;
+ int old_event = Fl::e_number;
o->handle(Fl::e_number = FL_UNFOCUS);
- Fl::e_number = old_event;
- Fl::focus(0);
+ Fl::e_number = old_event;
+ Fl::focus(0);
}
if (o->visible()) o->handle(event);
}
@@ -329,16 +327,16 @@ int Fl_Group::navigation(int key) {
case FL_Down:
i++;
if (i >= children_) {
- if (parent()) return 0;
- i = 0;
+ if (parent()) return 0;
+ i = 0;
}
break;
case FL_Left:
case FL_Up:
if (i) i--;
else {
- if (parent()) return 0;
- i = children_-1;
+ if (parent()) return 0;
+ i = children_-1;
}
break;
default:
@@ -351,7 +349,7 @@ int Fl_Group::navigation(int key) {
case FL_Up:
// for up/down, the widgets have to overlap horizontally:
if (o->x() >= previous->x()+previous->w() ||
- o->x()+o->w() <= previous->x()) continue;
+ o->x()+o->w() <= previous->x()) continue;
}
if (o->take_focus()) return 1;
}
@@ -396,9 +394,9 @@ void Fl_Group::clear() {
// the group's children. Otherwise fl_fix_focus() would send lots
// of events to children that are about to be deleted anyway.
- Fl_Widget *pushed = Fl::pushed(); // save pushed() widget
- if (contains(pushed)) pushed = this; // set it to be the group, if it's a child
- Fl::pushed(this); // for fl_fix_focus etc.
+ Fl_Widget *pushed = Fl::pushed(); // save pushed() widget
+ if (contains(pushed)) pushed = this; // set it to be the group, if it's a child
+ Fl::pushed(this); // for fl_fix_focus etc.
// okay, now it is safe to destroy the children:
@@ -417,19 +415,19 @@ void Fl_Group::clear() {
}
#endif // REVERSE_CHILDREN
- while (children_) { // delete all children
- int idx = children_-1; // last child's index
- Fl_Widget* w = child(idx); // last child widget
- if (w->parent()==this) { // should always be true
- if (children_>2) { // optimized removal
- w->parent_ = 0; // reset child's parent
- children_--; // update counter
- } else { // slow removal
+ while (children_) { // delete all children
+ int idx = children_-1; // last child's index
+ Fl_Widget* w = child(idx); // last child widget
+ if (w->parent()==this) { // should always be true
+ if (children_>2) { // optimized removal
+ w->parent_ = 0; // reset child's parent
+ children_--; // update counter
+ } else { // slow removal
remove(idx);
}
- delete w; // delete the child
- } else { // should never happen
- remove(idx); // remove it anyway
+ delete w; // delete the child
+ } else { // should never happen
+ remove(idx); // remove it anyway
}
}
@@ -484,7 +482,7 @@ void Fl_Group::insert(Fl_Widget &o, int index) {
} else {
if (!(children_ & (children_-1))) // double number of children
array_ = (Fl_Widget**)realloc((void*)array_,
- 2*children_*sizeof(Fl_Widget*));
+ 2*children_*sizeof(Fl_Widget*));
int j; for (j = children_; j > index; j--) array_[j] = array_[j-1];
array_[j] = &o;
}
@@ -512,7 +510,7 @@ void Fl_Group::remove(int index) {
if (index < 0 || index >= children_) return;
Fl_Widget &o = *child(index);
if (&o == savedfocus_) savedfocus_ = 0;
- if (o.parent_ == this) { // this should always be true
+ if (o.parent_ == this) { // this should always be true
o.parent_ = 0;
}
@@ -560,8 +558,8 @@ void Fl_Group::remove(Fl_Widget &o) {
If you add or remove widgets, this will be done automatically.
\note The internal array of widget sizes and positions will be allocated
- and filled when the next resize() occurs. For more information on
- the contents and structure of the bounds() array see bounds().
+ and filled when the next resize() occurs. For more information on
+ the contents and structure of the bounds() array see bounds().
\see bounds()
\see sizes() (deprecated)
@@ -569,8 +567,8 @@ void Fl_Group::remove(Fl_Widget &o) {
void Fl_Group::init_sizes() {
delete[] bounds_;
bounds_ = 0;
- delete[] sizes_; // FLTK 1.3 compatibility
- sizes_ = 0; // FLTK 1.3 compatibility
+ delete[] sizes_; // FLTK 1.3 compatibility
+ sizes_ = 0; // FLTK 1.3 compatibility
}
/**
@@ -592,19 +590,19 @@ void Fl_Group::init_sizes() {
the x() and y() coordinates of their respective Fl_Rect's are zero.
\note You should never need to use this \e protected method directly,
- unless you have special needs to rearrange the children of a
- Fl_Group. Fl_Tile uses this to rearrange its widget positions.
- The returned array should be considered read-only. Do not change
- its contents. If you need to rearrange children in a group, do
- so by resizing the children and call init_sizes().
+ unless you have special needs to rearrange the children of a
+ Fl_Group. Fl_Tile uses this to rearrange its widget positions.
+ The returned array should be considered read-only. Do not change
+ its contents. If you need to rearrange children in a group, do
+ so by resizing the children and call init_sizes().
\#include \<FL/Fl_Rect.H\> if you want to access the bounds() array in
your derived class. Fl_Rect.H is intentionally not included by
Fl_Group.H to avoid unnecessary dependencies.
\returns Array of Fl_Rect's with widget positions and sizes. The
- returned array is only valid until init_sizes() is called
- or widgets are added to or removed from the group.
+ returned array is only valid until init_sizes() is called
+ or widgets are added to or removed from the group.
\see init_sizes()
@@ -662,14 +660,14 @@ Fl_Rect* Fl_Group::bounds() {
\note This method will be removed in a future FLTK version (1.5.0 or higher).
- \returns Array of int's with widget positions and sizes. The returned
- array is only valid until init_sizes() is called or widgets
- are added to or removed from the group.
+ \returns Array of int's with widget positions and sizes. The returned
+ array is only valid until init_sizes() is called or widgets
+ are added to or removed from the group.
- \note Since FLTK 1.4.0 the returned array is a \b read-only and re-ordered
- copy of the internal bounds() array. Do not change its contents.
- If you need to rearrange children in a group, do so by resizing
- the children and call init_sizes().
+ \note Since FLTK 1.4.0 the returned array is a \b read-only and re-ordered
+ copy of the internal bounds() array. Do not change its contents.
+ If you need to rearrange children in a group, do so by resizing
+ the children and call init_sizes().
\see bounds()
*/
@@ -715,8 +713,8 @@ void Fl_Group::resize(int X, int Y, int W, int H) {
if (!as_window()) {
Fl_Widget*const* a = array();
for (int i=children_; i--;) {
- Fl_Widget* o = *a++;
- o->resize(o->x() + dx, o->y() + dy, o->w(), o->h());
+ Fl_Widget* o = *a++;
+ o->resize(o->x() + dx, o->y() + dy, o->w(), o->h());
}
}
@@ -799,8 +797,8 @@ void Fl_Group::draw_children() {
if (clip_children()) {
fl_push_clip(x() + Fl::box_dx(box()),
y() + Fl::box_dy(box()),
- w() - Fl::box_dw(box()),
- h() - Fl::box_dh(box()));
+ w() - Fl::box_dw(box()),
+ h() - Fl::box_dh(box()));
}
if (damage() & ~FL_DAMAGE_CHILD) { // redraw the entire thing:
@@ -809,7 +807,7 @@ void Fl_Group::draw_children() {
draw_child(o);
draw_outside_label(o);
}
- } else { // only redraw the children that need it:
+ } else { // only redraw the children that need it:
for (int i=children_; i--;) update_child(**a++);
}
@@ -911,8 +909,3 @@ void Fl_Group::draw_outside_label(const Fl_Widget& widget) const {
}
widget.draw_label(X,Y,W,H,(Fl_Align)a);
}
-
-
-//
-// End of "$Id$".
-//