Fabio Bracci wrote:

> The problem I am facing now is that I have generated with fluid a window with 
> a scroll with a group; the group is the one holding the complex widget 
> structure.
> In my case I should wrap the group's draw() call with the offscreen code ... 
> but I can't!
> /usr/include/FL/Fl_Group.H:56: error: �virtual void Fl_Group::draw()� is 
> protected
> Is there a way to trigger the draw() method of a group from the outside?
> The alternative would be again deriving Fl_Group to customize draw(), but 
> fluid doesn't know anything about my custom widgets, so I will not be able to 
> use a Group with offscreen code from fluid.
> 
> In short: how is it possible to trigger the protected draw() of the inner 
> Group without dismantling the complex widget (built with fluid)?

First: I just wanted to suggest that we should change all draw methods 
to be public instead of protected, but I did not yet do it. This is just 
for such problems that you encountered here. IMHO, there's no reason to 
protect the draw methods, because draw() is virtual anyway.

Short term solution for your problem: a simple cast of the pointer 
solves your problem, e.g.:

Fl_Widget *wi = (Fl_Widget *)my_group; // cast to base class
wi->draw(); // this calls Fl_Group::draw() :-)

Maybe you can also use a "short" form without an intermediate variable, 
but this is less intuitive code:

((Fl_Widget *)my_group)->draw(); // untested, but should work (?)

Another (tested) possibility. Define this somewhere in your code:

static inline void draw_sub(Fl_Widget *W) { W->draw(); }

Then you can write:

draw_sub(my_group); // calls virtual draw() method of my_group.

Albrecht

P.S. I filed STR # 2142, see http://www.fltk.org/str.php?L2142
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to