> I try to create a Fl_Group derived widget, which redirects pixels
> by means of a fl_offscreen buffer for manipulation.
> fl_offscreen works fine, pixel manipulation is fine, but drawing is
> displaced.
Hmm, I dunno - this seems to work OK for me...
// offscreen-scroll.cxx
// fltk-config --compile offscreen-scroll.cxx
#include <FL/Fl.H>
#include <FL/x.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Scroll.H>
#include <Fl/fl_draw.h>
/***********************************************************************
******/
static uchar *data_p = NULL;
static Fl_Offscreen offscr = 0;
static int offscrW = 750;
static int offscrH = 750;
/***********************************************************************
******/
class offscreen_group : public Fl_Group {
protected:
void draw( );
public:
offscreen_group(int X, int Y, int W, int H) :
Fl_Group(X,Y,W,H) { }
};
void offscreen_group::draw() {
int wo = w();
int ho = h();
if (!offscr) offscr = fl_create_offscreen(offscrW, offscrH);
if(!offscr) return; // create must have failed!
fl_begin_offscreen(offscr);
// draw the widget hierarchy of this group into the offscreen
Fl_Group::draw();
fl_end_offscreen();
// copy the offscreen back onto this window...
fl_copy_offscreen(0, 0, wo, ho, offscr, 0, 0);
}
/***********************************************************************
******/
int main(int argc, char **argv) {
Fl_Double_Window *main_win = new Fl_Double_Window(450, 430,
"Fl_Offscreen group test");
main_win->begin();
Fl_Scroll *scroller = new Fl_Scroll(0,0,400,400);
scroller->begin();
offscreen_group *osg = new offscreen_group(0, 0, offscrW,
offscrH);
osg->begin();
osg->box(FL_FLAT_BOX);
int a = 40, b = 40;
// Put some widgets in the offscreen_group
Fl_Button *b0;
while ((a + 60) < offscrW)
{
b0 = new Fl_Button( a, b, 60, 60, "BUTTON");
a += 60;
b += 60;
}
osg->end();
scroller->end();
main_win->end();
main_win->resizable(scroller);
main_win->show(argc, argv);
return Fl::run( );
}
/* end of file */
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 mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk