? unxmacxp.pro Index: aqua/inc/VCLView.h =================================================================== RCS file: /cvs/oo/gsl/vcl/aqua/inc/VCLView.h,v retrieving revision 1.6 diff -u -r1.6 VCLView.h --- aqua/inc/VCLView.h 2000/12/08 01:28:57 1.6 +++ aqua/inc/VCLView.h 2001/12/21 04:05:38 @@ -75,7 +75,12 @@ // ----------- @interface VCLView : NSQuickDrawView +{ +int qdRgnResized; +} +- init; - (void)drawRect: (NSRect)aRect; +- (void)lockFocus; - (MacOSBOOL)isOpaque; @end Index: aqua/source/gdi/VCLGraphics.m =================================================================== RCS file: /cvs/oo/gsl/vcl/aqua/source/gdi/VCLGraphics.m,v retrieving revision 1.22 diff -u -r1.22 VCLGraphics.m --- aqua/source/gdi/VCLGraphics.m 2001/03/12 23:15:32 1.22 +++ aqua/source/gdi/VCLGraphics.m 2001/12/21 04:05:39 @@ -87,12 +87,33 @@ { if ( [hView isKindOfClass: [NSQuickDrawView class]] ) { - CGrafPtr pCGrafPort = [(NSQuickDrawView *)hView qdPort]; - + CGrafPtr pCGrafPort=NULL; + RGBColor oldFore, newFore; + Rect r; + NSRect viewBounds; + [hView lockFocus]; - + + // [ed] 12/12/01 The Carbon GrafPort only is valid as long as the view has + // the focus, so we need to be sure to execute lockFocus before assigning + // the port. + + pCGrafPort = [(NSQuickDrawView *)hView qdPort]; + return pCGrafPort; + } + else + { + // [ed] 12/12/01 Error checking + + fprintf(stderr, "Non nil hView in LockFocusCGrafPort(), but not a quickdrawview\n"); } // if + } + else + { + // [ed] 12/12/01 Error checking + + fprintf(stderr, "Nil hView in LockFocusCGrafPort()\n"); } // if return NULL; Index: aqua/source/gdi/salgdi.cxx =================================================================== RCS file: /cvs/oo/gsl/vcl/aqua/source/gdi/salgdi.cxx,v retrieving revision 1.55.2.3 diff -u -r1.55.2.3 salgdi.cxx --- aqua/source/gdi/salgdi.cxx 2001/09/17 00:54:52 1.55.2.3 +++ aqua/source/gdi/salgdi.cxx 2001/12/21 04:05:41 @@ -483,6 +483,24 @@ RGBColor aBrushColor = maGraphicsData.maBrushColor; Rect aRect; + // [ed] 12/1/01 Parameter checks. Limit all of the parameters to fit within + // the current port bounds + + Rect portBounds; + GetPortBounds(maGraphicsData.mpCGrafPort, &portBounds); + + if(nX < portBounds.left) + nX=portBounds.left; + + if(nY < portBounds.top) + nY=portBounds.top; + + if((nHeight > (portBounds.bottom-portBounds.top)-(nY-portBounds.top)) || (nHeight < 0)) + nHeight=portBounds.bottom-portBounds.top-(nY-portBounds.top)-1; + + if((nWidth > (portBounds.right-portBounds.left-(nX-portBounds.left))) || (nHeight < 0)) + nWidth=portBounds.right-portBounds.left-(nX-portBounds.left)-1; + // Compute the second set of (nX,nY) coordinates nEndX = nX + nWidth; @@ -500,7 +518,7 @@ } // if else { - PaintRect( &aRect ); + PaintRect( &aRect ); } // else EndGraphics( &maGraphicsData ); Index: aqua/source/gdi/salgdiutils.cxx =================================================================== RCS file: /cvs/oo/gsl/vcl/aqua/source/gdi/salgdiutils.cxx,v retrieving revision 1.4 diff -u -r1.4 salgdiutils.cxx --- aqua/source/gdi/salgdiutils.cxx 2001/03/12 23:15:32 1.4 +++ aqua/source/gdi/salgdiutils.cxx 2001/12/21 04:05:42 @@ -238,9 +238,12 @@ BOOL LockGraphics ( SalGraphics *rSalGraphics ) { BOOL bCGrafPortLocked = FALSE; - + + // [ed] 12/16/01 Don't lock QDView grafports. + if ( ( rSalGraphics != NULL ) && ( rSalGraphics->maGraphicsData.mpCGrafPort != NULL ) + && ( rSalGraphics->maGraphicsData.mbWindow != TRUE) ) { rSalGraphics->maGraphicsData.mnOSStatus @@ -298,8 +301,15 @@ rSalGraphicsData->mpCGrafPort = VCLGraphics_LockFocusCGrafPort( rSalGraphicsData->mhDC ); } // if - - if ( rSalGraphicsData->mpCGrafPort != NULL ) + + // [ed] 12/3/01 Check to make sure we've got a valid graph port + + if(rSalGraphicsData->mpCGrafPort && !IsValidPort(rSalGraphicsData->mpCGrafPort)) + { + fprintf(stderr, "Invalid port in BeginGraphics()\n"); + } + + if ( ( rSalGraphicsData->mpCGrafPort != NULL ) && IsValidPort(rSalGraphicsData->mpCGrafPort)) { // Get the port's pen attributes @@ -326,7 +336,7 @@ // Set to the current offscreen world for Mac OS X // only as everything is written to GWorld here - + SetGWorld( rSalGraphicsData->mpCGrafPort, NULL ); // Was there a QD error when we set the GWorld? @@ -357,8 +367,11 @@ { // if the PixMap is a relocatable block, // then mark it as locked. - - if ( LockPixels( rSalGraphicsData->mhGWorldPixMap ) ) + + // [ed] 12/16/01 Don't lock pixels of QDViews + + if ( !rSalGraphicsData->mbWindow && + LockPixels( rSalGraphicsData->mhGWorldPixMap ) ) { rSalGraphicsData->mbGWorldPixelsLocked = TRUE; } // if @@ -379,10 +392,10 @@ // to our GWorld bStartGraphics = TRUE; - + // Now begin to set the clip region - if ( ( rSalGraphicsData->mbClipRgnChanged == TRUE ) + if ( ( rSalGraphicsData->mbClipRgnChanged == TRUE ) && ( rSalGraphicsData->mhClipRgn != NULL ) ) { @@ -399,8 +412,26 @@ rSalGraphicsData->mbClipRgnChanged = FALSE; } // if } // if + else + { + // [ed] 12/13/01 GWord graphics error flags set + + fprintf(stderr, "GWorld graphics flags indicate error in BeginGraphics()\n"); + } } // if + else + { + // [ed] 12/13/01 GWorld graphics has no PixMap handle + + fprintf(stderr, "Valid GWorld, but no pixmap in BeginGraphics()\n"); + } } // if + else + { + // [ed] 12/13/01 Error checking + + fprintf(stderr, "QuickDraw error in BeginGraphics()\n"); + } } // if } // if @@ -436,11 +467,21 @@ } // if // Reset the port's pen to its original attributes - + + /* + + [ed] 12/19/01 Apparently the pen pattern handle we retrieved + in BeginGraphics() is invalid by this point on OS 10.1. + By not attempting to revert the pen pattern, we can avoid + seg faulting the next time we draw into the port. + + +++ Is it necessary to reset the pen pattern? + SetPortPenPixPat( rSalGraphicsData->mpCGrafPort, rSalGraphicsData->mhPortPenPattern ); - + */ + SetPortPenSize( rSalGraphicsData->mpCGrafPort, rSalGraphicsData->maPortPenSize ); @@ -449,20 +490,26 @@ rSalGraphicsData->mnPortPenMode ); + // When we get here then the QD port must have changed(?) + // [ed] 12/19/01 This will commit the changes to reset the pen size + // and pen mode. + + PortChanged( rSalGraphicsData->mpCGrafPort ); + +#if defined DBG_UTIL || defined DEBUG || defined _DEBUG + // [ed] 12/19/01 Flush the QuickDraw buffer immediately. This helps + // with VCL debugging. + + if(QDIsPortBuffered(rSalGraphicsData->mpCGrafPort)) + QDFlushPortBuffer( rSalGraphicsData->mpCGrafPort, NULL ); +#endif + // Unlock focus on the current NSView if ( rSalGraphicsData->mbWindow == TRUE ) { VCLGraphics_UnLockFocusCGrafPort( rSalGraphicsData->mhDC ); } // if - - // When we get here then the QD port must have changed(?) - - PortChanged( rSalGraphicsData->mpCGrafPort ); - - // Flush the QuickDraw buffer - - QDFlushPortBuffer( rSalGraphicsData->mpCGrafPort, NULL ); // Was there an error after flushing the QuickDraw buffer Index: aqua/source/gdi/salvd.cxx =================================================================== RCS file: /cvs/oo/gsl/vcl/aqua/source/gdi/salvd.cxx,v retrieving revision 1.13 diff -u -r1.13 salvd.cxx --- aqua/source/gdi/salvd.cxx 2001/03/12 23:15:32 1.13 +++ aqua/source/gdi/salvd.cxx 2001/12/21 04:05:43 @@ -86,7 +86,7 @@ GWorldPtr pGWorld = NULL; CTabHandle hCTable = NULL; GDHandle hGDevice = NULL; - GWorldFlags nFlags = noNewDevice; + GWorldFlags nFlags = 0; // [ed] 12/1/01 Allow offscreen gworlds OSStatus nOSStatus = noErr; // Set the dimensions of the GWorldPtr Index: aqua/source/window/VCLView.m =================================================================== RCS file: /cvs/oo/gsl/vcl/aqua/source/window/VCLView.m,v retrieving revision 1.4 diff -u -r1.4 VCLView.m --- aqua/source/window/VCLView.m 2000/12/16 02:43:17 1.4 +++ aqua/source/window/VCLView.m 2001/12/21 04:05:43 @@ -74,6 +74,44 @@ { } +- init +{ + qdRgnResized=0; + return self; +} + +- (void)lockFocus +{ + [super lockFocus]; + + // [ed] 12/15/01 If we haven't done so yet, adjust the visRgn and clipRgn of the port + // to match the view. OS 10.1 changed the default behaviour of the clipping of + // NSQDViews and they now require initialization. + + if(!qdRgnResized) + { + RgnHandle tempRgn; + Rect r; + + r.left=0; + r.top=0; + r.right=[self bounds].size.width; + r.bottom=[self bounds].size.height; + + SetPort([self qdPort]); + + tempRgn=NewRgn(); + RectRgn(tempRgn, &r); + + ClipRect(&r); + SetPortVisibleRegion([self qdPort], tempRgn); + PortChanged([self qdPort]); + + DisposeRgn(tempRgn); + qdRgnResized=1; + } +} + - (MacOSBOOL)isOpaque { // Set background to white to avoid flickering when timer paints Index: aqua/source/window/VCLWindow.m =================================================================== RCS file: /cvs/oo/gsl/vcl/aqua/source/window/VCLWindow.m,v retrieving revision 1.45 diff -u -r1.45 VCLWindow.m --- aqua/source/window/VCLWindow.m 2001/03/07 04:39:53 1.45 +++ aqua/source/window/VCLWindow.m 2001/12/21 04:05:44 @@ -251,8 +251,8 @@ // We need to replace the window's contentView with an VCLView so // that we can paint using QuickDraw - [hWindow setContentView: [[VCLView new] initWithFrame: [hWindow frame]]]; - + [hWindow setContentView: [[[VCLView new] init] initWithFrame: [hWindow frame]]]; + // Turn on optimized drawing since we have no overlapping views [hWindow useOptimizedDrawing: YES];