The draw and handle methods really should be protected so they can be 
reused by subclasses.

They are public in the base class so that a lot of internal fltk code 
does not have to be made a "friend" of Widget. This pretty much means 
there is no reason not to make them public in subclasses as well.

They certainly should not be private.

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.

On 05/02/2012 06:09 AM, MacArthur, Ian (SELEX GALILEO, UK) wrote:
> All,
>
> I've shifted this out of the STR and into the group so that brains smarter 
> than mine can join in and say what's what...
>
>
>> Link: http://www.fltk.org/str.php?L2834
>> Version: 1.3-feature
>>
>>
>> @Ian,
>>
>> I don't think calling ((Fl_Widget *)this)->draw() will work
>> in my Fl_Help_View subclass's draw() method (it will recurs)
>> - or am I misunderstanding you?
>>
>> I tried calling ((Fl_Group *)this)->draw() but this doesn't work also.
>
>
> OK, here's what I thought was going on...
>
> You have a derived widget, derived from Fl_Help_View, and in your derived 
> draw method you wanted to call the base class by doing:
>
>       Fl_Help_View::draw();
>
> But for whatever reason (scope I imagine) that's not allowed.
>
> So I wondered if we can trigger the base class by indirection via the 
> (public, virtual) draw method of Fl_Widget.
>
> But you indicate that this will nto work...
>
> Anybody care to pitch in here?
>
>
>>
>> The same with handle(), I believe..
>>
>> @Albrecht
>> Looking at other widgets I guess FLTK's design deliberately not intended
>> a subclass to use the draw() method of it's inherited class, which is
>> okay for simple widgtes as you have draw_box() and draw_label() that
>> can be used.
>>
>> Nevertheless I think it might be usefull for extending widgets to have
>> a protected (you are right about not needing public) access to draw().
>>
>> Or am I missing something - how else could one extend the inherited
>> draw() without duplicating the whole drawing code (which is huge in
>> case of Fl_Help_View) or using some dirty tricks?
>
>
>
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
> 3EL
> A company registered in England&  Wales.  Company no. 02426132
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>

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

Reply via email to