On 28.10.2011 01:42, Jim Jozwiak wrote:

> Albrecht, now that you have explained the internals, perhaps I could use
> absolute positioning within the FL_Groups as dictated by the ratios with
> FL_NORMAL_SIZE and use no FL_Packs. Then at execution time, when I see
> what font size the user wants,

Oh, now I seem to understand! You wanted to resize the application to
use different font sizes. That was not clear to me.

> I could set FL_NORMAL_SIZE to the user's
> font size, and resize the whole application proportionally. Would this
> be in accord with fltk design principles?

Yes, I think so (if I understood what you mean in all details). However,
simply setting FL_NORMAL_SIZE to a different value wouldn't change font
sizes of existing widgets. You would have to set the font sizes of each
widget accordingly, or you must delete all widgets and create them
again after setting FL_NORMAL_SIZE.

One way to do this easily (for some value of easy) is to derive your
own widgets and override the resize() method similar to this:

MyButton::resize(int x, int y, int w, int h) {
   labelsize(FL_NORMAL_SIZE);
   Fl_Button::resize(x,y,w,h);
}

Note that this is untested, and that other widgets also use textsize()
methods or something like that.

Proportional resizing of the whole application could be done by only
resizing the window, since all widgets inside would be resized and
positioned accordingly... Finally, this can be done by the user by
resizing the window manually - and if you override the window's
resize() method, you can calculate an appropriate font size, set it
in a global variable (maybe FL_NORMAL_SIZE, as you suggested), and
go ahead:

MyWindow::resize(int x, int y, int w, int h) {
   // calculate font size, depending on w and h
   FL_NORMAL_SIZE = calculated_size;
   Fl_Window::resize(x,y,w,h); // resize the window and all widgets
}


Well, I don't dream and tell you something here. All this is done in
a similar way in one of my FLTK applications. Font sizes are adjusted
dynamically according to the window's size, and the user can resize
the window by dragging the window borders as usual, enlarging the
fonts as needed...

But of course you can also use a configuration dialog and resize the
window according to the user's font size. YMMV.

Albrecht
_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to