|
|
This came up on fltk.general:
On 10/16/22 10:01, lifeatt...@gmail.com wrote:
I
have searched for a while for this but haven't come up with an
answer. (I'm guessing it's obvious).
Fltk has defaults for eg. Colour, Font Size etc and I
would like to set my own so I don't have to code them on
each individual widget. Can someone tell me how to do this.
Thank you for asking this question. I don't feel it was
"obvious" : I've been using FLTK for some time now, could have
used the answer, and didn't know it!
Perhaps some well named wrapper methods could make this
easier to find/more intuitive, as I think few would expect
UPPER_CASE
values to be settable globals. We can hide these historical
warts
by adding improved methods, like:
Fl_Fontsize Fl::default_fontsize()
const { return FL_NORMAL_SIZE; }
void Fl::default_fontsize(Fl_Fontsize
val) { FL_NORMAL_SIZE = val; }
Fl_Color
Fl::default_background_color() const { return
FL_BACKGROUND_COLOR; }
void
Fl::default_background_color(Fl_Color val) {
FL_BACKGROUND_COLOR = val; }
..etc..
Perhaps we can also pivot away from setting FL_HELVETICA to
change
"the default font" (because that's a really bad way to do it)
by creating a NEW variable FL_DEFAULT_FONT:
Fl_Font FL_DEFAULT_FONT = -1; // default uses FL_HELVETICA
..and then in the Fl_Widget ctor, make this change:
Fl_Widget::Fl_Widget(int X, int Y, int W, int H, const char* L)
{
[..]
label_.value = L;
label_.image = 0;
label_.deimage = 0;
label_.type = FL_NORMAL_LABEL;
- label_.font = FL_HELVETICA;
+ label_.font =
(FL_DEFAULT_FONT != -1) ? FL_DEFAULT_FONT : FL_HELVETICA;
label_.size = FL_NORMAL_SIZE;
This way old apps that set FL_HELVETICA would work as it does
now,
but if the app uses "the new way" by setting Fl::default_font(),
a new wrapper around FL_DEFAULT_FONT, then it would take
precedence.
Anyway, things like this could clean up some bad API warts
and make it easier for new users to search the docs for how to
change
the defaults.
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/4397c0e5-22ea-dad4-fc6f-5e7cd05f4a6a%40seriss.com.
[ Direct Link to Message ] | |
|
| |