> For one, one of the improvents mentioned before were to be
> able to set the application level font/size (can be
> done)/etc.. otherwise using the default. But I really don't
> need to know any of that. I just want to know how big this
> text will be so I can build the controls the proper size in
> the proper place. If I had a special font/size I'd be using,
> I could pass it on, otherwise I leave it NULL or 0 and it
> determines the font/size used by a widget (it's before creating it).
But measure what?
Until you say which face and which size you want to use, there is
*nothing* to measure.
There is, strictly speaking, no concept of a default font in fltk -
though many widgets do opt for FL_HELVETICA/FL_NORMAL_SIZE, it's not a
strict default per se, so you *need* to set enough context for the
measure methods to work with.
They have no concept of a default widget or anything, so you need to
give them enough context with which to work.
If you want, you can probably just set the font to FL_HELVETICA and the
size to FL_NORMAL_SIZE just before you call fl_measure() or
fl_text_extents() and that'll probably be "right" most of the time
anyway...
> Also, I find that "measure_label" doesn't work right unless
> you set the ww and hh to zero before calling, it doesn't seem
> to initialize variables but add to them or something? That's
> unexpected for sure.
I think that's expected though?
Certainly it is the documented behaviour for fl_measure(), which I
believe measure_label() uses internally... Hmm, no you are right, the
Fl_Widget:: measure_label() docs do not say that, though I imagine that
they should. That sounds like a docs bug I'd hazard...
> So right now you have to create the widget with text, then
> measure it (besure to init ww and hh first), then resize /
> position / or size it to it's final location. Instead of,
> measuring the text, creating the widget (this is mainly for
> static text controls - fl_box - text being placed on the window).
No you don't - I mean, you can if you want, but it's not what I do.
Before you create the widgets, just call:
fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
(note that you can call fl_font(), fl_measure() et al even when you are
not in a rendering context if you want to, so you don't need to be in a
draw method or anything to do this... If you are creating a bunch of
widgets, one call to fl_font() should suffice to set the context, and
then you are good to go.)
Then call:
fl_text_extents(txt, dx, dy, wo, ho);
And then you know exactly how big that face/size combination would be
rendered, and you can use that to size your widget.
If you want to enforce fltk-symbol-expansion, or wrapping to a width
limit, use fl_measure() instead, and either ensure the w,h are preset to
zero, or that w is preset to the max width you will allow (to enforce
wrapping.)
To me, that sounds like exactly what you are asking for, so I'm
struggling to understand why it's not what you want?
SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14
3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev