diff options
Diffstat (limited to 'vcl/aqua/source/gdi/salgdi.cxx')
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 142 |
1 files changed, 105 insertions, 37 deletions
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index 661eb64b83ce..f8410a47dfd6 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -346,64 +346,80 @@ void AquaSalGraphics::updateResolution() void AquaSalGraphics::initResolution( NSWindow* pWin ) { - NSScreen* pScreen = nil; + // #i100617# read DPI only once; there is some kind of weird caching going on + // if the main screen changes + // FIXME: this is really unfortunate and needs to be investigated - /* #i91301# - many woes went into the try to have different resolutions - on different screens. The result of these trials is that OOo is not ready - for that yet, vcl and applications would need to be adapted. + SalData* pSalData = GetSalData(); + if( pSalData->mnDPIX == 0 || pSalData->mnDPIY == 0 ) + { + NSScreen* pScreen = nil; - Unfortunately this is not possible in the 3.0 timeframe. - So let's stay with one resolution for all Windows and VirtualDevices - which is the resolution of the main screen + /* #i91301# + many woes went into the try to have different resolutions + on different screens. The result of these trials is that OOo is not ready + for that yet, vcl and applications would need to be adapted. - This of course also means that measurements are exact only on the main screen. - For activating different resolutions again just comment out the two lines below. + Unfortunately this is not possible in the 3.0 timeframe. + So let's stay with one resolution for all Windows and VirtualDevices + which is the resolution of the main screen - if( pWin ) + This of course also means that measurements are exact only on the main screen. + For activating different resolutions again just comment out the two lines below. + + if( pWin ) pScreen = [pWin screen]; - */ - if( pScreen == nil ) - { - NSArray* pScreens = [NSScreen screens]; - if( pScreens ) - pScreen = [pScreens objectAtIndex: 0]; - } + */ + if( pScreen == nil ) + { + NSArray* pScreens = [NSScreen screens]; + if( pScreens ) + pScreen = [pScreens objectAtIndex: 0]; + } - mnRealDPIX = mnRealDPIY = 96; - if( pScreen ) - { - NSDictionary* pDev = [pScreen deviceDescription]; - if( pDev ) + mnRealDPIX = mnRealDPIY = 96; + if( pScreen ) { - NSNumber* pVal = [pDev objectForKey: @"NSScreenNumber"]; - if( pVal ) + NSDictionary* pDev = [pScreen deviceDescription]; + if( pDev ) { - // FIXME: casting a long to CGDirectDisplayID is evil, but - // Apple suggest to do it this way - const CGDirectDisplayID nDisplayID = (CGDirectDisplayID)[pVal longValue]; - const CGSize aSize = CGDisplayScreenSize( nDisplayID ); // => result is in millimeters - mnRealDPIX = static_cast<long>((CGDisplayPixelsWide( nDisplayID ) * 25.4) / aSize.width); - mnRealDPIY = static_cast<long>((CGDisplayPixelsHigh( nDisplayID ) * 25.4) / aSize.height); + NSNumber* pVal = [pDev objectForKey: @"NSScreenNumber"]; + if( pVal ) + { + // FIXME: casting a long to CGDirectDisplayID is evil, but + // Apple suggest to do it this way + const CGDirectDisplayID nDisplayID = (CGDirectDisplayID)[pVal longValue]; + const CGSize aSize = CGDisplayScreenSize( nDisplayID ); // => result is in millimeters + mnRealDPIX = static_cast<long>((CGDisplayPixelsWide( nDisplayID ) * 25.4) / aSize.width); + mnRealDPIY = static_cast<long>((CGDisplayPixelsHigh( nDisplayID ) * 25.4) / aSize.height); + } + else + { + DBG_ERROR( "no resolution found in device description" ); + } } else { - DBG_ERROR( "no resolution found in device description" ); + DBG_ERROR( "no device description" ); } } else { - DBG_ERROR( "no device description" ); + DBG_ERROR( "no screen found" ); } + + // for OSX any anisotropy reported for the display resolution is best ignored (e.g. TripleHead2Go) + mnRealDPIX = mnRealDPIY = (mnRealDPIX + mnRealDPIY + 1) / 2; + + pSalData->mnDPIX = mnRealDPIX; + pSalData->mnDPIY = mnRealDPIY; } else { - DBG_ERROR( "no screen found" ); + mnRealDPIX = pSalData->mnDPIX; + mnRealDPIY = pSalData->mnDPIY; } - // for OSX any anisotropy reported for the display resolution is best ignored (e.g. TripleHead2Go) - mnRealDPIX = mnRealDPIY = (mnRealDPIX + mnRealDPIY + 1) / 2; - mfFakeDPIScale = 1.0; } @@ -416,6 +432,16 @@ void AquaSalGraphics::GetResolution( long& rDPIX, long& rDPIY ) rDPIY = static_cast<long>(mfFakeDPIScale * mnRealDPIY); } +void AquaSalGraphics::copyResolution( AquaSalGraphics& rGraphics ) +{ + if( !rGraphics.mnRealDPIY && rGraphics.mbWindow && rGraphics.mpFrame ) + rGraphics.initResolution( rGraphics.mpFrame->mpWindow ); + + mnRealDPIX = rGraphics.mnRealDPIX; + mnRealDPIY = rGraphics.mnRealDPIY; + mfFakeDPIScale = rGraphics.mfFakeDPIScale; +} + // ----------------------------------------------------------------------- USHORT AquaSalGraphics::GetBitCount() @@ -948,6 +974,11 @@ bool AquaSalGraphics::drawPolyLine( const ::basegfx::B2DPolygon& rPolyLine, if( rLineWidths.getX() != rLineWidths.getY() ) return false; + // #i101491# Aqua does not support B2DLINEJOIN_NONE; return false to use + // the fallback (own geometry preparation) + if(basegfx::B2DLINEJOIN_NONE == eLineJoin) + return false; + // setup line attributes CGLineJoin aCGLineJoin = kCGLineJoinMiter; switch( eLineJoin ) { @@ -2298,6 +2329,43 @@ void AquaSalGraphics::FreeEmbedFontData( const void* pData, long nDataLen ) // ----------------------------------------------------------------------- +SystemFontData AquaSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const +{ + SystemFontData aSysFontData; + OSStatus err; + aSysFontData.nSize = sizeof( SystemFontData ); + + // NOTE: Native ATSU font fallbacks are used, not the VCL fallbacks. + ATSUFontID fontId; + err = ATSUGetAttribute( maATSUStyle, kATSUFontTag, sizeof(fontId), &fontId, 0 ); + if (err) fontId = 0; + aSysFontData.aATSUFontID = (void *) fontId; + + Boolean bFbold; + err = ATSUGetAttribute( maATSUStyle, kATSUQDBoldfaceTag, sizeof(bFbold), &bFbold, 0 ); + if (err) bFbold = FALSE; + aSysFontData.bFakeBold = (bool) bFbold; + + Boolean bFItalic; + err = ATSUGetAttribute( maATSUStyle, kATSUQDItalicTag, sizeof(bFItalic), &bFItalic, 0 ); + if (err) bFItalic = FALSE; + aSysFontData.bFakeItalic = (bool) bFItalic; + + ATSUVerticalCharacterType aVerticalCharacterType; + err = ATSUGetAttribute( maATSUStyle, kATSUVerticalCharacterTag, sizeof(aVerticalCharacterType), &aVerticalCharacterType, 0 ); + if (!err && aVerticalCharacterType == kATSUStronglyVertical) { + aSysFontData.bVerticalCharacterType = true; + } else { + aSysFontData.bVerticalCharacterType = false; + } + + aSysFontData.bAntialias = !mbNonAntialiasedText; + + return aSysFontData; +} + +// ----------------------------------------------------------------------- + SystemGraphicsData AquaSalGraphics::GetGraphicsData() const { SystemGraphicsData aRes; |