Mikko L wrote:
> Following is bad, because you cant know if Window::default_style is
> already constructed or not.
Ahh, OK, thanks.
I wasn't sure actually what Window::default_style was..
didn't realize it was a class instance.
Guess that explains why I'd sometimes get a window with
a white background instead of gray on startup. ;)
Yes, if XXX::default_style is an instance of a class defined
in one of the FLTK modules, then it's certainly possible to
access an instance of a class before it's constructed.
(Seems the linker shouldn't let that happen, but I know it can..)
I'll use your newer approach for an example instead.
Guess I need to start making an FLTK2 cheat page..
> In fact copy ctor of NamedStyle is bad, cause it will also copy style name
> and break Style::find() function.
I see, yeah, it would copy the default style's name which I guess is
bad.
OK. I wasn't sure what the style names were actually used for.
Also, I think I was thinking that the 'backptr' argument in the ctor
was the same as initializing the "parent_", but after a review of
Style.cxx, I see it's not.
Looks like the backptr argument to the NamedStyle ctor might need
some docs. Think I'll make an STR for that.
Question: in these lines:
G_window_style.parent_ = Window::default_style;
G_button_style.parent_ = Button::default_style;
..seems a little scary to be jamming values directly into
class variables with trailing underbars from outside the class.
Is there a reason there isn't a setparent() method instead?
Also, though I'm new to this, it seems like it would make sense
if there was a constructor that let one pass the parent value
in as part of the construction. My mistake (above) in thinking
'backptr' was the way to do this I think might be a common one.
One parting comment: I see all the variables in Style are public,
with the comment:
// Everything is public for various back-compatability hacks
..which seems like a 'legacy comment', but since FLTK2 is a
complete rewrite, and Style is, I think, a totally new class,
what's it need to be "backwards compatible" with?
(Maybe I should move those last two paragraphs over to fltk.developer)
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk