Stan wrote:
> Where's the missing end() ?

        Your end() in the ctor of DateInput ends the group,
        but not the outer Fl_Window defined in main().

        So the 'missing end()' is the one called in main().

        By calling current(0) in DateInput's ctor, you're effectively
        end()ing the Fl_Window within your ctor, which has global
        ramifications. So watch out: if you do that, you'll run into
        trouble when you try to add new widgets to the Fl_Window
        in main() after your call to new DateInput(..); the Window
        is no longer current, and the end() in main() will be ineffective.

        To prevent that problem, at very least leave the window
        hierarchy intact by calling current(parent()); after creating
        the Calendar the way you have it.

        Conceptually, though, I wouldn't think of Calendar as being
        'inside' the DateInput.. it's a separate window.

        One way to change the program that I think is possibly more
        in keeping with the widget hierarchy concept would be to
        define Calendar in main(), and then pass its pointer to the
        DateInput class, eg:

main()
{
     // Main window and components
     w = new Fl_Window()
        d = new DateInput();
     w->end();

     // Popup features
     cal = new Calendar();      // create calendar here
     d->SetCalendar(c);         // attach it to the DateInput class here
     ..
}

        This way you're declaring Calendar outside the Fl_Window hierarchy,
        reflecting that it's 'separate', from a widget point of view.

        In this case DateInput::SetCalendar() can either affect only
        the single instance of DateInput(), or all instances, depending
        on if you implement the internal pointer as a static or not.

        This way the one Calendar instance can be assigned to other
        widgets as well, and not just DateInput.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to