diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-12-17 18:59:06 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-12-17 19:00:34 +0100 |
| commit | 311d9a8ad427d0fb6c23fb8752620883e210d2b2 (patch) | |
| tree | b4838fbb234dca89fb93eab93deca92a9075b97e | |
| parent | d6ba66ca4b247584a9226fb6995f07323d1ef5bd (diff) | |
Forms compatibility: use as_window() rather than type()
... and some more improvements and minor changes.
No functionality changes.
Note: this code is used in the fltk_forms library.
| -rw-r--r-- | src/forms_compatibility.cxx | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/forms_compatibility.cxx b/src/forms_compatibility.cxx index 7700e177e..2d9ca858f 100644 --- a/src/forms_compatibility.cxx +++ b/src/forms_compatibility.cxx @@ -24,21 +24,23 @@ char fl_flip = 2; void fl_end_form() { while (Fl_Group::current()) Fl_Group::current()->forms_end(); } + void Fl_Group::forms_end() { // set the dimensions of a group to surround contents - if (children() && !w()) { + const int nc = g->children(); + if (nc && !w()) { Fl_Widget*const* a = array(); Fl_Widget* o = *a++; int rx = o->x(); int ry = o->y(); int rw = rx+o->w(); int rh = ry+o->h(); - for (int i=children_-1; i--;) { + for (int i = nc - 1; i--;) { o = *a++; if (o->x() < rx) rx = o->x(); if (o->y() < ry) ry = o->y(); - if (o->x()+o->w() > rw) rw = o->x()+o->w(); - if (o->y()+o->h() > rh) rh = o->y()+o->h(); + if (o->x() + o->w() > rw) rw = o->x() + o->w(); + if (o->y() + o->h() > rh) rh = o->y() + o->h(); } x(rx); y(ry); @@ -46,13 +48,13 @@ void Fl_Group::forms_end() { h(rh-ry); } // flip all the children's coordinate systems: - if (fl_flip) { - Fl_Widget* o = (type()>=FL_WINDOW) ? this : window(); + if (nc && fl_flip) { + Fl_Widget* o = as_window() ? this : window(); int Y = o->h(); Fl_Widget*const* a = array(); - for (int i=children(); i--;) { + for (int i = nc; i--;) { Fl_Widget* ow = *a++; - int newy = Y-ow->y()-ow->h(); + int newy = Y - ow->y() - ow->h(); ow->y(newy); } } |
