On 02.05.2012 15:09, MacArthur, Ian (SELEX GALILEO, UK) wrote:

> 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...

Let's say "... other brains ..." (not necessarily smarter, otherwise
I wouldn't know if mine qualifies) ;-)

>> 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.

It's obviously private in Fl_Help_View. :-(

> 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?

He said it already: this would recurse. Why? Calling a method
explicitly with class::method() calls exactly this class's method,
but an unqualified call always uses the virtual method, and hence
in this case that of the derived class. Example:

In Fl_Scroll::draw(): (Fl_Scroll is derived from Fl_Group):

   Fl_Group *g = this;
   g->draw();           // calls Fl_Scroll::draw() [1]
   Fl_Group::draw();    // calls Fl_Group::draw() explicitly [2]

[1] using the virtual function table
[2] because it's explicitly qualified.

We really need a protected method, and I believe this is only an
omission / accident in Fl_Help_View.

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

Reply via email to