diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-08-18 12:29:05 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-08-18 12:29:05 +0000 |
commit | c020497e35ced754dbaf83e9e4ee71ee79f80e2b (patch) | |
tree | 41b8864f2c78faac9a3bc1974aca3a833079d463 /vcl | |
parent | 42973237340a8abbb4cb2a79257742878efa2763 (diff) |
INTEGRATION: CWS aquaupdateicon (1.52.40); FILE MERGED
2008/07/31 13:55:07 pl 1.52.40.2: #i92043# refactor for tiger, which has problems with NSStatusItems at exit, so use one and only one
2008/07/29 17:39:19 pl 1.52.40.1: #i92043# add: native menubar add buttons
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/aqua/source/app/salinst.cxx | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/vcl/aqua/source/app/salinst.cxx b/vcl/aqua/source/app/salinst.cxx index 2fdb6883dc5f..d1a8b27369fe 100644 --- a/vcl/aqua/source/app/salinst.cxx +++ b/vcl/aqua/source/app/salinst.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salinst.cxx,v $ - * $Revision: 1.53 $ + * $Revision: 1.54 $ * * This file is part of OpenOffice.org. * @@ -42,6 +42,7 @@ #include "vcl/salimestatus.hxx" #include "vcl/window.hxx" #include "vcl/timer.hxx" +#include "vcl/impbmp.hxx" #include "saldata.hxx" #include "salinst.h" @@ -258,6 +259,11 @@ const ::rtl::OUString& SalGetDesktopEnvironment() void DeInitSalData() { SalData *pSalData = GetSalData(); + if( pSalData->mpStatusItem ) + { + [pSalData->mpStatusItem release]; + pSalData->mpStatusItem = nil; + } delete pSalData; SetSalData( NULL ); } @@ -1044,3 +1050,77 @@ NSString* CreateNSString( const rtl::OUString& rStr ) { return [[NSString alloc] initWithCharacters: rStr.getStr() length: rStr.getLength()]; } + +CGImageRef CreateCGImage( const Image& rImage ) +{ + BitmapEx aBmpEx( rImage.GetBitmapEx() ); + Bitmap aBmp( aBmpEx.GetBitmap() ); + + if( ! aBmp || ! aBmp.ImplGetImpBitmap() ) + return NULL; + + // simple case, no transparency + AquaSalBitmap* pSalBmp = static_cast<AquaSalBitmap*>(aBmp.ImplGetImpBitmap()->ImplGetSalBitmap()); + + if( ! pSalBmp ) + return NULL; + + CGImageRef xImage = NULL; + if( ! (aBmpEx.IsAlpha() || aBmpEx.IsTransparent() ) ) + xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight ); + else if( aBmpEx.IsAlpha() ) + { + AlphaMask aAlphaMask( aBmpEx.GetAlpha() ); + Bitmap aMask( aAlphaMask.GetBitmap() ); + AquaSalBitmap* pMaskBmp = static_cast<AquaSalBitmap*>(aMask.ImplGetImpBitmap()->ImplGetSalBitmap()); + if( pMaskBmp ) + xImage = pSalBmp->CreateWithMask( *pMaskBmp, 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight ); + else + xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight ); + } + else if( aBmpEx.GetTransparentType() == TRANSPARENT_BITMAP ) + { + Bitmap aMask( aBmpEx.GetMask() ); + AquaSalBitmap* pMaskBmp = static_cast<AquaSalBitmap*>(aMask.ImplGetImpBitmap()->ImplGetSalBitmap()); + if( pMaskBmp ) + xImage = pSalBmp->CreateWithMask( *pMaskBmp, 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight ); + else + xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight ); + } + else if( aBmpEx.GetTransparentType() == TRANSPARENT_COLOR ) + { + Color aTransColor( aBmpEx.GetTransparentColor() ); + SalColor nTransColor = MAKE_SALCOLOR( aTransColor.GetRed(), aTransColor.GetGreen(), aTransColor.GetBlue() ); + xImage = pSalBmp->CreateColorMask( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight, nTransColor ); + } + + return xImage; +} + +NSImage* CreateNSImage( const Image& rImage ) +{ + CGImageRef xImage = CreateCGImage( rImage ); + + if( ! xImage ) + return nil; + + Size aSize( rImage.GetSizePixel() ); + NSImage* pImage = [[NSImage alloc] initWithSize: NSMakeSize( aSize.Width(), aSize.Height() )]; + if( pImage ) + { + [pImage setFlipped: YES]; + [pImage lockFocus]; + + NSGraphicsContext* pContext = [NSGraphicsContext currentContext]; + CGContextRef rCGContext = reinterpret_cast<CGContextRef>([pContext graphicsPort]); + + const CGRect aDstRect = { {0, 0}, { aSize.Width(), aSize.Height() } }; + CGContextDrawImage( rCGContext, aDstRect, xImage ); + + [pImage unlockFocus]; + } + + CGImageRelease( xImage ); + + return pImage; +} |