I'm moving a chunk of the "Subject: Re: Styles" thread
        over here from fltk.general that seemed more relevant
        to fltk.development, to prevent dev chatter on the general group.

        "mal content" was trying to get Styles working, and I thought I'd
        give it a shot just to start to learn about 2.x by dabbling.

        Styles doesn't have any example code that I could find, so after
        some help from Mikko, we cobbled together a working example that
        shows how to change the default fonts/colors for windows and buttons.

        The example is shown in Mikko's 04/01/07 06:39 posting in the
        "Re: Styles" thread on fltk.general, which makes use of the
        (WidgetType)::default_style

        Some things that seemed odd, though. To set the NamedStyle's
        parent_ seemed to involve:

---- snip
int main(..) {
     // Set correct parents for styles
     G_window_style.parent_ = Window::default_style;   // <--
     G_button_style.parent_ = Button::default_style;   // <--
---- snip

        Seems a little scary to be doing direct variable assignments
        to variables (esp. with underbars). Shouldn't there instead
        be something like a .parent() or .setparent() method?

        Looking to the code to see if it might have just been undocumented,
        I noticed /all/ the variables in Style are in fact public, with
        the comment:
        // Everything is public for various back-compatability hacks
        I figured with Style and FLTK2 being fairly new, there wouldn't
        already be legacy to worry about.. shouldn't that all be private?

        Also, seems like it would be handy if maybe the NamedStyle
        constructor could include a way to set the parent on init, eg:

---- snip
int main() {
     NamedStyle window_style("MyWindowStyle", Window::default_style);
---- snip

        ..or is there a reason something like that would be bad?

        Finally, is there a way to use styles to affect *all* widget
        defaults? ie. if you want to change the default font for all
        widgets? It seems as if one might have to make one style instance
        for each kind of widget an app uses?

        I know Styles are new, maybe I'm 'too soon' to use them,
        or more likely, I'm probably missing something by not
        knowing where to find good example code.
_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to