Interesting but on my demo of tabs it shows a bug that I don't know yet
where it is: the second button next to the clock do not resize font
properly, all others do.
Main changes for my solution that my example shows it's flaws.
class Fl_Widget {
...
virtual Fl_Font textfont() const {return labelfont();}
virtual void textfont(Fl_Font s) {}
virtual Fl_Fontsize textsize() const {return labelsize();}
virtual void textsize(Fl_Fontsize s) {}
}
struct st_widget_sizes {
int x,y,w,h;
Fl_Fontsize labelsize, textsize;
};
st_widget_sizes* Fl_Group::sizes() {
if (!sizes_) {
//int* p = sizes_ = new int[4*(children_+2)];
st_widget_sizes* p = sizes_ = new st_widget_sizes[(children_+2)];
// first thing in sizes array is the group's size:
if (type() < FL_WINDOW) {p->x = x(); p->y = y();} else {p->x = p->y =
0;}
p->w = p->x+w(); p->h = p->y+h();
p->labelsize = labelsize();
p->textsize = textsize();
// next is the resizable's size:
++p;
p->x = sizes_->x; // init to the group's size
p->w = sizes_->w;
p->y = sizes_->y;
p->h = sizes_->h;
p->labelsize = sizes_->labelsize;
p->textsize = sizes_->textsize;
Fl_Widget* r = resizable();
if (r && r != this) { // then clip the resizable to it
int t;
t = r->x(); if (t > sizes_->x) p->x = t;
t +=r->w(); if (t < sizes_->w) p->w = t;
t = r->y(); if (t > sizes_->y) p->y = t;
t +=r->h(); if (t < sizes_->h) p->h = t;
p->labelsize = r->labelsize();
p->textsize = r->textsize();
}
// next is all the children's sizes:
++p;
Fl_Widget*const* a = array();
for (int i=children_; i--;) {
Fl_Widget* o = *a++;
p->x = o->x();
p->w = o->x()+o->w();
p->y = o->y();
p->h = o->y()+o->h();
p->labelsize = o->labelsize();
p->textsize = o->textsize();
++p;
}
}
return sizes_;
}
void Fl_Group::resizefont(float font_scale){
st_widget_sizes *p = sizes();
//element at 0 is self = this window
for(int i=0, iMax=children(); i < iMax; i++)
{
Fl_Widget *wdg = child(i);
if(wdg->as_group())
wdg->as_group()->resizefont(font_scale);
else
{
st_widget_sizes *tmp = p+i;
wdg->labelsize( tmp->labelsize * font_scale);
if (tmp->textsize)
wdg->textsize( tmp->textsize * font_scale);
}
}
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk