On 11.02.2009, at 12:22, Fabio Bracci wrote:

>>> a) why is draw() a protected method?
>>
>> I can't tell you, why it is protected, IMHO this is not necessary  
>> or useful.
>
> ..weird!
>

::draw() is protected because we kept getting complaints that "draw()"  
is not working as expected. The event-driven nature of GUIs is new to  
many developers, and some assume that they can call draw() whenever  
they want something appear on the screen. We had to explain redraw()  
vs. draw() at least once a week.

After making draw() protected, we rarerly get this question. Seein  
that draw() is protected, users start reading the docs to find out why  
that is, and usually find redraw() pretty quickly.

Fl_Widget::draw() obviously must be public, or Fl_Group could not  
redraw its children. There is no harm in that whatsoever because  
draw() is virtual, so the correct implementation will be called.  
((Fl_Widget*)w)->draw() in that respect I would not consider a hack,  
but a useful stumble stone - plus it does the Right Thing anyway.

Or in short: please do *not* make draw() public.

  Matthias

----
http://robowerk.com/


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

Reply via email to