You described it correctly (except I would pass the rectangle as a 
reference rather than as 4 numbers), and I think you are right that this 
would break any existing code that tries to call a base class draw(), as 
that would call the virtual draw(rect) function.

Calling Base::draw() is not useful to implement a draw(rect) function 
(as it does not pass the rect) so this is not a problem for new code.

Any chance some more kludges could be put into the fltk1 emulation so 
that this works for that? One way is that draw(void) only exists in the 
fltk1 wrapper and some trick is done so that all the implementatios call 
the actual function (ie Subclass::draw(rect) rather than just 
this->draw(rect)). There would have to be something in the fltk1 wrapper 
anyway so that draw() can be overridden by old code.

On 05/03/2012 01:41 AM, Albrecht Schlosser wrote:
> On 02.05.2012 17:50, Bill Spitzak wrote:
>
>> For FLTK 3 I would recommend a new draw and handle that take a
>> rectangle. The purpose is so a subclass can add a "frame" around the
>> contents without kludging it by adjusting the widget's boundaries. This
>> also has the advantage that you can make these protected, even in the
>> base class.
>>
>> Plain "draw()" is a public non-virtual on the base class which calls the
>> virtual draw with the widget's rectangle.
>
> Hmm, let's see if I understand this...
>
> Say we have something like
>
> virtual void draw_rect() {...}
>
> and draw() becomes
>
> void draw() { draw_rect(x(), y(), w(), h()); }
>
> But then, wouldn't calling draw() always call the virtual method, and
> thus inhibit usage like the following, as discussed here, e.g. in a
> derived class like Fl_Scroll ?
>
> Fl_Group::draw(); // would call Fl_Scroll::draw_rect() !
>
> So this would break existing code that would have to be rewritten
> to call draw_rect() directly, like this:
>
> Fl_Group::draw_rect(x(), y(), w(), h());
>
> Or did I miss (or misunderstand) something?
>
> Albrecht

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to