Daniel wrote:
> 
> FLTK is one of the best GUI libraries I've looked at.
> And FLTK2 continues the trend, but ...
> 
> I'm confused why child widgets are added to the parent list by
> use of a static pointer controlled by begin() / end()?
> 
> Would it not be cleaner to simply add a pointer to the parent
> widget in the child widgets constructor?  That way the 'add'
> function could be called directly with the parent widget rather
> than through a system wide static pointer.
> 
> What is the advantage of this?
> 
> -Daniel

The primary reason fltk works that way is because Forms worked that way 
(although Forms did not have nested widgets, so it was more like any 
widget was added to the last-created window).

The other reason is because VC++ produces a warning if you pass "this" 
to any function in a constructor. This makes it impossible to make a 
composite widget class without producing these warnings, that would look 
like this if the parent was an argument to the constructor:

class CompositeWidget : public fltk::Window {
   fltk::Input child_widget; // part of the compoisite widget
public:
   CompositeWidget() :
     Window(...),
     child_widget(this,...) // this line produces nasty warning message
    {}
};
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to