|
|
commit 311d9a8ad427d0fb6c23fb8752620883e210d2b2
Author: Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Fri Dec 17 18:59:06 2021 +0100
Commit: Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Fri Dec 17 19:00:34 2021 +0100
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.
src/forms_compatibility.cxx | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git src/forms_compatibility.cxx src/forms_compatibility.cxx
index 7700e17..2d9ca85 100644
--- src/forms_compatibility.cxx
+++ 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);
}
}
[ Direct Link to Message ] | |
|
| |