And here the Fl_Pack reworked to use the new funcion, it's not working
properly yet but can show the idea:
void Fl_Pack::draw() {
int tx = x()+Fl::box_dx(box());
int ty = y()+Fl::box_dy(box());
int tw = w()-Fl::box_dw(box());
int th = h()-Fl::box_dh(box());
int rw, rh;
int full_x, full_y, full_w, full_h;
int current_position = horizontal() ? tx : ty;
int maximum_position = current_position;
uchar d = damage();
Fl_Widget*const* a = array();
if (horizontal()) {
rw = -spacing_;
rh = th;
for (int i = children(); i--;)
if (child(i)->visible()) {
if (child(i) != this->resizable()) {
child(i)->get_full_size(full_x, full_y, full_w, full_h);
//rw += child(i)->w();
rw += full_w;
}
rw += spacing_;
}
} else {
rw = tw;
rh = -spacing_;
for (int i = children(); i--;)
if (child(i)->visible()) {
if (child(i) != this->resizable()) {
child(i)->get_full_size(full_x, full_y, full_w, full_h);
//rh += child(i)->h();
rh += full_h;
}
rh += spacing_;
}
}
for (int i = children(); i--;) {
Fl_Widget* o = *a++;
if (o->visible()) {
int X,Y,W,H;
o->get_full_size(full_x, full_y, full_w, full_h);
if (horizontal()) {
X = current_position;
//W = o->w();
W = full_w;
Y = ty;
H = th;
} else {
X = tx;
W = tw;
Y = current_position;
//H = o->h();
H = full_h;
}
// Last child, if resizable, takes all remaining room
if(i == 0 && o == this->resizable()) {
if(horizontal())
W = tw - rw;
else
H = th - rh;
}
if (spacing_ && current_position>maximum_position && box() &&
//(X != o->x() || Y != o->y() || d&FL_DAMAGE_ALL)) {
(X != full_x || Y != full_y || d&FL_DAMAGE_ALL)) {
fl_color(color());
if (horizontal())
fl_rectf(maximum_position, ty, spacing_, th);
else
fl_rectf(tx, maximum_position, tw, spacing_);
}
//if (X != o->x() || Y != o->y() || W != o->w() || H != o->h()) {
if (X != full_x || Y != full_y || W != full_w || H != full_h) {
o->resize(X,Y,W,H);
o->clear_damage(FL_DAMAGE_ALL);
o->get_full_size(full_x, full_y, full_w, full_h);
}
if (d&FL_DAMAGE_ALL) {
draw_child(*o);
draw_outside_label(*o);
} else update_child(*o);
// child's draw() can change it's size, so use new size:
//current_position += (horizontal() ? o->w() : o->h());
//current_position += (horizontal() ? o->w() : o->h());
current_position += (horizontal() ? full_w : full_h);
if (current_position > maximum_position)
maximum_position = current_position;
current_position += spacing_;
}
}
if (horizontal()) {
if (maximum_position < tx+tw && box()) {
fl_color(color());
fl_rectf(maximum_position, ty, tx+tw-maximum_position, th);
}
tw = maximum_position-tx;
} else {
if (maximum_position < ty+th && box()) {
fl_color(color());
fl_rectf(tx, maximum_position, tw, ty+th-maximum_position);
}
th = maximum_position-ty;
}
tw += Fl::box_dw(box()); if (tw <= 0) tw = 1;
th += Fl::box_dh(box()); if (th <= 0) th = 1;
if (tw != w() || th != h()) {
Fl_Widget::resize(x(),y(),tw,th);
d = FL_DAMAGE_ALL;
}
if (d&FL_DAMAGE_ALL) {
draw_box();
draw_label();
}
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev