Rodrigo Morante wrote:
> // Added from here...
> fl_begin_offscreen(off);
> /// win->make_current(); <-- remove this
> win->redraw();
> Fl::check();
> fl_end_offscreen();
> // ...to here.
First off, I am going the conversation late, so forgive me if what I am
about to say has already been said.
I needed something like this awhile back, but instead of saving a window, I
wanted to save the contents of a Fl_Scroll.
The trick, I believe, had to do with the win->redraw() statement you have.
The widgets in the window may not actually redraw themselves when you call
Fl::check(). They might not if they have some logic around damage or
something that says they are not dirty so they don't need to redraw.
Instead, what I did was derived a new widget from Fl_Scroll called:
Fl_RGB_Image* Fl_Canvas::capture() // Fl_Canvas derives from Fl_Scroll.
Then, where you do win->redraw(), I did something like:
for(int i = 0; i < children(); i++)
child(i)->draw();
This worked from me because my Fl_Scroll contained custom widgets that had a
public draw().
Instead, assuming you derive a new window class, Fl_MyWindow : public
Fl_Double_Window, for example, you can do something like this (untested
code):
Fl_RGB_Image* Fl_MyWindow::Fl_Canvas::capture()
{
// ... offscreen setup and stuff here
Fl_Widget *o = NULL;
// probably need some fancy Fl_Group descending impl.
for(int i = 0; i < children(); i++)
{
o = child(i);
o->damage(FL_DAMAGE_ALL);
o->redraw();
}
// once all widgets are dirty, force redraw. Maybe Fl::flush() is better?
Fl::check();
// ... offscreen closing here
}
Note that my example is basically psuedo-code. Also, notice that the
function returns Fl_RGB_Image*. I chose to do that so that if I reuse the
code, I can do something else with the image instead of saving it.
Hope this helps.
Cheers,
Alvin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk