On 6 Feb 2009, at 17:44, Fabio Bracci wrote:

> Indeed what I am aiming for is to print/screen capture/etc a whole  
> widgets hierarchy contained in a Fl_Scroll (so a Fl_Group); I  
> already was thinking about providing a draw() function to a derived  
> class and enclose the Fl_Scroll::draw() with the offscreen  
> operations, thanx for the example!
>
> 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.

Yes, that was what I had inferred from your previous comments, so  
that was what I tried to illustrate in my example. Was I right?

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

This is exactly what I would do, though. It is very easy to make a  
derived version of Fl_Group (as per my example) and then tell fluid  
to use that class for the container group.

All you have to do is:

- Construct your widget hierarchy in fluid as usual

- Construct your derived group, and store it in a .cxx/.h pair of  
files with the text editor of your choice (just cut 'n paste from my  
example as a starting point!)

- add a #include for the .h file to the top of the fluid tree (using  
the fluid  New->Code->Declaration menu entry)

- select the properties of your enclosing Fl_Group, go to the C++ tab  
and fill in the CLASS entry with the name of your derived class.

Thereafter, fluid will use your derived class for that widget, rather  
than a "regular" Fl_Group, thereby making access to its draw method  
for custom effects straightforward.


> In short: how is it possible to trigger the protected draw() of the  
> inner Group without dismantling the complex widget (built with fluid)?

See above.
I use this approach fairly often, and it is very straightforward,  
providing a flexible and powerful way to "tweak" any existing widget.
-- 
Ian


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

Reply via email to