diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-11-27 17:44:08 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-11-27 17:44:08 +0000 |
| commit | 2b85bf81680e2243ef5a5daf85d9eb04321c7278 (patch) | |
| tree | dc7d3e1cdbd44ed10b358412098b73d24b64d143 /src/Fl_Double_Window.cxx | |
| parent | 4dc5732a3e0f376786d1d6b788e5cf601439e890 (diff) | |
Preliminary commit of my MacOS X work.
**** THIS CODE COMPILES BUT DOES NOT WORK. ****
TODO: fix event handling - getting blank windows, etc.
TODO: re-port OpenGL code.
TODO: add support for images with alpha.
TODO: add support for more then just beeps in fl_beep().
TODO: other stuff I'm sure...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1765 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Double_Window.cxx')
| -rw-r--r-- | src/Fl_Double_Window.cxx | 89 |
1 files changed, 86 insertions, 3 deletions
diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx index dd60ba903..6e2a741bc 100644 --- a/src/Fl_Double_Window.cxx +++ b/src/Fl_Double_Window.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Double_Window.cxx,v 1.12.2.4 2001/01/22 15:13:39 easysw Exp $" +// "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.1 2001/11/27 17:44:06 easysw Exp $" // // Double-buffered window code for the Fast Light Tool Kit (FLTK). // @@ -59,7 +59,7 @@ static int can_xdbe() { #endif void Fl_Double_Window::show() { -#ifndef WIN32 +#if !defined(WIN32) && !defined(__APPLE__) if (!shown()) { // don't set the background pixel fl_open_display(); Fl_X::make_xid(this); @@ -94,6 +94,82 @@ void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) extern void fl_restore_clip(); +#elif defined(__APPLE__) + +/** + * Mac: + */ +GWorldPtr fl_create_offscreen(int w, int h) { + GWorldPtr gw; + Rect bounds; + bounds.left=0; bounds.right=w; bounds.top=0; bounds.bottom=h; + QDErr err = NewGWorld(&gw, 0, &bounds, 0L, 0L, useTempMem); + if ( err == -108 ) + { } +// fl_message( "The application memory is low. Please increase the initial memory assignment.\n" ); + if (err!=noErr || gw==0L) return 0L; + return gw; +} + +/** + * Mac: + */ +void fl_copy_offscreen(int x,int y,int w,int h,GWorldPtr gWorld,int srcx,int srcy) { + Rect src; + src.top = srcy; src.left = srcx; src.bottom = srcy+h; src.right = srcx+w; + Rect dst; + GrafPtr dstPort; GetPort(&dstPort); + dst.top = y; dst.left = x; dst.bottom = y+h; dst.right = x+w; + RGBColor rgb; + rgb.red = 0xffff; rgb.green = 0xffff; rgb.blue = 0xffff; + RGBBackColor( &rgb ); + rgb.red = 0x0000; rgb.green = 0x0000; rgb.blue = 0x0000; + RGBForeColor( &rgb ); + CopyBits(GetPortBitMapForCopyBits(gWorld), GetPortBitMapForCopyBits(dstPort), &src, &dst, srcCopy, 0L); +} + +/** + * Mac: + */ +void fl_delete_offscreen(GWorldPtr gWorld) { + DisposeGWorld(gWorld); +} + +static GrafPtr prevPort; +static GDHandle prevGD; + +/** + * Mac: + */ +void fl_begin_offscreen(GWorldPtr gWorld) { + GetGWorld( &prevPort, &prevGD ); + if ( gWorld ) + { + SetGWorld( gWorld, 0L ); + PixMapHandle pm = GetGWorldPixMap(gWorld); + LockPixels(pm); + fl_window = (Window)prevPort; + SetPort( (GrafPtr)fl_window ); + } + fl_push_no_clip(); +} + +/** + * Mac: + */ +void fl_end_offscreen() { + GWorldPtr currPort; + GDHandle currGD; + GetGWorld( &currPort, &currGD ); + fl_pop_clip(); + PixMapHandle pm = GetGWorldPixMap(currPort); + UnlockPixels(pm); + fl_window = (Window)prevPort; + SetGWorld( prevPort, prevGD ); +} + +extern void fl_restore_clip(); + #endif // Fl_Overlay_Window relies on flush(1) copying the back buffer to the @@ -149,6 +225,13 @@ void Fl_Double_Window::flush(int eraseoverlay) { draw(); DeleteDC(fl_gc); fl_gc = _sgc; +#elif defined(__APPLE__) + if ( myi->other_xid ) fl_begin_offscreen( myi->other_xid ); + fl_restore_clip(); // duplicate region into new gc + draw(); + if ( myi->other_xid ) fl_end_offscreen(); + } else { + fl_clip_region( 0 ); #else // X: fl_window = myi->other_xid; draw(); @@ -192,5 +275,5 @@ Fl_Double_Window::~Fl_Double_Window() { } // -// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4 2001/01/22 15:13:39 easysw Exp $". +// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.1 2001/11/27 17:44:06 easysw Exp $". // |
