On 14.04.2012 21:29, Domingo Alvarez Duarte wrote:
> 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.

If we only could take a look at the code...

> 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) {}
>
> }

This looks okay, as discussed with Edzard. I also believe that
these methods should be in Fl_Widget and virtual.

> struct st_widget_sizes {
> int x,y,w,h;
> Fl_Fontsize labelsize, textsize;
> };

Good point. The sizes() array should really be a struct (or class),
but this would also break ABI *and* API (and hence probably existing
code, although the sizes() array is not officially documented).

<nitpicking>
Also, the members should have better names, since "w" and "h"
are not used as width and height here, but as right and bottom
positions, so they could be called r and b, for instance.
</nitpicking>

> 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)];

... the following posted code is difficult to read. Is this only the
"translation" to the new struct plus addition of labelsize and
textsize? (Code removed)

> 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;

Aren't you missing to adjust for the first two members of the
sizes array above? Should probably read:

st_widget_sizes *tmp = p+i+2; // add "+2" here

> wdg->labelsize( tmp->labelsize * font_scale);
> if (tmp->textsize)
> wdg->textsize( tmp->textsize * font_scale);
> }
> }
> }

Instead of using "if (wdg->as_group())" this could be solved
(better?) by making the method virtual.

However, your code doesn't show how resizefont() is used, and
Fl_Group::resize() and maybe more code must be changed if
Fl_Group::sizes() were changed.


Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to