diff --git a/CHANGES b/CHANGES index e9472a3a098a81b84656db7707688bc92dcc0c52..cc484bcdc6dc012c3004691f96ccc869617191bf 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ CHANGES IN FLTK 1.1.0b7 + - Some Win32 drivers would draw into wrong buffers + after OpenGL mode change + - Mac OS X support works 95% - More documentation updates... - The file chooser would cause a segfault if you clicked in an empty area of the file list. diff --git a/FL/gl.h b/FL/gl.h index d4102a259c421d06ce178788bba9c2f37ab30b08..d99cbd45f90af1beb68e75f55250e6b5eb6e3e26 100644 --- a/FL/gl.h +++ b/FL/gl.h @@ -1,5 +1,5 @@ // -// "$Id: gl.h,v 1.6.2.4 2001/01/22 15:13:38 easysw Exp $" +// "$Id: gl.h,v 1.6.2.4.2.1 2001/12/06 00:17:47 matthiaswm Exp $" // // OpenGL header file for the Fast Light Tool Kit (FLTK). // @@ -44,7 +44,12 @@ # define APIENTRY # endif #endif -#include <GL/gl.h> + +#ifdef __APPLE__ +# include <OpenGL/gl.h> +#else +# include <GL/gl.h> +#endif FL_EXPORT void gl_start(); FL_EXPORT void gl_finish(); @@ -76,5 +81,5 @@ FL_EXPORT void gl_draw_image(const uchar *, int x,int y,int w,int h, int d=3, in #endif // -// End of "$Id: gl.h,v 1.6.2.4 2001/01/22 15:13:38 easysw Exp $". +// End of "$Id: gl.h,v 1.6.2.4.2.1 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/FL/mac.H b/FL/mac.H index 4aa1799474eb68f3de6c2d658fdfc6d901b0eff7..4eeadf3b416c8f73e964a4ba28f00b188044cbb5 100644 --- a/FL/mac.H +++ b/FL/mac.H @@ -1,5 +1,5 @@ // -// "$Id: mac.H,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $" +// "$Id: mac.H,v 1.1.2.2 2001/12/06 00:17:47 matthiaswm Exp $" // // Mac header file for the Fast Light Tool Kit (FLTK). // @@ -108,7 +108,7 @@ extern void fl_delete_offscreen(Fl_Offscreen gWorld); extern void fl_begin_offscreen(Fl_Offscreen gWorld); extern void fl_end_offscreen(); -typedef GrafPtr Fl_Bitmask; +typedef GWorldPtr Fl_Bitmask; // Carbon requires a 1-bit GWorld instead of a BitMap extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); @@ -120,6 +120,6 @@ extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b) #endif // !FL_MAC_H // -// End of "$Id: mac.H,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $". +// End of "$Id: mac.H,v 1.1.2.2 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/FL/mac.r b/FL/mac.r index ef7d54eeba1a1743d82723de49e3fbd3cfc8df32..3d71f2ebbf6d90817e31cf4bc663eaa42f231a12 100644 --- a/FL/mac.r +++ b/FL/mac.r @@ -8,19 +8,6 @@ data 'MENU' (128, "Apple") { $"2D00 0000 0000" /* -..... */ }; -data 'cfrg' (0) { - $"0000 0000 0000 0000 0000 0001 0000 0000" /* ................ */ - $"0000 0000 0000 0000 0000 0000 0000 0001" /* ................ */ - $"7077 7063 0000 0000 0000 0000 0000 0000" /* pwpc............ */ - $"0001 0000 0000 0101 0000 0000 0000 0000" /* ................ */ - $"0000 0000 0000 0000 0034 0662 7574 746F" /* .........4.butto */ - $"6E00 0000" /* n... */ -}; - -data 'SIZE' (-1) { - $"58C0 0006 0000 0006 0000" /* X�........ */ -}; - data 'carb' (0) { }; diff --git a/README.mac b/README.mac index d375cd1883f4864c7dbf044d90cad848818cfa24..3b244dafad365aae1af2887dd039db756133780b 100644 --- a/README.mac +++ b/README.mac @@ -1,13 +1,23 @@ README.mac - 12/03/2001 - Building FLTK under MacOS and OS X ------------------------------------------------------------ - +CONTENTS +-------- + - Introduction + - gcc (Carbon) - how to build + - scripts + - known MacFLTK bugs + - test suite status + - other stuff + - FLTK 1.0.x for Mac + + INTRODUCTION ------------ FLTK for Mac OS X is in pre-beta stage. Expect rapid changes to the source code and build environment. Expect many crashes and funny -bliking patterns. +blinking patterns. FLTK currently supports the following development environment on the Mac OS X platform: @@ -20,11 +30,11 @@ Mac OS X platform: - (MPW - future releases) -FLTK for Mac is carbonized, i.e. all applicatiosn should run on Mac +FLTK for Mac is carbonized, i.e. all applications should run on Mac OS 8.1 and higher and OS X without changes. -gcc (Carbon) - how to buid +gcc (Carbon) - how to build -------------------------- Since the Max OS X command line build environment is based on BSD @@ -69,16 +79,54 @@ find . -name 'Make*' -exec $SET_MAC_TYPE {} \; echo "done." +known MacFLTK bugs +------------------ + +- OpenGL window resize +- font support not finished +- line styles missing +- cut, copy, paste +- mousewheel (Carbon Events) +- sub-sub-subwindow +- modal windows are not modal +- makefiles supporting Rez + + +test suite status +----------------- + +OS X: + +CubeView(++), adjuster(++), arc(++), ask(++), bitmap(++), +boxtype(++), browser(++), button(++), buttons(++), checkers(++), +clock(++), colbrowser(++), color_chooser(++), cube(++), cursor(+), +curve(++), demo(++), doublebuffer(++), editor(++), fast_slow(++), +file_chooser(++), fonts(++), forms(++), fractals(+), fullscreen(+), +gl_overlay(o), glpuzzle(++), hello(++), help(++), iconize(+), image(+), +inactive(++), input(++), keyboard(+), label(++), line_style(+), +mandelbrot(++), menubar(++), message(++), minimum(++), navigation(++), +output(++), overlay(o), pack(++), pixmap(++), pixmap_browser(++), +radio(++), resizebox(++), scroll(++), shape(+), shiny(--), subwindow(++), +symbols(++), tabs(++), tile(++), tiled_image(++), valuators(++), +fluid(++) + +(o)=minor bugs, (+)=usable, (++)=running perfectly, (-)=major +bugs, (--)=crashes + + other stuff ----------- The following creator ID's 'FLTK', 'Fltk', 'FLID' and 'Flid' are -officially registered with Aplle Computers and can be used for +officially registered with Apple Computers and can be used for FLTK applications ('FLTK') and fluid files ('Flid'). -All applications shout be ended with exit(0); or they might +All applications should be ended with exit(0); or they might hang until killed. +Under OS X, all windows are doublebuffered anyway. Using Fl_Window +has the same effect as using Fl_Double_Window on OS X. + FLTK 1.0.x for Mac ------------------ diff --git a/src/Fl.cxx b/src/Fl.cxx index 51bf7d61c6046418c8420b4162515bf4d8302289..d803583ce9bfe3e85d4bcdf68dae7c32fb3c4d69 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl.cxx,v 1.24.2.41.2.10 2001/11/28 20:43:44 easysw Exp $" +// "$Id: Fl.cxx,v 1.24.2.41.2.11 2001/12/06 00:17:47 matthiaswm Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -361,7 +361,14 @@ void Fl::flush() { #ifdef WIN32 GdiFlush(); -#elif !defined(__APPLE__) +#elif defined (__APPLE__) + GrafPtr port; GetPort( &port ); + if ( port ) + { + QDFlushPortBuffer( port, 0 ); + //printf("DBG: Fl::flush\n"); + } +#else if (fl_display) XFlush(fl_display); #endif } @@ -834,5 +841,5 @@ void Fl_Window::flush() { } // -// End of "$Id: Fl.cxx,v 1.24.2.41.2.10 2001/11/28 20:43:44 easysw Exp $". +// End of "$Id: Fl.cxx,v 1.24.2.41.2.11 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx index 272067ddffa8d97345469554e6acdea92e126e5b..4d03d5ae885efdb8ac576e45b8abbb0ae71911ce 100644 --- a/src/Fl_Bitmap.cxx +++ b/src/Fl_Bitmap.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.7 2001/11/27 17:44:06 easysw Exp $" +// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.8 2001/12/06 00:17:47 matthiaswm Exp $" // // Bitmap drawing routines for the Fast Light Tool Kit (FLTK). // @@ -34,49 +34,48 @@ #ifdef __APPLE__ // MacOS bitmask functions Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) { Rect srcRect; - RgnHandle r = NewRgn(); srcRect.left = 0; srcRect.right = w; srcRect.top = 0; srcRect.bottom = h; GrafPtr savePort; - GrafPtr newPort; GetPort(&savePort); // remember the current port - newPort = CreateNewPort(); - - SetPortBounds(newPort, &srcRect); // make bitmap the size of the bounds that caller supplied - RectRgn( GetPortClipRegion(newPort, r), &srcRect ); - RectRgn( GetPortVisibleRegion(newPort, r), &srcRect ); - DisposeRgn(r); - - //++ rowBytes is size of row, it must be rounded up to an even number of bytes -// int rowBytes = newPort->portBits.rowBytes = (( w + 15 ) >> 4 ) << 1; -// int rowBytesSrc = (( w + 7 ) >> 3 ); -// newPort->portBits.baseAddr = NewPtr( rowBytes * h ); -// if ( !newPort->portBits.baseAddr ) -// { -// SetPort(savePort); -// ClosePort(newPort); -// DisposePtr((Ptr)newPort); -// return 0L; -// } -// -// static uchar reverse[16] = /* Bit reversal lookup table */ -// { 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee, -// 0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff }; -// uchar *dst = (uchar*)newPort->portBits.baseAddr; -// const uchar *src = array; -// int rowPatch = ( rowBytes!=rowBytesSrc ) ? 1 : 0 ; -// for ( int j=0; j<h; j++,dst+=rowPatch ) -// for ( int i=0; i<rowBytesSrc; i++,src++ ) -// *dst++ = (reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] & 0x0f); + Fl_Bitmask gw; + NewGWorld( &gw, 1, &srcRect, 0L, 0L, 0 ); + PixMapHandle pm = GetGWorldPixMap( gw ); + if ( pm ) + { + LockPixels( pm ); + if ( *pm ) + { + uchar *base = (uchar*)GetPixBaseAddr( pm ); + if ( base ) + { + PixMapPtr pmp = *pm; + // verify the parameters for direct memory write + if ( pmp->pixelType == 0 || pmp->pixelSize == 1 || pmp->cmpCount == 1 || pmp->cmpSize == 1 ) + { + static uchar reverse[16] = /* Bit reversal lookup table */ + { 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee, 0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff }; + uchar *dst = base; + const uchar *src = array; + int rowBytesSrc = (w+7)>>3 ; + int rowPatch = (pmp->rowBytes&0x3fff) - rowBytesSrc; + for ( int j=0; j<h; j++,dst+=rowPatch ) + for ( int i=0; i<rowBytesSrc; i++,src++ ) + *dst++ = (reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] & 0x0f); + } + } + UnlockPixels( pm ); + } + } SetPort(savePort); - return newPort; /* tell caller we succeeded! */ + return gw; /* tell caller we succeeded! */ } void fl_delete_bitmask(Fl_Bitmask id) { - if (id) DisposePort(id); + if (id) DisposeGWorld(id); } #elif defined(WIN32) // Windows bitmask functions... // 'fl_create_bitmap()' - Create a 1-bit bitmap for drawing... @@ -236,16 +235,17 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { if (!id) id = fl_create_bitmask(w(), h(), array); GrafPtr dstPort; GetPort( &dstPort ); - Rect dst; - dst.left = X; dst.right = X+W; - dst.top = Y; dst.bottom = Y+H; + Rect src, dst; + GetPortBounds( id, &src ); + SetRect( &src, cx, cy, cx+W, cy+H ); + SetRect( &dst, X, Y, X+W, Y+H ); CopyBits( - GetPortBitMapForCopyBits((GrafPtr)id), - GetPortBitMapForCopyBits(dstPort), - GetPortBounds((GrafPtr)id, 0), - &dst, - srcOr, - 0L); + GetPortBitMapForCopyBits(id), // srcBits + GetPortBitMapForCopyBits(dstPort), // dstBits + &src, // src bounds + &dst, // dst bounds + srcOr, // mode + 0L); // mask region #else if (!id) id = fl_create_bitmask(w(), h(), array); @@ -340,5 +340,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) { // -// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.7 2001/11/27 17:44:06 easysw Exp $". +// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.8 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx index 8145dfdf14327a8cfe14047d7c2acb83ee4fe6cc..9bf615e2dddf0ece39a2d79673ceba4351398893 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.2.2 2001/12/04 03:03:17 matthiaswm Exp $" +// "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.3 2001/12/06 00:17:47 matthiaswm Exp $" // // Double-buffered window code for the Fast Light Tool Kit (FLTK). // @@ -103,7 +103,7 @@ 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); + QDErr err = NewGWorld(&gw, 0, &bounds, 0L, 0L, 0); // 'useTempMem' should not be used (says the Carbon port manual) if ( err == -108 ) { } // fl_message( "The application memory is low. Please increase the initial memory assignment.\n" ); @@ -116,6 +116,7 @@ GWorldPtr fl_create_offscreen(int w, int h) { */ void fl_copy_offscreen(int x,int y,int w,int h,GWorldPtr gWorld,int srcx,int srcy) { Rect src; + if ( !gWorld ) return; src.top = srcy; src.left = srcx; src.bottom = srcy+h; src.right = srcx+w; Rect dst; GrafPtr dstPort; GetPort(&dstPort); @@ -145,11 +146,10 @@ void fl_begin_offscreen(GWorldPtr gWorld) { GetGWorld( &prevPort, &prevGD ); if ( gWorld ) { - SetGWorld( gWorld, 0L ); + SetGWorld( gWorld, 0L ); // sets the correct port PixMapHandle pm = GetGWorldPixMap(gWorld); LockPixels(pm); - fl_window = (Window)prevPort; - SetPort( GetWindowPort(fl_window) ); + fl_window = GetWindowFromPort( gWorld ); } fl_push_no_clip(); } @@ -164,8 +164,8 @@ void fl_end_offscreen() { fl_pop_clip(); PixMapHandle pm = GetGWorldPixMap(currPort); UnlockPixels(pm); - fl_window = (Window)prevPort; SetGWorld( prevPort, prevGD ); + fl_window = GetWindowFromPort( prevPort ); } extern void fl_restore_clip(); @@ -187,7 +187,14 @@ void Fl_Double_Window::flush(int eraseoverlay) { XdbeAllocateBackBufferName(fl_display, fl_xid(this), XdbeUndefined); else #endif +#ifdef __APPLE__ + // the Apple OS X window manager double buffers ALL windows anyway, so there is no need to waste memory and time + // BTW: Windows2000 and later also forces doublebuffering if transparent windows are beeing used (alpha channel) + if ( !QDIsPortBuffered( GetWindowPort(myi->xid) ) ) myi->other_xid = fl_create_offscreen(w(), h()); +#else + myi->other_xid = fl_create_offscreen(w(), h()); +#endif clear_damage(FL_DAMAGE_ALL); } #if USE_XDBE @@ -242,7 +249,11 @@ void Fl_Double_Window::flush(int eraseoverlay) { // on Irix (at least) it is faster to reduce the area copied to // the current clip region: int X,Y,W,H; fl_clip_box(0,0,w(),h(),X,Y,W,H); +#ifdef __APPLE__ + if (myi->other_xid) fl_copy_offscreen(X, Y, W, H, myi->other_xid, X, Y); +#else fl_copy_offscreen(X, Y, W, H, myi->other_xid, X, Y); +#endif } void Fl_Double_Window::resize(int X,int Y,int W,int H) { @@ -275,5 +286,5 @@ Fl_Double_Window::~Fl_Double_Window() { } // -// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.2 2001/12/04 03:03:17 matthiaswm Exp $". +// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.3 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/src/Fl_Gl_Choice.H b/src/Fl_Gl_Choice.H index 82dad8f20059a06162a7696e7c33930635724398..4f30578719f0aacf5e75eb96561a3d2a3e04a8d8 100644 --- a/src/Fl_Gl_Choice.H +++ b/src/Fl_Gl_Choice.H @@ -1,5 +1,5 @@ // -// "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.1 2001/11/27 17:44:06 easysw Exp $" +// "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.2 2001/12/06 00:17:47 matthiaswm Exp $" // // OpenGL definitions for the Fast Light Tool Kit (FLTK). // @@ -58,8 +58,9 @@ # include <FL/gl.h> # define GLContext HGLRC #elif defined(__APPLE__) -# include <OpenGL.h> -# define GLContext CGLContextObj +# include <OpenGL/gl.h> +# include <AGL/agl.h> +# define GLContext AGLContext #else # include <GL/glx.h> # define GLContext GLXContext @@ -94,7 +95,7 @@ GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0); #elif defined(__APPLE__) -//++ +GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0); #else @@ -114,5 +115,5 @@ void fl_delete_gl_context(GLContext); #endif // -// End of "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.1 2001/11/27 17:44:06 easysw Exp $". +// End of "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.2 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx index fe5d702b083630eaded04875dbc3bf7dc1249f32..a94c239b7306668b3477659f4be323a3125904d4 100644 --- a/src/Fl_Gl_Choice.cxx +++ b/src/Fl_Gl_Choice.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.2 2001/11/27 17:44:06 easysw Exp $" +// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.3 2001/12/06 00:17:47 matthiaswm Exp $" // // OpenGL visual selection code for the Fast Light Tool Kit (FLTK). // @@ -31,6 +31,10 @@ #include <stdlib.h> #include "Fl_Gl_Choice.H" +#ifdef __APPLE__ +# include <Fl/Fl_Window.H> +#endif + static Fl_Gl_Choice *first; // this assummes one of the two arguments is zero: @@ -195,16 +199,16 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay AGL_NONE }; AGLPixelFormat fmt; fmt = aglChoosePixelFormat(NULL, 0, attrib); - context = aglCreateContext(fmt, fl_first_context); - if ( !fl_first_context ) fl_first_context = (GLXContext)context; + context = aglCreateContext(fmt, first_context); + if ( !first_context ) first_context = (GLContext)context; aglDestroyPixelFormat( fmt ); - if ( parent() ) { - CGrafPort *port = (CGrafPort*)fl_xid(this); - GLint rect[] = { x(), port->portRect.bottom-h()-y(), w(), h() }; - aglSetInteger( (GLXContext)context, AGL_BUFFER_RECT, rect ); - aglEnable( (GLXContext)context, AGL_BUFFER_RECT ); + if ( window->parent() ) { + Rect wrect; GetWindowPortBounds( fl_xid(window), &wrect ); + GLint rect[] = { window->x(), wrect.bottom-window->h()-window->y(), window->w(), window->h() }; + aglSetInteger( (GLContext)context, AGL_BUFFER_RECT, rect ); + aglEnable( (GLContext)context, AGL_BUFFER_RECT ); } - aglSetDrawable((GLXContext)context, (CGrafPort*)fl_xid(window)); + aglSetDrawable( context, GetWindowPort( fl_xid(window) ) ); return (context); } #else @@ -228,13 +232,13 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) { wglMakeCurrent(Fl_X::i(w)->private_dc, context); #elif defined(__APPLE__) if ( w->parent() ) { //: resize our GL buffer rectangle - CGrafPort *port = (CGrafPort*)fl_xid(w); - GLint rect[] = { w->x(), port->portRect.bottom-w->h()-w->y(), w->w(), w->h() }; - aglSetInteger( c, AGL_BUFFER_RECT, rect ); - aglEnable( c, AGL_BUFFER_RECT ); + Rect wrect; GetWindowPortBounds( fl_xid(w), &wrect ); + GLint rect[] = { w->x(), wrect.bottom-w->h()-w->y(), w->w(), w->h() }; + aglSetInteger( context, AGL_BUFFER_RECT, rect ); + aglEnable( context, AGL_BUFFER_RECT ); } - aglSetDrawable(c, (CGrafPort*)fl_xid(w)); //++ here or in Fl_Gl_Window::make_current creation part? - aglSetCurrentContext(c); + aglSetDrawable(context, GetWindowPort( fl_xid(w) ) ); //++ here or in Fl_Gl_Window::make_current creation part? + aglSetCurrentContext(context); #else glXMakeCurrent(fl_display, fl_xid(w), context); #endif @@ -258,10 +262,10 @@ void fl_delete_gl_context(GLContext context) { if (context != first_context) { #ifdef WIN32 wglDeleteContext(context); -#elif defined(__APPLE) - aglSetCurrentContext(NULL); - aglSetDrawable((AGLContext)context, NULL); - aglDestroyContext((AGLContext)context); +#elif defined(__APPLE__) + aglSetCurrentContext( NULL ); + aglSetDrawable( context, NULL ); + aglDestroyContext( context ); #else glXDestroyContext(fl_display, context); #endif @@ -271,5 +275,5 @@ void fl_delete_gl_context(GLContext context) { #endif // -// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.2 2001/11/27 17:44:06 easysw Exp $". +// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.3 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx index 31142185cea6d365cb04d71b3ba4743ddd3a1eb0..e4a16c81e8dbc15eba60c2c269f6e9d1751ca579 100644 --- a/src/Fl_Gl_Window.cxx +++ b/src/Fl_Gl_Window.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.2 2001/12/04 04:12:58 matthiaswm Exp $" +// "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.3 2001/12/06 00:17:47 matthiaswm Exp $" // // OpenGL window code for the Fast Light Tool Kit (FLTK). // @@ -202,8 +202,12 @@ void Fl_Gl_Window::flush() { #ifdef __APPLE__ //: clear previous clipping in this shared port - CGrafPort *port = (CGrafPort*)fl_xid(this); - SetRectRgn( port->clipRgn, 0, 0, 0x7fff, 0x7fff ); + GrafPtr port = GetWindowPort( fl_xid(this) ); + Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff ); + GrafPtr old; GetPort( &old ); + SetPort( port ); + ClipRect( &rect ); + SetPort( old ); #endif make_current(); @@ -296,10 +300,10 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) { valid(0); #ifdef __APPLE__ if ( parent() ) { //: resize our GL buffer rectangle - CGrafPort *port = (CGrafPort*)fl_xid(this); - GLint rect[] = { X, port->portRect.bottom-h()-y(), W, H }; - aglSetInteger( (GLXContext)context_, AGL_BUFFER_RECT, rect ); - aglEnable( (GLXContext)context_, AGL_BUFFER_RECT ); + Rect wrect; GetWindowPortBounds( fl_xid(this), &wrect ); + GLint rect[] = { X, wrect.bottom-h()-y(), W, H }; + aglSetInteger( context_, AGL_BUFFER_RECT, rect ); + aglEnable( context_, AGL_BUFFER_RECT ); } #elif !defined(WIN32) if (!resizable() && overlay && overlay != this) @@ -347,5 +351,5 @@ void Fl_Gl_Window::draw_overlay() {} #endif // -// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.2 2001/12/04 04:12:58 matthiaswm Exp $". +// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.3 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/src/Fl_Sys_Menu_Bar.cxx b/src/Fl_Sys_Menu_Bar.cxx index 399b22c6199a314ef441104d2e52da2a63a46f12..5ae4e3ddbdd9395e31624a0ef321f71f26519945 100644 --- a/src/Fl_Sys_Menu_Bar.cxx +++ b/src/Fl_Sys_Menu_Bar.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $" +// "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.2.2 2001/12/06 00:17:47 matthiaswm Exp $" // // MacOS system menu bar widget for the Fast Light Tool Kit (FLTK). // @@ -24,7 +24,7 @@ // /** - * Tis code is a quick hack! It was written as a proove of concept. + * This code is a quick hack! It was written as a proof of concept. * It has been tested on the "menubar" sample program and provides * basic functionality. * @@ -252,7 +252,7 @@ void Fl_Sys_Menu_Bar::menu(const Fl_Menu_Item *m) } InsertMenu( mh, 0 ); - if ( mm->flags & FL_MENU_INACTIVE ) DisableItem( mh, 0 ); + if ( mm->flags & FL_MENU_INACTIVE ) DisableMenuItem( mh, 0 ); mm++; } DrawMenuBar(); @@ -310,5 +310,5 @@ int Fl_Menu_Bar::handle(int event) { */ // -// End of "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $". +// End of "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.2.2 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index 9cab1e8e33a9300cb1411a4ccae050fc89eed28e..db33c1d7b437671329ddbf8d1f769265655b2dfd 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_mac.cxx,v 1.1.2.2 2001/12/04 03:03:17 matthiaswm Exp $" +// "$Id: Fl_mac.cxx,v 1.1.2.3 2001/12/06 00:17:47 matthiaswm Exp $" // // MacOS specific code for the Fast Light Tool Kit (FLTK). // @@ -28,6 +28,8 @@ // still be useful. #define CONSOLIDATE_MOTION 0 +// use TARGET_API_MAC_CARBON if needed + #include <config.h> #include <FL/Fl.H> #include <FL/x.H> @@ -163,6 +165,13 @@ int fl_ready() } +/** + */ +void printMacEvent( const EventRecord &ev ) +{ +printf("Event: w:0x%04x m:0x%08x mod:0x%04x flags:%08x x:%d, y:%d\n", ev.what, ev.message, ev.modifiers, 0, ev.where.h, ev.where.v ); +} + /** * This function iss the central event handler. * It reads events from the event queue using the given maximum time @@ -206,7 +215,7 @@ static double do_queued_events( double time = 0.0 ) #else EventRecord ev; unsigned long ticks = (int)(time*60.0); - while ( WaitNextEvent(everyEvent, &ev, ticks, rgn) ) + if ( WaitNextEvent(everyEvent, &ev, ticks, rgn) ) { fl_handle(ev); //: handle the nullEvent to get mouse up events SetRectRgn(rgn, ev.where.h, ev.where.v, ev.where.h+1, ev.where.v+1 ); @@ -448,7 +457,7 @@ static void set_shift_states(const EventRecord &macevent) { ulong state = Fl::e_state & 0xff000000; if (macevent.modifiers&shiftKey) state |= FL_SHIFT; - if ( (macevent.modifiers&controlKey) && (macevent.modifiers&btnState) ) state |= FL_META; // try to fetch the right mouse button + if ( (macevent.modifiers&controlKey) && (!Button()) ) state |= FL_META; // try to fetch the right mouse button if (macevent.modifiers&optionKey) state |= FL_ALT; if (macevent.modifiers&cmdKey) state |= FL_CTRL; if (macevent.modifiers&alphaLock) state |= FL_CAPS_LOCK; @@ -610,6 +619,8 @@ void Fl_X::flush() { w->flush(); SetOrigin( 0, 0 ); + //QDFlushPortBuffer( GetWindowPort(xid), 0 ); // easy way out - remove! + //printf("DBG: Fl_X::flush\n"); } @@ -639,8 +650,8 @@ void handleUpdateEvent( WindowPtr xid ) } BeginUpdate( xid ); - DrawControls(xid); // do we need this? - DrawGrowIcon(xid); // do we need this? + //DrawControls(xid); // do we need this? + //DrawGrowIcon(xid); // do we need this? for ( Fl_X *cx = i->xidChildren; cx; cx = cx->xidNext ) { cx->w->clear_damage(window->damage()|FL_DAMAGE_EXPOSE); @@ -652,6 +663,8 @@ void handleUpdateEvent( WindowPtr xid ) window->clear_damage(); EndUpdate( xid ); + //QDFlushPortBuffer( GetWindowPort(xid), 0 ); // should not be needed here! + //printf("DBG: handleUpdate::flush\n"); SetPort( oldPort ); } @@ -685,12 +698,13 @@ int fl_handle(const EventRecord &macevent) WindowPtr xid; int event = 0; Fl_Window *window = 0L; + //printMacEvent( macevent ); switch (macevent.what) { case mouseDown: { // handle the differnt mouseDown events in various areas of the screen int part = FindWindow(macevent.where, &xid); - printf("mousedown in part %d\n", part ); + //printf("mousedown in part %d\n", part ); prevMouseDownXid = xid; switch (part) { case inDesk: break; @@ -701,9 +715,10 @@ int fl_handle(const EventRecord &macevent) window = fl_find(xid); if (!window) break; SetPort( GetWindowPort(xid) ); SetOrigin(0, 0); - Fl::e_keysym = FL_Button+((macevent.modifiers&controlKey)?3:1); //++ simulate three button using modifiers + //printMacEvent( macevent ); + Fl::e_keysym = FL_Button+((macevent.modifiers&0x1000)?3:1); //++ simulate three button using modifiers set_event_xy(macevent); checkdouble(); - Fl::e_state |= ((macevent.modifiers&controlKey)?FL_BUTTON3:FL_BUTTON1); + Fl::e_state |= ((macevent.modifiers&0x1000)?FL_BUTTON3:FL_BUTTON1); return Fl::handle(FL_PUSH, window); } case inDrag: Fl_X::MacDragWindow(xid, macevent); break; case inGrow: Fl_X::MacGrowWindow(xid, macevent); break; @@ -805,7 +820,7 @@ int fl_handle(const EventRecord &macevent) send_motion = fl_xmousewin = window; return 0; #else - return Fl::handle( (macevent.modifiers & btnState)?FL_MOVE:FL_DRAG, window); + return Fl::handle( Button()?FL_DRAG:FL_MOVE, window); #endif // if (!Fl::grab()) ReleaseCapture(); } @@ -936,6 +951,7 @@ void Fl_X::make(Fl_Window* w) int winclass = kDocumentWindowClass; int winattr = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute + //| kWindowLiveResizeAttribute // activate this as soon as we ported to Carbon Events! //| kWindowStandardHandlerAttribute ; // int winattr = kWindowStandardHandlerAttribute; @@ -944,7 +960,9 @@ void Fl_X::make(Fl_Window* w) int yp = w->y(); int wp = w->w(); int hp = w->h(); - if (!w->size_range_set) { + if (w->size_range_set) { + winattr |= kWindowFullZoomAttribute | kWindowResizableAttribute; + } else { if (w->resizable()) { Fl_Widget *o = w->resizable(); int minw = o->w(); if (minw > 100) minw = 100; @@ -957,9 +975,28 @@ void Fl_X::make(Fl_Window* w) } } int xwm = xp, ywm = yp, bt, bx, by; - if (!fake_X_wm(w, xwm, ywm, bt, bx, by)) winclass = kFloatingWindowClass; - else if (w->modal()) winclass = kModalWindowClass; - else if (w->non_modal()) winclass = kToolbarWindowClass; + // classes: + // kAlertWindowClass: small up frame - nice + // kModalWindowClass: as above + // kFloatingWindowClass: does not deactivate app window, but has small title bar (medium decoration) + // kDocumentWindowClass: transparent huge upper title (large decoration) -- last standard definition + // kUtilityWindowClass: like 'floating (small decoration) + // kHelpWindowClass: perfect: no decoration, keeps master active, stays on top of ALL windows, not modal though + // kSheetWindowClass: no deco, deactivates parent + // kToolbarWindowClass: no deco, passive, under other menues + // kPlainWindowClass: no deco, active, under + // kOverlayWindowClass: invisible! + // kSheetAlertWindowClass: no deco, active, under + // kAltPlainWindowClass: no deco, active, under + // attributes: + // kWindowCloseBoxAttribute, HorizontalZoom, VerticalZoom, FullZoom, CollapsBox, Resizable, + // SideTitlebar(floatin only), NoUpdates, NoActivates, Macros: StandardDocument, StandardFloating + if (!fake_X_wm(w, xwm, ywm, bt, bx, by)) + { winclass = kHelpWindowClass; winattr = 0; } + else if (w->modal()) + winclass = kFloatingWindowClass; // basically fine, but not modal! The modal window however does nor show + else if (w->non_modal()) + winclass = kFloatingWindowClass; // we need to call 'InitFloatingWindows for OS 8, 9 if (by+bt) { //++ if (!w->non_modal()) style |= WS_SYSMENU | WS_MINIMIZEBOX; wp += 2*bx; @@ -1003,7 +1040,7 @@ void Fl_X::make(Fl_Window* w) x->cursor = fl_default_cursor; x->xidChildren = 0; x->xidNext = 0; - CreateNewWindow(winclass, winattr, &wRect, &(x->xid)); + CreateNewWindow( winclass, winattr, &wRect, &(x->xid) ); SetWTitle(x->xid, pTitle); x->w = w; w->i = x; x->wait_for_expose = 1; @@ -1013,12 +1050,19 @@ void Fl_X::make(Fl_Window* w) w->set_visible(); w->handle(FL_SHOW); w->redraw(); // force draw to happen - TransitionWindow( x->xid, kWindowZoomTransitionEffect, kWindowShowTransitionAction, 0 ); + //TransitionWindow( x->xid, kWindowZoomTransitionEffect, kWindowShowTransitionAction, 0 ); ShowWindow( x->xid ); fl_show_iconic = 0; //++ hmmm, this should maybe set by the activate event?! Fl::handle(FL_FOCUS, w); //++ if (w->modal()) { Fl::modal_ = w; fl_fix_focus(); } + if ( ! Fl_X::first->next ) // if this is the first window, we need to bring the application to the front + { + ProcessSerialNumber psn; + OSErr err = GetCurrentProcess( &psn ); + if ( err==noErr ) SetFrontProcess( &psn ); + // or 'BringToFront' + } } } @@ -1102,8 +1146,8 @@ void Fl_Window::resize(int X,int Y,int W,int H) { MoveWindow(i->xid, X, Y, 0); if (is_a_resize) { SizeWindow(i->xid, W>0 ? W : 1, H>0 ? H : 1, 1); -// Rect all; all.top=-32000; all.bottom=32000; all.left=-32000; all.right=32000; -// InvalRect(&all); + Rect all; all.top=-32000; all.bottom=32000; all.left=-32000; all.right=32000; + InvalWindowRect( i->xid, &all ); } } if (is_a_resize) { @@ -1158,7 +1202,8 @@ void Fl_Window::make_current() } fl_clip_region( 0 ); - CopyRgn( fl_window_region, GetPortClipRegion( GetWindowPort(i->xid), 0) ); // for Fl_GL_Window + SetPortClipRegion( GetWindowPort(i->xid), fl_window_region ); + //CopyRgn( fl_window_region, GetPortClipRegion( GetWindowPort(i->xid), 0) ); // for Fl_GL_Window return; } @@ -1223,6 +1268,6 @@ elapsedNanoseconds = AbsoluteToNanoseconds(elapsedTime); */ // -// End of "$Id: Fl_mac.cxx,v 1.1.2.2 2001/12/04 03:03:17 matthiaswm Exp $". +// End of "$Id: Fl_mac.cxx,v 1.1.2.3 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index ea4f9c08e0a33199f2cd10961ab4e68b5eb7e340..e58ecffd3782f1f776fcc950806f734e4a4fd7da 100644 --- a/src/fl_rect.cxx +++ b/src/fl_rect.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_rect.cxx,v 1.10.2.4.2.3 2001/12/04 03:03:17 matthiaswm Exp $" +// "$Id: fl_rect.cxx,v 1.10.2.4.2.4 2001/12/06 00:17:47 matthiaswm Exp $" // // Rectangle drawing routines for the Fast Light Tool Kit (FLTK). // @@ -340,9 +340,13 @@ void fl_restore_clip() { SelectClipRgn(fl_gc, r); //if r is NULL, clip is automatically cleared #elif defined(__APPLE__) # if 1 - CopyRgn( fl_window_region, GetPortClipRegion( GetWindowPort(fl_window), 0) ); // changed + RgnHandle portClip = NewRgn(); + GrafPtr port = GetWindowPort( fl_window ); + CopyRgn( fl_window_region, portClip ); // changed if ( r ) - SectRgn( GetPortClipRegion( GetWindowPort(fl_window), 0), r, GetPortClipRegion( GetWindowPort(fl_window), 0) ); + SectRgn( portClip, r, portClip ); + SetPortClipRegion( port, portClip ); + DisposeRgn( portClip ); # else if (r) SetClip(r); else { @@ -462,11 +466,11 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){ RgnHandle rr = NewRgn(); SetRectRgn( rr, x, y, x+w, y+h ); SectRgn( r, rr, rr ); - Rect *rp = GetRegionBounds(rr, 0); - X = rp->left; - Y = rp->top; - W = rp->right - X; - H = rp->bottom - Y; + Rect rp; GetRegionBounds(rr, &rp); + X = rp.left; + Y = rp.top; + W = rp.right - X; + H = rp.bottom - Y; DisposeRgn( rr ); if ( H==0 ) return 2; if ( h==H && w==W ) return 0; @@ -494,5 +498,5 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){ } // -// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.3 2001/12/04 03:03:17 matthiaswm Exp $". +// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.4 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/test/fractals.cxx b/test/fractals.cxx index a351eb1e5dc1cb4d95182874f682520fbc597934..17c7205458856e54c615dbff14cd3df52e6004f6 100644 --- a/test/fractals.cxx +++ b/test/fractals.cxx @@ -1,5 +1,5 @@ // -// "$Id: fractals.cxx,v 1.5.2.6.2.1 2001/11/29 21:24:49 easysw Exp $" +// "$Id: fractals.cxx,v 1.5.2.6.2.2 2001/12/06 00:17:47 matthiaswm Exp $" // // Fractal drawing demo for the Fast Light Tool Kit (FLTK). // @@ -62,7 +62,11 @@ int main(int, char**) { */ #include <FL/glut.H> -#include <GL/glu.h> // added for fltk +#ifdef __APPLE__ +# include <OpenGL/glu.h> +#else +# include <GL/glu.h> // added for fltk +#endif #include <stdio.h> #include <stdlib.h> @@ -75,8 +79,11 @@ int main(int, char**) { #include "fracviewer.c" // changed from .h for fltk #if defined(WIN32) || defined(__EMX__) -#define drand48() (((float) rand())/((float) RAND_MAX)) -#define srand48(x) (srand((x))) +# define drand48() (((float) rand())/((float) RAND_MAX)) +# define srand48(x) (srand((x))) +#elif defined __APPLE__ +# define drand48() (((float) rand())/((float) RAND_MAX)) +# define srand48(x) (srand((x))) #endif typedef enum { NOTALLOWED, MOUNTAIN, TREE, ISLAND, BIGMTN, STEM, LEAF, @@ -806,5 +813,5 @@ int main(int argc, char** argv) #endif // -// End of "$Id: fractals.cxx,v 1.5.2.6.2.1 2001/11/29 21:24:49 easysw Exp $". +// End of "$Id: fractals.cxx,v 1.5.2.6.2.2 2001/12/06 00:17:47 matthiaswm Exp $". // diff --git a/test/glpuzzle.cxx b/test/glpuzzle.cxx index 5a6bc9dd75b3b4840e9573e93458cbb65826a0b6..6a980b52d81188f4c411e53fe5e4aac0d95aea21 100644 --- a/test/glpuzzle.cxx +++ b/test/glpuzzle.cxx @@ -1,5 +1,5 @@ // -// "$Id: glpuzzle.cxx,v 1.8.2.5 2001/04/30 17:17:01 easysw Exp $" +// "$Id: glpuzzle.cxx,v 1.8.2.5.2.1 2001/12/06 00:17:47 matthiaswm Exp $" // // OpenGL puzzle demo for the Fast Light Tool Kit (FLTK). // @@ -45,7 +45,11 @@ int main(int, char**) { #include <time.h> #include <math.h> #include <FL/glut.H> // changed for fltk -#include <GL/glu.h> // added for fltk +#ifdef __APPLE__ +# include <OpenGL/glu.h> +#else +# include <GL/glu.h> // added for fltk +#endif #include "trackball.c" // changed from trackball.h for fltk #define WIDTH 4 @@ -1480,5 +1484,5 @@ main(int argc, char **argv) #endif // added for fltk's distribution // -// End of "$Id: glpuzzle.cxx,v 1.8.2.5 2001/04/30 17:17:01 easysw Exp $". +// End of "$Id: glpuzzle.cxx,v 1.8.2.5.2.1 2001/12/06 00:17:47 matthiaswm Exp $". //