? vcl/unxmacxi.pro ? vcl/aqua/new_graphics.diff Index: vcl/aqua/inc/salbmp.h =================================================================== RCS file: /cvs/gsl/vcl/aqua/inc/Attic/salbmp.h,v retrieving revision 1.1.2.7 diff -u -r1.1.2.7 salbmp.h --- vcl/aqua/inc/salbmp.h 8 Mar 2007 20:46:10 -0000 1.1.2.7 +++ vcl/aqua/inc/salbmp.h 28 May 2007 15:45:40 -0000 @@ -137,8 +137,11 @@ sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, const BitmapPalette& rDestPalette, sal_uInt8* pDestData, sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData ); - bool Create( CGContextRef xContext, int nX, int nY, int nWidth, int nHeight ); - bool Create( sal_uInt32 nWidth, sal_uInt32 nHeight, sal_uInt16 nBits, sal_uInt32 nBytesPerRow, sal_uInt8* pBuffer, sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY ); + bool Create( CGContextRef xContext, int nX, int nY, int nWidth, int nHeight, bool bMirrorVert = true ); + bool Create( sal_uInt32 nWidth, sal_uInt32 nHeight, sal_uInt16 nBits, sal_uInt32 nBytesPerRow, sal_uInt8* pBuffer, + sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY, + bool bMirrorVert = true + ); bool Create( CGImageRef& xImage ); CGImageRef CreateWithMask( const AquaSalBitmap& rMask, sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY ); Index: vcl/aqua/inc/salframe.h =================================================================== RCS file: /cvs/gsl/vcl/aqua/inc/salframe.h,v retrieving revision 1.15.112.21 diff -u -r1.15.112.21 salframe.h --- vcl/aqua/inc/salframe.h 23 May 2007 14:25:33 -0000 1.15.112.21 +++ vcl/aqua/inc/salframe.h 28 May 2007 15:45:40 -0000 @@ -159,6 +159,9 @@ virtual void SetClientSize( long nWidth, long nHeight ); void UpdateFrameGeometry(); + + // trigger painting of the window + void SendPaintEvent(); void ActivateTSM(); void DeactivateTSM(); Index: vcl/aqua/inc/salgdi.h =================================================================== RCS file: /cvs/gsl/vcl/aqua/inc/salgdi.h,v retrieving revision 1.28.112.28 diff -u -r1.28.112.28 salgdi.h --- vcl/aqua/inc/salgdi.h 24 May 2007 10:43:39 -0000 1.28.112.28 +++ vcl/aqua/inc/salgdi.h 28 May 2007 15:45:41 -0000 @@ -91,10 +91,7 @@ protected: CarbonViewRef mrView; // VCLVIEW - CGContextRef mrBitmapContext; // bitmap graphics context (either from a virtual device(mrBitmapContext==mrContext) or an offscreen copy of mrContext CGContextRef mrContext; // graphics context for Quartz 2D - CGLayerRef mrCGLayer; // CGLayer to store what we draw to mrContext and be able to repaint (replace mrBitmapContext) - CGContextRef mrCGLayerContext; // Context of CGLayer, used for drawing CarbonWindowRef mrWindow; // Window if this is a Window graphics CGMutablePathRef mrClippingPath; // path representing current clip region @@ -121,17 +118,11 @@ bool mbWindow; // is this a window graphics bool mbScreen; // is this graphics screen compatible - sal_Int32 mnGraphics; // guards BeginGraphics and EndGraphics from multiple calls - /* sal_uInt32 mnUpdateGraphicsEvent; DECL_LINK( UpdateGraphics, void* ); */ -#if DEBUGLEVEL>1 - bool mbQDCG; //true if in QDCG -#endif - private: /** returns the display id this window is mostly visible on */ CGDirectDisplayID GetWindowDisplayID() const; @@ -153,18 +144,15 @@ void ImplDrawPixel( long nX, long nY, float pColor[] ); // helper to draw single pixels - bool isOffscreenCopy() const; void Flush(); + bool CheckContext(); + void UpdateWindow(); protected: - // set up and release graphics context, required for any drawing operation - // the view will be be flipped like the HIView coordinate system - // i.e. (0,0) is top left and the y-axis points to the bottom - bool BeginGraphics(); - bool EndGraphics(); - void InitContextForPainting( CGContextRef xContext ); void RefreshWindow(); void RefreshRect(float lX, float lY, float lWidth, float lHeight); void RefreshRect(HIRect aHIRect); + + void SetState(); virtual BOOL unionClipRegion( long nX, long nY, long nWidth, long nHeight ); // draw --> LineColor and FillColor and RasterOp and ClipRegion @@ -340,9 +328,4 @@ virtual BOOL IsNativeControlSupported( ControlType nType, ControlPart nPart ); }; -inline bool AquaSalGraphics::isOffscreenCopy() const -{ - return mrBitmapContext && (mrBitmapContext != mrContext); -} - #endif // _SV_SALGDI_H Index: vcl/aqua/source/gdi/salatslayout.cxx =================================================================== RCS file: /cvs/gsl/vcl/aqua/source/gdi/Attic/salatslayout.cxx,v retrieving revision 1.1.2.15 diff -u -r1.1.2.15 salatslayout.cxx --- vcl/aqua/source/gdi/salatslayout.cxx 23 May 2007 14:21:21 -0000 1.1.2.15 +++ vcl/aqua/source/gdi/salatslayout.cxx 28 May 2007 15:45:41 -0000 @@ -332,11 +332,7 @@ ByteCount theSizes[10]; ATSUAttributeValuePtr theValues[10]; ItemCount numcontrols = 0; - ATSUAttributeTag theTagsOff[10]; - ByteCount theSizesOff[10]; - ATSUAttributeValuePtr theValuesOff[10]; - ItemCount numcontrolsOff = 0; - long height; + long height = 0; if( mnTextLen <= 0 ) return; @@ -344,43 +340,23 @@ // get posiiton of the beginniing of the line to write Point aPos = GetDrawPosition( Point(mnBaseAdv, 0) ); - if ( mpGraphics->BeginGraphics() ) + if ( mpGraphics->CheckContext() ) { - // Get windows dimensions - GetWindowPortBounds( mpGraphics->mrWindow, &windowBounds ); - height = windowBounds.bottom - windowBounds.top; - // Modify Y for flipped view - aPos.Y() = height - aPos.Y(); - - if(mpGraphics->mrContext != NULL){ - // the flipped view leads to flipped glyphs as well - // so apply another transformation that flips back and adjust y-pos accordingly - - CGContextTranslateCTM ( mpGraphics->mrContext, 0, height ); - CGContextScaleCTM ( mpGraphics->mrContext, 1.0, -1.0 ); - - if (mpGraphics->isOffscreenCopy()) - { - CGContextTranslateCTM ( mpGraphics->mrBitmapContext, 0, height ); - CGContextScaleCTM ( mpGraphics->mrBitmapContext, 1.0, -1.0 ); - } - - - theTags[numcontrols] = kATSUCGContextTag; - theSizes[numcontrols] = sizeof( CGContextRef ); - theValues[numcontrols++] = &(mpGraphics->mrContext); - - } - else - { - AquaLog("-->%s : mpGraphics->mrContext is NULL\n",__func__); - } - - if (mpGraphics->isOffscreenCopy()){ - theTagsOff[numcontrolsOff] = kATSUCGContextTag; - theSizesOff[numcontrolsOff] = sizeof( CGContextRef ); - theValuesOff[numcontrolsOff++] = &(mpGraphics->mrBitmapContext); - } + CGContextSaveGState( mpGraphics->mrContext ); + // Get windows dimensions + height = CGBitmapContextGetHeight( mpGraphics->mrContext ); // returns 0 in not a bitmap context case + // Modify Y for flipped view + aPos.Y() = height - aPos.Y(); + + // the flipped view leads to flipped glyphs as well + // so apply another transformation that flips back and adjust y-pos accordingly + + CGContextTranslateCTM ( mpGraphics->mrContext, 0, height ); + CGContextScaleCTM ( mpGraphics->mrContext, 1.0, -1.0 ); + + theTags[numcontrols] = kATSUCGContextTag; + theSizes[numcontrols] = sizeof( CGContextRef ); + theValues[numcontrols++] = &(mpGraphics->mrContext); // Rotate if necessary if( mpGraphics->mnATSUIRotation != 0 ) @@ -389,14 +365,6 @@ theTags[numcontrols] = kATSULineRotationTag; theSizes[numcontrols] = sizeof( Fixed ); theValues[numcontrols++] = &theAngle; - - - if (mpGraphics->isOffscreenCopy()) - { - theTagsOff[numcontrolsOff] = kATSULineRotationTag; - theSizesOff[numcontrolsOff] = sizeof( Fixed ); - theValuesOff[numcontrolsOff++] = &theAngle; - } } // Tell ATSUI to use CoreGraphics @@ -424,18 +392,8 @@ mpGraphics->RefreshRect( nScaledTop, nScaledLeft, nScaledWidth, nScaledHeight ); } #endif - - if (mpGraphics->isOffscreenCopy()) - { - ATSUSetLayoutControls( maATSULayout, numcontrolsOff, theTagsOff, theSizesOff, theValuesOff ); - - theErr = ATSUDrawText( maATSULayout, mnTextOfs, mnTextLen, Long2Fix(aPos.X()), Long2Fix(aPos.Y())); - if( theErr != noErr ) - AquaLog( "ATSLayout::DrawText(0x%p) : ATSUDrawText failed for offscreen copy!\n", this ); - } } - - mpGraphics->EndGraphics(); + CGContextRestoreGState( mpGraphics->mrContext ); } } Index: vcl/aqua/source/gdi/salbmp.cxx =================================================================== RCS file: /cvs/gsl/vcl/aqua/source/gdi/salbmp.cxx,v retrieving revision 1.23.112.19 diff -u -r1.23.112.19 salbmp.cxx --- vcl/aqua/source/gdi/salbmp.cxx 25 May 2007 08:17:50 -0000 1.23.112.19 +++ vcl/aqua/source/gdi/salbmp.cxx 28 May 2007 15:45:41 -0000 @@ -81,18 +81,18 @@ // ------------------------------------------------------------------ -bool AquaSalBitmap::Create( CGContextRef xContext, int nX, int nY, int nWidth, int nHeight ) +bool AquaSalBitmap::Create( CGContextRef xContext, int nX, int nY, int nWidth, int nHeight, bool bMirrorVert ) { return Create( CGBitmapContextGetWidth( xContext ), CGBitmapContextGetHeight( xContext ), CGBitmapContextGetBitsPerPixel( xContext ), CGBitmapContextGetBytesPerRow( xContext ), static_cast< sal_uInt8* >( CGBitmapContextGetData( xContext ) ), - nX, nY, nWidth, nHeight ); + nX, nY, nWidth, nHeight, bMirrorVert ); } /** creates an AquaSalBitmap from a rectangle inside a memory bitmap (only 16 und 32 bit supported!) NOTE: This code flips the data upside down so sources must come from AQUA directly */ -bool AquaSalBitmap::Create( sal_uInt32 nWidth, sal_uInt32 nHeight, sal_uInt16 nBits, sal_uInt32 nBytesPerRow, sal_uInt8* pBuffer, sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY ) +bool AquaSalBitmap::Create( sal_uInt32 nWidth, sal_uInt32 nHeight, sal_uInt16 nBits, sal_uInt32 nBytesPerRow, sal_uInt8* pBuffer, sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY, bool bMirrorVert ) { if( (nBits != 16) && (nBits != 32) || !nWidth || !nHeight ) return false; @@ -109,16 +109,32 @@ if( nX ) pSource += nX << (( nBits == 32 ) ? 2 : 1); - nY = nHeight - nY - nDY; - pSource += nBytesPerRow * nY; - - sal_uInt32 y = nDY; - while( y-- ) - { - memcpy( pDest, pSource, mnBytesPerRow ); - pDest += mnBytesPerRow; - pSource += nBytesPerRow; - } + if( bMirrorVert ) + { + nY = nHeight - nY - nDY; + pSource += nBytesPerRow * nY; + + sal_uInt32 y = nDY; + while( y-- ) + { + memcpy( pDest, pSource, mnBytesPerRow ); + pDest += mnBytesPerRow; + pSource += nBytesPerRow; + } + } + else + { + pSource += nBytesPerRow * nY; + pDest += mnBytesPerRow * (nDY-1); + + sal_uInt32 y = nDY; + while( y-- ) + { + memcpy( pDest, pSource, mnBytesPerRow ); + pDest -= mnBytesPerRow; + pSource += nBytesPerRow; + } + } return true; } return false; Index: vcl/aqua/source/gdi/salgdi.cxx =================================================================== RCS file: /cvs/gsl/vcl/aqua/source/gdi/salgdi.cxx,v retrieving revision 1.59.112.44 diff -u -r1.59.112.44 salgdi.cxx --- vcl/aqua/source/gdi/salgdi.cxx 25 May 2007 06:52:42 -0000 1.59.112.44 +++ vcl/aqua/source/gdi/salgdi.cxx 28 May 2007 15:45:41 -0000 @@ -96,11 +96,6 @@ mrView = NULL; mrWindow = NULL; mrContext = NULL; - mrBitmapContext = NULL; - -#if DEBUGLEVEL>1 - mbQDCG=false; -#endif mrRGBColorSpace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ); @@ -131,15 +126,12 @@ mbScreen = false; // mnUpdateGraphicsEvent = 0; - mnGraphics = 0; } // ----------------------------------------------------------------------- AquaSalGraphics::~AquaSalGraphics() { - DBG_ASSERT( mnGraphics == 0, "vcl::AquaSalGraphics::~AquaSalGraphics(), BeginGraphics and EndGraphics calls do not match!" ); - /* if( mnUpdateGraphicsEvent ) { @@ -151,14 +143,14 @@ ATSUDisposeStyle( maATSUStyle ); delete [] mpStdClippingRect; - if( mrBitmapContext && (mrBitmapContext != mrContext) ) + if( mrContext && mrWindow != 0 ) { // destroy backbuffer bitmap context that we created ourselfs - void * pBuffer = CGBitmapContextGetData(mrBitmapContext); - CFRelease( mrBitmapContext ); - mrBitmapContext = 0; + void * pBuffer = CGBitmapContextGetData(mrContext); + CFRelease( mrContext ); + mrContext = 0; if( pBuffer ) - free( pBuffer ); + rtl_freeMemory( pBuffer ); } } @@ -207,18 +199,7 @@ USHORT AquaSalGraphics::GetBitCount() { - if ( mrWindow ) - { - return static_cast( CGDisplayBitsPerPixel( GetWindowDisplayID() ) ); - } - else if( mrBitmapContext ) - { - return static_cast( CGBitmapContextGetBitsPerPixel(mrBitmapContext) ); - } - else - { - return 32; - } + return static_cast( CheckContext() ? CGBitmapContextGetBitsPerPixel(mrContext) : 0 ); } // ----------------------------------------------------------------------- @@ -228,6 +209,8 @@ // release old path and indicate no clipping CGPathRelease( mrClippingPath ); mrClippingPath = NULL; + if( CheckContext() ) + SetState(); } // ----------------------------------------------------------------------- @@ -291,6 +274,8 @@ delete [] mpClippingRect; mpClippingRect = NULL; } + if( CheckContext() ) + SetState(); } // ----------------------------------------------------------------------- @@ -298,6 +283,8 @@ void AquaSalGraphics::SetLineColor() { mpLineColor[3] = 0.0; // set alpha component to 0 + + CGContextSetStrokeColor( mrContext, mpLineColor ); } // ----------------------------------------------------------------------- @@ -308,6 +295,8 @@ mpLineColor[1] = (float) SALCOLOR_GREEN(nSalColor) / 255.0; mpLineColor[2] = (float) SALCOLOR_BLUE(nSalColor) / 255.0; mpLineColor[3] = 1.0; // opaque + + CGContextSetStrokeColor( mrContext, mpLineColor ); } // ----------------------------------------------------------------------- @@ -315,6 +304,8 @@ void AquaSalGraphics::SetFillColor() { mpFillColor[3] = 0.0; // set alpha component to 0 + + CGContextSetFillColor( mrContext, mpFillColor ); } // ----------------------------------------------------------------------- @@ -325,6 +316,8 @@ mpFillColor[1] = (float) SALCOLOR_GREEN(nSalColor) / 255.0; mpFillColor[2] = (float) SALCOLOR_BLUE(nSalColor) / 255.0; mpFillColor[3] = 1.0; // opaque + + CGContextSetFillColor( mrContext, mpFillColor ); } // ----------------------------------------------------------------------- @@ -335,44 +328,46 @@ // ----------------------------------------------------------------------- +static SalColor ImplGetROPSalColor( SalROPColor nROPColor ) +{ + SalColor nSalColor; + if ( nROPColor == SAL_ROP_0 ) + nSalColor = MAKE_SALCOLOR( 0, 0, 0 ); + else + nSalColor = MAKE_SALCOLOR( 255, 255, 255 ); + return nSalColor; +} + void AquaSalGraphics::SetROPLineColor( SalROPColor nROPColor ) { + SetLineColor( ImplGetROPSalColor( nROPColor ) ); } // ----------------------------------------------------------------------- void AquaSalGraphics::SetROPFillColor( SalROPColor nROPColor ) { + SetFillColor( ImplGetROPSalColor( nROPColor ) ); } // ----------------------------------------------------------------------- void AquaSalGraphics::ImplDrawPixel( long nX, long nY, float pColor[] ) { - // save fill color and replace it with the desired color - float oldFillColor[4]; - memcpy( (void*) oldFillColor, (void*) mpFillColor, sizeof( oldFillColor ) ); - memcpy( (void*) mpFillColor, (void*) pColor, sizeof( oldFillColor ) ); - - if ( BeginGraphics() ) - { + if ( CheckContext() ) + { + CGContextSetFillColor( mrContext, pColor ); // draw 1x1 rect, there is no pixel drawing in Quartz - CGContextFillRect (mrContext, CGRectMake (nX, nY, 1, 1)); - - if( isOffscreenCopy() ) - CGContextFillRect (mrBitmapContext, CGRectMake (nX, nY, 1, 1)); - EndGraphics(); - } - - // restore fill color - memcpy( (void*) mpFillColor, (void*) oldFillColor, sizeof( oldFillColor ) ); - + CGContextFillRect( mrContext, CGRectMake (nX, nY, 1, 1) ); + CGContextSetFillColor( mrContext, mpFillColor ); + } } void AquaSalGraphics::drawPixel( long nX, long nY ) { // draw pixel with current line color - ImplDrawPixel( nX, nY, mpLineColor ); + ImplDrawPixel( nX, nY, mpLineColor ); + RefreshRect( nX, nY, 1, 1 ); } void AquaSalGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) @@ -387,6 +382,7 @@ }; ImplDrawPixel(nX, nY, pColor); + RefreshRect( nX, nY, 1, 1 ); } // ----------------------------------------------------------------------- @@ -401,35 +397,29 @@ void AquaSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) { - if ( BeginGraphics() ) - { + if ( CheckContext() ) implDrawLine( mrContext, nX1, nY1, nX2, nY2 ); - if( isOffscreenCopy() ) - implDrawLine( mrBitmapContext, nX1, nY1, nX2, nY2 ); - EndGraphics(); - } + + Rectangle aRefreshRect( nX1, nY1, nX2, nY2 ); + aRefreshRect.Justify(); + RefreshRect( aRefreshRect.Left(), aRefreshRect.Top(), aRefreshRect.GetWidth(), aRefreshRect.GetHeight() ); } // ----------------------------------------------------------------------- -static void implDrawRect( CGContextRef& xContext, long nX, long nY, long nWidth, long nHeight, bool bFilled ) -{ - if( bFilled ) - CGContextStrokeRect(xContext, CGRectMake (nX, nY, nWidth, nHeight)); - else - CGContextFillRect(xContext, CGRectMake (nX, nY, nWidth, nHeight)); -} - void AquaSalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight ) { - if ( BeginGraphics() ) + if ( CheckContext() ) { - const bool bFilled = IsBrushTransparent(); + CGRect aRect( CGRectMake(nX, nY, nWidth, nHeight) ); + + if( ! IsBrushTransparent() ) + CGContextFillRect( mrContext, aRect ); - implDrawRect( mrContext, nX, nY, nWidth, nHeight, bFilled ); - if( isOffscreenCopy() ) - implDrawRect( mrBitmapContext, nX, nY, nWidth, nHeight, bFilled ); - EndGraphics(); + if( ! IsPenTransparent() ) + CGContextStrokeRect( mrContext, aRect ); + + RefreshRect( nX, nY, nWidth, nHeight ); } } @@ -447,18 +437,16 @@ void AquaSalGraphics::drawPolyLine( ULONG nPoints, const SalPoint *pPtAry ) { - if( (nPoints > 1) && BeginGraphics() ) + if( (nPoints > 1) && CheckContext() ) { implDrawPolyLine( mrContext, nPoints, pPtAry ); - if( isOffscreenCopy() ) - implDrawPolyLine( mrBitmapContext, nPoints, pPtAry ); - EndGraphics(); + RefreshWindow(); } } // ----------------------------------------------------------------------- -static void ImplDrawPolygone( CGContextRef& xContext, ULONG nPoints, const SalPoint *pPtAry, float* pFillColor, float* pLineColor ) +static void ImplDrawPolygon( CGContextRef& xContext, ULONG nPoints, const SalPoint *pPtAry, float* pFillColor, float* pLineColor ) { CGContextBeginPath( xContext ); CGContextMoveToPoint( xContext, pPtAry->mnX, pPtAry->mnY ); @@ -478,18 +466,14 @@ void AquaSalGraphics::drawPolygon( ULONG nPoints, const SalPoint *pPtAry ) { - if( (nPoints > 1) && BeginGraphics() ) - { - ImplDrawPolygone( mrContext, nPoints, pPtAry, mpFillColor, mpLineColor ); - if( isOffscreenCopy() ) - ImplDrawPolygone( mrBitmapContext, nPoints, pPtAry, mpFillColor, mpLineColor ); - EndGraphics(); - } + if( (nPoints > 1) && CheckContext() ) + ImplDrawPolygon( mrContext, nPoints, pPtAry, mpFillColor, mpLineColor ); + RefreshWindow(); } // ----------------------------------------------------------------------- -static void ImplDrawPolyPolygone( CGContextRef& xContext, ULONG nPolyCount, const ULONG *pPoints, PCONSTSALPOINT *ppPtAry ) +static void ImplDrawPolyPolygon( CGContextRef& xContext, ULONG nPolyCount, const ULONG *pPoints, PCONSTSALPOINT *ppPtAry ) { CGContextBeginPath( xContext ); for( ULONG nPoly = 0; nPoly < nPolyCount; nPoly++ ) @@ -511,19 +495,15 @@ void AquaSalGraphics::drawPolyPolygon( ULONG nPolyCount, const ULONG *pPoints, PCONSTSALPOINT *ppPtAry ) { - if( nPolyCount && ( mpFillColor[3] > 0.0 ) && BeginGraphics() ) - { - ImplDrawPolyPolygone( mrContext, nPolyCount, pPoints, ppPtAry ); - if( isOffscreenCopy() ) - ImplDrawPolyPolygone( mrBitmapContext, nPolyCount, pPoints, ppPtAry ); - EndGraphics(); - } + if( nPolyCount && ( mpFillColor[3] > 0.0 ) && CheckContext() ) + ImplDrawPolyPolygon( mrContext, nPolyCount, pPoints, ppPtAry ); if( mpLineColor[3] > 0.0 ) { for( ULONG nPoly = 0; nPoly < nPolyCount; nPoly++ ) drawPolyLine( pPoints[nPoly], ppPtAry[nPoly] ); } + RefreshWindow(); } // ----------------------------------------------------------------------- @@ -604,18 +584,15 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap ) { const AquaSalBitmap& rBitmap = static_cast(rSalBitmap); - if ( BeginGraphics() ) + if( CheckContext() ) { CGImageRef xImage = const_cast< AquaSalBitmap& >( rBitmap ).CreateCroppedImage( (int)pPosAry->mnSrcX, (int)pPosAry->mnSrcY, (int)pPosAry->mnSrcWidth, (int)pPosAry->mnSrcHeight ); CGContextDrawImage(mrContext, CGRectMake ((int)pPosAry->mnDestX, (int)pPosAry->mnDestY, (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight), xImage); - if( isOffscreenCopy() ) - CGContextDrawImage(mrBitmapContext, CGRectMake ((int)pPosAry->mnDestX, (int)pPosAry->mnDestY, (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight), xImage); RefreshRect((int)pPosAry->mnDestX, (int)pPosAry->mnDestY, (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight); CGImageRelease(xImage); - EndGraphics(); } } @@ -633,7 +610,7 @@ { AquaSalBitmap& rBitmap = const_cast< AquaSalBitmap& >( static_cast(rSalBitmap) ); const AquaSalBitmap& rMask = static_cast(rTransparentBitmap); - if ( BeginGraphics() ) + if( CheckContext() ) { CGImageRef xMaskedImage( rBitmap.CreateWithMask( rMask, pPosAry->mnSrcX, pPosAry->mnSrcY, pPosAry->mnSrcWidth, pPosAry->mnSrcHeight ) ); if( xMaskedImage ) @@ -642,11 +619,9 @@ RefreshRect((int)pPosAry->mnDestX, (int)pPosAry->mnDestY, (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight); - if( isOffscreenCopy() ) - CGContextDrawImage(mrBitmapContext, CGRectMake (pPosAry->mnDestX, pPosAry->mnDestY, pPosAry->mnDestWidth, pPosAry->mnDestHeight), xMaskedImage); CGImageRelease(xMaskedImage); } - EndGraphics(); + RefreshWindow(); } } @@ -656,7 +631,7 @@ { const AquaSalBitmap& rBitmap = static_cast(rSalBitmap); - if ( BeginGraphics() ) + if ( CheckContext() ) { CGImageRef xImage = rBitmap.CreateColorMask( pPosAry->mnSrcX, pPosAry->mnSrcY, pPosAry->mnSrcWidth, pPosAry->mnSrcHeight, nMaskColor ); if( xImage ) @@ -665,11 +640,8 @@ RefreshRect((int)pPosAry->mnDestX, (int)pPosAry->mnDestY, (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight); - if( isOffscreenCopy() ) - CGContextDrawImage(mrBitmapContext, CGRectMake (pPosAry->mnDestX, pPosAry->mnDestY, pPosAry->mnDestWidth, pPosAry->mnDestHeight), xImage); CGImageRelease(xImage); } - EndGraphics(); } } @@ -684,10 +656,10 @@ nDX = labs( nDX ); nDY = labs( nDY ); - if( mrBitmapContext ) + if( mrContext ) { pBitmap = new AquaSalBitmap; - if( !pBitmap->Create( mrBitmapContext, nX, nY, nDX, nDY ) ) + if( !pBitmap->Create( mrContext, nX, nY, nDX, nDY, mrWindow == 0 ) ) { delete pBitmap; pBitmap = 0; @@ -712,7 +684,7 @@ void AquaSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) { - if ( BeginGraphics() ) + if ( CheckContext() ) { CGRect aCGRect = CGRectMake( nX, nY, nWidth, nHeight); CGContextSaveGState(mrContext); @@ -742,13 +714,8 @@ } CGContextRestoreGState( mrContext); - EndGraphics(); RefreshRect( nX, nY, nWidth, nHeight ); } - else - { - AquaLog( ">>>>> AquaSalGraphics::invert - failed BeginGraphics\n" ); - } } // ----------------------------------------------------------------------- @@ -756,7 +723,7 @@ void AquaSalGraphics::invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nSalFlags ) { CGPoint* CGpoints ; - if ( BeginGraphics() ) + if ( CheckContext() ) { CGContextSaveGState(mrContext); CGpoints = makeCGptArray(nPoints,pPtAry); @@ -786,9 +753,8 @@ } CGRect pRect = CGContextGetClipBoundingBox(mrContext); CGContextRestoreGState( mrContext); - EndGraphics(); - RefreshRect(pRect.origin.x, pRect.origin.y, pRect.size.width, pRect.size.height); delete [] CGpoints; + RefreshRect(pRect.origin.x, pRect.origin.y, pRect.size.width, pRect.size.height); } else { @@ -836,15 +802,10 @@ if(!xMaskedImage) return FALSE; - if ( BeginGraphics() ) + if ( CheckContext() ) { - CGContextDrawImage(mrContext, CGRectMake( rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight), xMaskedImage ); - - if( isOffscreenCopy() ) - CGContextDrawImage(mrBitmapContext, CGRectMake( rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight), xMaskedImage ); - - EndGraphics(); + RefreshRect(rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight); } CGImageRelease(xMaskedImage); @@ -856,7 +817,7 @@ bool AquaSalGraphics::drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) { - if ( BeginGraphics() ) + if ( CheckContext() ) { CGContextSaveGState(mrContext); float oldAlpha = mpFillColor[3]; // save the old alpha @@ -864,11 +825,10 @@ // and the OOo transparency value of 255 corresponds to the quartz transparency value of 0 mpFillColor[3] = ((float)255-nTransparency) / 255; // set the new alpha CGContextSetFillColor( mrContext, mpFillColor ); // using our color and new alpha + mpFillColor[3] = oldAlpha; // reset the old value CGContextFillRect( mrContext, CGRectMake(nX, nY, nWidth, nHeight) ); CGContextRestoreGState(mrContext); - EndGraphics(); RefreshRect(nX, nY, nWidth, nHeight); - mpFillColor[3] = oldAlpha; // reset the old value return TRUE; } else @@ -1052,7 +1012,7 @@ GetWindowPortBounds ( mrWindow, &windowBounds); return windowBounds.right - windowBounds.left; } - else if( mrBitmapContext ) + else if( mrContext ) { return CGBitmapContextGetWidth( mrContext ); } Index: vcl/aqua/source/gdi/salgdiutils.cxx =================================================================== RCS file: /cvs/gsl/vcl/aqua/source/gdi/salgdiutils.cxx,v retrieving revision 1.7.112.23 diff -u -r1.7.112.23 salgdiutils.cxx --- vcl/aqua/source/gdi/salgdiutils.cxx 24 May 2007 10:43:39 -0000 1.7.112.23 +++ vcl/aqua/source/gdi/salgdiutils.cxx 28 May 2007 15:45:41 -0000 @@ -77,101 +77,87 @@ mbVirDev = true; mrContext = xContext; - mrBitmapContext = xContext; + if( mrContext ) + { + CGContextSetFillColorSpace( mrContext, mrRGBColorSpace ); + CGContextSetStrokeColorSpace( mrContext, mrRGBColorSpace ); + CGContextSaveGState( mrContext ); + SetState(); + } } // ---------------------------------------------------------------------- -void AquaSalGraphics::InitContextForPainting( CGContextRef xContext ) +void AquaSalGraphics::SetState() { + CGContextRestoreGState( mrContext ); + CGContextSaveGState( mrContext ); // set up clipping area if( mrClippingPath ) { - CGContextBeginPath( xContext ); // discard any existing path - CGContextAddPath( xContext, mrClippingPath ); // set the current path to the clipping path - CGContextClip( xContext ); // use it for clipping + CGContextBeginPath( mrContext ); // discard any existing path + CGContextAddPath( mrContext, mrClippingPath ); // set the current path to the clipping path + CGContextClip( mrContext ); // use it for clipping } // set RGB colorspace and line and fill colors - CGContextSetFillColorSpace( xContext, mrRGBColorSpace ); - CGContextSetFillColor( xContext, mpFillColor ); - CGContextSetStrokeColorSpace( xContext, mrRGBColorSpace ); - CGContextSetStrokeColor( xContext, mpLineColor ); + CGContextSetFillColor( mrContext, mpFillColor ); + CGContextSetStrokeColor( mrContext, mpLineColor ); } // ---------------------------------------------------------------------- -bool AquaSalGraphics::BeginGraphics () +bool AquaSalGraphics::CheckContext() { - if( mnGraphics++ == 0 ) - { - if( mrWindow != NULL && mrContext == 0) - { - Rect windowBounds; - GetWindowPortBounds ( mrWindow, &windowBounds); - const unsigned int nWidth = windowBounds.right - windowBounds.left; - const unsigned int nHeight = windowBounds.bottom - windowBounds.top; - - if( mrBitmapContext ) - { - // check if window size changed and we need to create a new bitmap context - if( (CGBitmapContextGetWidth(mrBitmapContext) != nWidth) || (CGBitmapContextGetHeight(mrBitmapContext) != nHeight) ) - { - void* pBuffer = CGBitmapContextGetData(mrBitmapContext); - CFRelease( mrBitmapContext ); - mrBitmapContext = 0; - free( pBuffer ); - } - } - - if( !mrBitmapContext ) - { - void* pData = malloc( nWidth * 4 * nHeight ); - if (pData ) - { - mrBitmapContext = CGBitmapContextCreate( pData, nWidth, nHeight, 8, nWidth * 4, mrRGBColorSpace, kCGImageAlphaNoneSkipFirst ); - - if( !mrBitmapContext ) - { - free( pData ); - } - } - } - - SetPortWindowPort (mrWindow); - if( noErr == QDBeginCGContext (GetWindowPort (mrWindow), &mrContext)) - { -#if DEBUGLEVEL>1 - mbQDCG = true; -#endif - if( mrBitmapContext ) - { - CGContextSaveGState( mrBitmapContext ); - InitContextForPainting( mrBitmapContext ); - } - - CGContextTranslateCTM (mrContext, 0, nHeight); - CGContextScaleCTM (mrContext, 1.0, -1.0); - - InitContextForPainting( mrContext ); - - //RefreshWindow(); - } - } - else if( mbVirDev ) - { - CGContextSaveGState( mrBitmapContext ); - InitContextForPainting( mrBitmapContext ); - } - } + if( mrWindow != NULL ) + { + Rect windowBounds; + GetWindowPortBounds( mrWindow, &windowBounds ); + const unsigned int nWidth = windowBounds.right - windowBounds.left; + const unsigned int nHeight = windowBounds.bottom - windowBounds.top; + if( mrContext ) + { + // check if window size changed and we need to create a new bitmap context + if( (CGBitmapContextGetWidth(mrContext) != nWidth) || (CGBitmapContextGetHeight(mrContext) != nHeight) ) + { + void* pBuffer = CGBitmapContextGetData(mrContext); + CFRelease( mrContext ); + mrContext = 0; + rtl_freeMemory( pBuffer ); + } + } + + if( !mrContext ) + { + void* pData = rtl_allocateMemory( nWidth * 4 * nHeight ); + if (pData ) + { + mrContext = CGBitmapContextCreate( pData, nWidth, nHeight, 8, nWidth * 4, mrRGBColorSpace, kCGImageAlphaNoneSkipFirst ); + + if( !mrContext ) + { + rtl_freeMemory( pData ); + } + else + { + CGContextTranslateCTM( mrContext, 0, nHeight ); + CGContextScaleCTM( mrContext, 1.0, -1.0 ); + CGContextSetFillColorSpace( mrContext, mrRGBColorSpace ); + CGContextSetStrokeColorSpace( mrContext, mrRGBColorSpace ); + CGContextSaveGState( mrContext ); + SetState(); + } + } + } + } if( mrContext ) { return true; } else { - AquaLog("<<>> AquaSalGraphics::BeginGraphics() FAILED!!!!\n" ); + AquaLog("<<>> AquaSalGraphics::CheckContext() FAILED!!!!\n" ); return false; } } @@ -182,6 +168,9 @@ // Refresh windows content Rect myRect; GetWindowBounds(mrWindow, kWindowContentRgn, &myRect); + myRect.right -= myRect.left; + myRect.bottom -= myRect.top; + myRect.left = myRect.top = 0; InvalWindowRect(mrWindow, &myRect); } @@ -201,6 +190,13 @@ OSStatus retVal = HIViewSetNeedsDisplayInRect(mrView,&aHIRect,true); if (retVal) AquaLog( "FIXME: HIViewSetNeedsDisplayInRect returned %d (mrView is %p)\n", (int) retVal, mrView); + + Rect aRect; + aRect.left = (short)lX; + aRect.top = (short)lY; + aRect.right = (short)(lX + lWidth ); + aRect.bottom = (short)(lY + lHeight ); + InvalWindowRect(mrWindow, &aRect); } void AquaSalGraphics::RefreshRect(HIRect aHIRect) @@ -212,19 +208,14 @@ // Refresh windows content HIViewSetNeedsDisplayInRect(mrView,&aHIRect,true); + RefreshWindow(); } void AquaSalGraphics::Flush() { if( mbWindow ) { - bool bAcquireContext = (mrContext == NULL); - if( bAcquireContext ) - bAcquireContext = BeginGraphics(); - if( mrContext ) - CGContextFlush(mrContext); - if( bAcquireContext ) - EndGraphics(); + UpdateWindow(); } } @@ -246,68 +237,24 @@ // ----------------------------------------------------------------------- -bool AquaSalGraphics::EndGraphics () -{ - if( (mnGraphics > 0) && (--mnGraphics == 0) ) - { - if( mrContext != NULL && mrWindow != NULL ) - { -/* TODO: Optimize this so we synchronize only on user event? - if( !mnUpdateGraphicsEvent ) - mnUpdateGraphicsEvent = Application::PostUserEvent( LINK( this, AquaSalGraphics, UpdateGraphics), 0 ); -*/ - //RefreshWindow(); - //CGContextSynchronize(mrContext); - - QDEndCGContext (GetWindowPort(mrWindow), &mrContext); -#if DEBUGLEVEL>1 - mbQDCG = false; -#endif - mrContext = 0; - - if( mrBitmapContext ) - CGContextRestoreGState( mrBitmapContext ); - } - else if( mbVirDev ) - { - if( mrBitmapContext ) - CGContextRestoreGState( mrBitmapContext ); - } - } -#if DEBUGLEVEL>1 - if(mbQDCG) - AquaLog("-->%s unmatched QDEndCGContext\n",__func__); - else - AquaLog("-->%s OK\n",__func__); -#endif - return true; -} - -// ----------------------------------------------------------------------- - -/* -IMPL_LINK( AquaSalGraphics, UpdateGraphics, void*, EMPTYARG ) +void AquaSalGraphics::UpdateWindow() { - mnUpdateGraphicsEvent = 0; - if( mrContext != NULL && mrWindow != NULL ) { - SetPortWindowPort (mrWindow); - if( noErr == QDBeginCGContext (GetWindowPort (mrWindow), &mrWindowContext)) + SetPortWindowPort(mrWindow); + CGContextRef xWindowContext = 0; + if( noErr == QDBeginCGContext (GetWindowPort (mrWindow), &xWindowContext)) { Rect windowBounds; - GetWindowPortBounds ( mrWindow, &windowBounds); + GetWindowPortBounds( mrWindow, &windowBounds); CGImageRef xImage = CGBitmapContextCreateImage( mrContext ); - CGContextDrawImage(mrWindowContext, CGRectMake (windowBounds.left, windowBounds.top, windowBounds.right - windowBounds.left, windowBounds.bottom - windowBounds.top ), xImage); + CGContextDrawImage(xWindowContext, CGRectMake(windowBounds.left, windowBounds.top, windowBounds.right - windowBounds.left, windowBounds.bottom - windowBounds.top ), xImage); CGImageRelease(xImage); - CGContextSynchronize(mrWindowContext); - QDEndCGContext (GetWindowPort(mrWindow), &mrWindowContext); - mrWindowContext = 0; + CGContextFlush( xWindowContext ); + QDEndCGContext (GetWindowPort(mrWindow), &xWindowContext); } } - return 0; } -*/ // ----------------------------------------------------------------------- Index: vcl/aqua/source/gdi/salnativewidgets.cxx =================================================================== RCS file: /cvs/gsl/vcl/aqua/source/gdi/Attic/salnativewidgets.cxx,v retrieving revision 1.1.2.35 diff -u -r1.1.2.35 salnativewidgets.cxx --- vcl/aqua/source/gdi/salnativewidgets.cxx 26 May 2007 20:54:33 -0000 1.1.2.35 +++ vcl/aqua/source/gdi/salnativewidgets.cxx 28 May 2007 15:45:42 -0000 @@ -276,8 +276,10 @@ break; case CTRL_TOOLTIP: // ** TO DO + CHECK IF NEEDED ** - if( nPart == PART_ENTIRE_CONTROL ) + #if 0 + if( nPart == PART_ENTIRE_CONTROL ) // we don't currently support the tooltip return true; + #endif break; case CTRL_MENU_POPUP: @@ -473,27 +475,31 @@ const rtl::OUString& aCaption ) { AquaLog( "%s (%s, %s)\n", __func__, ImplDbgGetStringControlType(nType), ImplDbgGetStringControlPart(nPart)); - BOOL bOk = FALSE; - + BOOL bOK = FALSE; + + if( ! CheckContext() ) + return false; + Rectangle buttonRect = rControlRegion.GetBoundRect(); + RefreshRect( buttonRect.Left(), buttonRect.Top(), buttonRect.GetWidth(), buttonRect.GetHeight() ); HIRect rc; rc.origin.x = static_cast(buttonRect.Left()); rc.origin.y = static_cast(buttonRect.Top()); rc.size.width = static_cast(buttonRect.Right()) - static_cast(buttonRect.Left()); rc.size.height = static_cast(buttonRect.Bottom()) - static_cast(buttonRect.Top()); - + /** Scrollbar parts code equivalent ** - PART_BUTTON_UP 101 - PART_BUTTON_DOWN 102 + PART_BUTTON_UP 101 + PART_BUTTON_DOWN 102 PART_THUMB_VERT 211 PART_TRACK_VERT_UPPER 201 PART_TRACK_VERT_LOWER 203 - + PART_DRAW_BACKGROUND_HORZ 1000 PART_DRAW_BACKGROUND_VERT 1001 - **/ - + **/ + switch( nType ) { // [FIXME] wait for clipping before to add the new controls below @@ -502,80 +508,57 @@ case CTRL_TAB_BODY: case CTRL_TOOLBAR: { - if( BeginGraphics() ) + HIThemeMenuItemDrawInfo aMenuItemDrawInfo; + aMenuItemDrawInfo.version = 0; + aMenuItemDrawInfo.state = kThemeMenuActive; + aMenuItemDrawInfo.itemType = kThemeMenuItemHierBackground; + HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrContext,kHIThemeOrientationNormal,NULL); + bOK = true; + } + break; + + case CTRL_MENU_POPUP: + { + if ((nPart == PART_ENTIRE_CONTROL) || (nPart == PART_MENU_ITEM )|| (nPart == HAS_BACKGROUND_TEXTURE )) + { + HIThemeMenuDrawInfo aMenuInfo; + aMenuInfo.version = 0; + aMenuInfo.menuType = kThemeMenuTypePullDown; + + HIThemeMenuItemDrawInfo aMenuItemDrawInfo; + // the Aqua grey theme when the item is selected is drawn here. + aMenuItemDrawInfo.itemType = kThemeMenuItemPlain; + + if ((nPart == PART_MENU_ITEM )) { - HIThemeMenuItemDrawInfo aMenuItemDrawInfo; - aMenuItemDrawInfo.version = 0; + // the blue theme when the item is selected is drawn here. + aMenuItemDrawInfo.state = kThemeMenuSelected; + } + else + { + // normal color for non selected item aMenuItemDrawInfo.state = kThemeMenuActive; - aMenuItemDrawInfo.itemType = kThemeMenuItemHierBackground; - HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrContext,kHIThemeOrientationNormal,NULL); - if ( isOffscreenCopy() ) - HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrBitmapContext,kHIThemeOrientationNormal,NULL); - EndGraphics(); - return true; } - else - return false; + + // repaints the background of the pull down menu + HIThemeDrawMenuBackground(&rc,&aMenuInfo,mrContext,kHIThemeOrientationNormal); + + // repaints the item either blue (selected) and/or Aqua grey (active only) + HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrContext,kHIThemeOrientationNormal,&rc); + + bOK = true; + } } - break; - - case CTRL_MENU_POPUP: - { - if ((nPart == PART_ENTIRE_CONTROL) || (nPart == PART_MENU_ITEM )|| (nPart == HAS_BACKGROUND_TEXTURE )) - { - HIThemeMenuDrawInfo aMenuInfo; - aMenuInfo.version = 0; - aMenuInfo.menuType = kThemeMenuTypePullDown; - - HIThemeMenuItemDrawInfo aMenuItemDrawInfo; - // the Aqua grey theme when the item is selected is drawn here. - aMenuItemDrawInfo.itemType = kThemeMenuItemPlain; - - if ((nPart == PART_MENU_ITEM )) - { - // the blue theme when the item is selected is drawn here. - aMenuItemDrawInfo.state = kThemeMenuSelected; - } - else - { - // normal color for non selected item - aMenuItemDrawInfo.state = kThemeMenuActive; - } - - if( BeginGraphics() ) - { - - // repaints the background of the pull down menu - HIThemeDrawMenuBackground(&rc,&aMenuInfo,mrContext,kHIThemeOrientationNormal); - - // repaints the item either blue (selected) and/or Aqua grey (active only) - HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrContext,kHIThemeOrientationNormal,&rc); - - // Draw POPUP menu item to the offscreen bitmap - if ( isOffscreenCopy() ) - { - HIThemeDrawMenuBackground(&rc,&aMenuInfo,mrBitmapContext,kHIThemeOrientationNormal); - HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrBitmapContext,kHIThemeOrientationNormal,&rc); - } - - EndGraphics(); - return true; - } - else - return false; - } - } - break; - + break; + case CTRL_PUSHBUTTON: - { - + { // [ FIXME] : instead of use a value, vcl can retrieve corect values on the fly (to be implemented) int max_height = 20; - + // [FIXME]: for width, better use (native) text length to define width. How retrieve the text length ? int max_width = 68; - + // [FIXME] find a better criteria to differentiate several buttons who are square, but are not Bewel buttons. if((rc.size.width < 17) && (rc.size.width == rc.size.height ) ) { @@ -583,27 +566,18 @@ aBevelInfo.version = 0; aBevelInfo.kind = kThemeBevelButton; aBevelInfo.state = getState( nState ); - + ButtonValue aButtonValue = aValue.getTristateVal(); aBevelInfo.value = ImplGetButtonValue( aButtonValue ); - + aBevelInfo.adornment = (( nState & CTRL_STATE_DEFAULT ) != 0) ? - kThemeAdornmentDefault : - kThemeAdornmentNone; + kThemeAdornmentDefault : + kThemeAdornmentNone; if( (nState & CTRL_STATE_FOCUSED) != 0 ) - aBevelInfo.adornment |= kThemeAdornmentFocus; - - if( BeginGraphics() ) - { - HIThemeDrawButton( &rc, &aBevelInfo, mrContext, kHIThemeOrientationNormal, NULL ); - if ( isOffscreenCopy() ) - HIThemeDrawButton( &rc, &aBevelInfo, mrBitmapContext, kHIThemeOrientationNormal, NULL ); - EndGraphics(); - return true; - } - else - return false; - break; + aBevelInfo.adornment |= kThemeAdornmentFocus; + + HIThemeDrawButton( &rc, &aBevelInfo, mrContext, kHIThemeOrientationNormal, NULL ); + bOK = true; } else { @@ -619,132 +593,109 @@ // translation value must be an integrer int delta_y = floor((rc.size.height - max_height) / 2.0); rc.origin.y += delta_y + 1; - + // button height must be limited ( height value collected from OSXHIGuidelines ) rc.size.height = max_height; } - + aPushInfo.state = getState( nState ); - + aPushInfo.value = ImplGetButtonValue( aValue.getTristateVal() ); - + aPushInfo.adornment = (( nState & CTRL_STATE_DEFAULT ) != 0) ? - kThemeAdornmentDefault : - kThemeAdornmentNone; + kThemeAdornmentDefault : + kThemeAdornmentNone; if( (nState & CTRL_STATE_FOCUSED) != 0 ) - aPushInfo.adornment |= kThemeAdornmentFocus; - + aPushInfo.adornment |= kThemeAdornmentFocus; + // will show correct refresh once working aPushInfo.animation.time.current = CFAbsoluteTimeGetCurrent(); - - if( BeginGraphics() ) - { - HIThemeDrawButton( &rc, &aPushInfo, mrContext, kHIThemeOrientationNormal, NULL ); - if ( isOffscreenCopy() ) - HIThemeDrawButton( &rc, &aPushInfo, mrBitmapContext, kHIThemeOrientationInverted, NULL ); - EndGraphics(); - return true; - } - else - return false; + + HIThemeDrawButton( &rc, &aPushInfo, mrContext, kHIThemeOrientationNormal, NULL ); + bOK = true; } - break; } - } - - case CTRL_RADIOBUTTON: + } + break; + + case CTRL_RADIOBUTTON: case CTRL_CHECKBOX: { HIThemeButtonDrawInfo aInfo; switch( nType ) { - case CTRL_RADIOBUTTON: aInfo.kind = kThemeRadioButton; - break; - case CTRL_CHECKBOX: aInfo.kind = kThemeCheckBox; - break; + case CTRL_RADIOBUTTON: aInfo.kind = kThemeRadioButton; + break; + case CTRL_CHECKBOX: aInfo.kind = kThemeCheckBox; + break; } - + aInfo.state = getState( nState ); - + ButtonValue aButtonValue = aValue.getTristateVal(); aInfo.value = ImplGetButtonValue( aButtonValue ); - + aInfo.adornment = (( nState & CTRL_STATE_DEFAULT ) != 0) ? - kThemeAdornmentDefault : - kThemeAdornmentNone; + kThemeAdornmentDefault : + kThemeAdornmentNone; if( (nState & CTRL_STATE_FOCUSED) != 0 ) aInfo.adornment |= kThemeAdornmentFocus; - if( BeginGraphics() ) + HIThemeDrawButton( &rc, &aInfo, mrContext, kHIThemeOrientationNormal, NULL ); + bOK = true; + } + break; + + case CTRL_SCROLLBAR: + { + ScrollbarValue* pScrollbarVal = (ScrollbarValue *)(aValue.getOptionalVal()); + + if( nPart == PART_DRAW_BACKGROUND_VERT || + nPart == PART_DRAW_BACKGROUND_HORZ ) { - HIThemeDrawButton( &rc, &aInfo, mrContext, kHIThemeOrientationNormal, NULL ); - if ( isOffscreenCopy() ) - HIThemeDrawButton( &rc, &aInfo, mrBitmapContext, kHIThemeOrientationNormal, NULL ); - EndGraphics(); - return true; + HIThemeTrackDrawInfo aTrackDraw; + aTrackDraw.version = 0; + aTrackDraw.kind = kThemeMediumScrollBar; + aTrackDraw.bounds = rc; + aTrackDraw.min = pScrollbarVal->mnMin; + aTrackDraw.max = pScrollbarVal->mnMax - pScrollbarVal->mnVisibleSize; + aTrackDraw.value = pScrollbarVal->mnCur; + aTrackDraw.reserved = 0; + aTrackDraw.attributes = kThemeTrackShowThumb; + if( nPart == PART_DRAW_BACKGROUND_HORZ ) + aTrackDraw.attributes |= kThemeTrackHorizontal; + aTrackDraw.enableState = kThemeTrackActive; + + ScrollBarTrackInfo aScrollInfo; + aScrollInfo.viewsize = pScrollbarVal->mnVisibleSize; + aScrollInfo.pressState = 0; + + if ( pScrollbarVal->mnButton1State & CTRL_STATE_ENABLED ) + { + if ( pScrollbarVal->mnButton1State & CTRL_STATE_PRESSED ) + aScrollInfo.pressState = kThemeTopOutsideArrowPressed; + } + + if ( pScrollbarVal->mnButton2State & CTRL_STATE_ENABLED ) + { + if ( pScrollbarVal->mnButton2State & CTRL_STATE_PRESSED ) + aScrollInfo.pressState = kThemeBottomOutsideArrowPressed; + } + + if ( pScrollbarVal->mnThumbState & CTRL_STATE_ENABLED ) + { + if ( pScrollbarVal->mnThumbState & CTRL_STATE_PRESSED ) + aScrollInfo.pressState = kThemeThumbPressed; + } + + aTrackDraw.trackInfo.scrollbar = aScrollInfo; + + HIThemeDrawTrack( &aTrackDraw, NULL, mrContext, kHIThemeOrientationNormal ); + bOK = true; } - else - return false; } - break; - - case CTRL_SCROLLBAR: - { - ScrollbarValue* pScrollbarVal = (ScrollbarValue *)(aValue.getOptionalVal()); - - if( nPart == PART_DRAW_BACKGROUND_VERT || - nPart == PART_DRAW_BACKGROUND_HORZ ) - { - HIThemeTrackDrawInfo aTrackDraw; - aTrackDraw.version = 0; - aTrackDraw.kind = kThemeMediumScrollBar; - aTrackDraw.bounds = rc; - aTrackDraw.min = pScrollbarVal->mnMin; - aTrackDraw.max = pScrollbarVal->mnMax - pScrollbarVal->mnVisibleSize; - aTrackDraw.value = pScrollbarVal->mnCur; - aTrackDraw.reserved = 0; - aTrackDraw.attributes = kThemeTrackShowThumb; - if( nPart == PART_DRAW_BACKGROUND_HORZ ) - aTrackDraw.attributes |= kThemeTrackHorizontal; - aTrackDraw.enableState = kThemeTrackActive; - - ScrollBarTrackInfo aScrollInfo; - aScrollInfo.viewsize = pScrollbarVal->mnVisibleSize; - aScrollInfo.pressState = 0; - - if ( pScrollbarVal->mnButton1State & CTRL_STATE_ENABLED ) - { - if ( pScrollbarVal->mnButton1State & CTRL_STATE_PRESSED ) - aScrollInfo.pressState = kThemeTopOutsideArrowPressed; - } - - if ( pScrollbarVal->mnButton2State & CTRL_STATE_ENABLED ) - { - if ( pScrollbarVal->mnButton2State & CTRL_STATE_PRESSED ) - aScrollInfo.pressState = kThemeBottomOutsideArrowPressed; - } - - if ( pScrollbarVal->mnThumbState & CTRL_STATE_ENABLED ) - { - if ( pScrollbarVal->mnThumbState & CTRL_STATE_PRESSED ) - aScrollInfo.pressState = kThemeThumbPressed; - } - - aTrackDraw.trackInfo.scrollbar = aScrollInfo; - - if ( BeginGraphics() ) - { - HIThemeDrawTrack( &aTrackDraw, NULL, mrContext, kHIThemeOrientationNormal ); - if ( isOffscreenCopy() ) - HIThemeDrawTrack( &aTrackDraw, NULL, mrBitmapContext, kHIThemeOrientationNormal ); - EndGraphics(); - return true; - } - else - return false; - } - } } - return bOk; + + return bOK; } /* Index: vcl/aqua/source/window/salframe.cxx =================================================================== RCS file: /cvs/gsl/vcl/aqua/source/window/salframe.cxx,v retrieving revision 1.46.112.94 diff -u -r1.46.112.94 salframe.cxx --- vcl/aqua/source/window/salframe.cxx 28 May 2007 11:59:17 -0000 1.46.112.94 +++ vcl/aqua/source/window/salframe.cxx 28 May 2007 15:45:42 -0000 @@ -303,6 +303,17 @@ } } +void AquaSalFrame::SendPaintEvent() +{ + SalPaintEvent aPaintEvt; + aPaintEvt.mnBoundX = 0; + aPaintEvt.mnBoundY = 0; + aPaintEvt.mnBoundWidth = maGeometry.nWidth; + aPaintEvt.mnBoundHeight = maGeometry.nHeight; + + CallCallback(SALEVENT_PAINT, &aPaintEvt); +} + // ----------------------------------------------------------------------- void AquaSalFrame::Show(BOOL bVisible, BOOL bNoActivate) @@ -333,11 +344,9 @@ AquaSalMenu *pAquaSalMenu = (AquaSalMenu *) mpMenu; SetRootMenu(pAquaSalMenu->mrMenuRef); } - if( ! mbShown ) - { - Rect aRect = { 0, 0, mnWidth, mnHeight }; - InvalWindowRect( mrWindow, &aRect ); - } + + // trigger filling out backbuffer + SendPaintEvent(); } else HideWindow(mrWindow); @@ -1442,22 +1451,10 @@ return noErr; AquaLog( "received full paint event\n"); - - Rect contentBounds; - GetWindowBounds( pSalFrame->mrWindow, kWindowContentRgn, &contentBounds ); - - SalPaintEvent aPaintEvt; - aPaintEvt.mnBoundX = 0; - aPaintEvt.mnBoundY = 0; - aPaintEvt.mnBoundWidth = pSalFrame->mnWidth; - aPaintEvt.mnBoundHeight = pSalFrame->mnHeight; - - AquaLog( "Full paint event: (%ld, %ld, %ld, %ld)\n", - aPaintEvt.mnBoundX, aPaintEvt.mnBoundY, - aPaintEvt.mnBoundWidth, aPaintEvt.mnBoundHeight); - - pSalFrame->CallCallback(SALEVENT_PAINT, &aPaintEvt); + if( pSalFrame->mpGraphics ) + pSalFrame->mpGraphics->UpdateWindow(); + return noErr; } @@ -1470,21 +1467,9 @@ if( !AquaSalFrame::isAlive( pSalFrame ) ) return noErr; - Rect portBounds; - GetWindowBounds (pSalFrame->mrWindow, kWindowContentRgn, &portBounds ); - - SalPaintEvent aPaintEvt; - aPaintEvt.mnBoundX = 0; - aPaintEvt.mnBoundY = 0; - aPaintEvt.mnBoundWidth = pSalFrame->mnWidth; - aPaintEvt.mnBoundHeight = pSalFrame->mnHeight; - - AquaLog( "Paint event: (%ld, %ld, %ld, %ld)\n", - aPaintEvt.mnBoundX, aPaintEvt.mnBoundY, - aPaintEvt.mnBoundWidth, aPaintEvt.mnBoundHeight); - - pSalFrame->CallCallback(SALEVENT_PAINT, &aPaintEvt); - + if( pSalFrame->mpGraphics ) + pSalFrame->mpGraphics->UpdateWindow(); + return noErr; } @@ -1509,6 +1494,10 @@ return noErr; pSalFrame->mpSalInstance->StopForceDispatchingPaintEvents(); + + pSalFrame->UpdateFrameGeometry(); + pSalFrame->SendPaintEvent(); + return noErr; }