diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-07-18 08:45:32 +0200 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-07-20 22:10:59 +0200 |
commit | 8e21a02520cbd2fdc09df1ca675f4aa46a02d5f6 (patch) | |
tree | f19907a12be55d8fdd4fc3560ded681dc3216fa0 /vcl | |
parent | 2b8528a2745bec7909bfe2265d6110a9964eef47 (diff) |
vcl: add floating equivalent for MapRes
Change-Id: I165e403d2834d341f7da7a280859afccb995a3bb
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/outdev/map.cxx | 52 | ||||
-rw-r--r-- | vcl/source/outdev/outdev.cxx | 4 |
2 files changed, 55 insertions, 1 deletions
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index beb9424809da..eb82156c8e4f 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -149,6 +149,8 @@ static void ImplCalcBigIntThreshold( long nDPIX, long nDPIY, static void ImplCalcMapResolution( const MapMode& rMapMode, long nDPIX, long nDPIY, ImplMapRes& rMapRes ) { + rMapRes.mfScaleX = 1.0; + rMapRes.mfScaleY = 1.0; switch ( rMapMode.GetMapUnit() ) { case MAP_RELATIVE: @@ -254,9 +256,18 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, { rMapRes.mnMapOfsX = aOrigin.X(); rMapRes.mnMapOfsY = aOrigin.Y(); + rMapRes.mfOffsetX = aOrigin.X(); + rMapRes.mfOffsetY = aOrigin.Y(); } else { + rMapRes.mfOffsetX *= aScaleX.GetDenominator(); + rMapRes.mfOffsetX /= aScaleX.GetNumerator(); + rMapRes.mfOffsetX += aOrigin.X(); + rMapRes.mfOffsetY *= aScaleY.GetDenominator(); + rMapRes.mfOffsetY /= aScaleY.GetNumerator(); + rMapRes.mfOffsetY += aOrigin.Y(); + BigInt aX( rMapRes.mnMapOfsX ); aX *= BigInt( aScaleX.GetDenominator() ); if ( rMapRes.mnMapOfsX >= 0 ) @@ -295,6 +306,11 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, rMapRes.mnMapOfsY = (long)aY + aOrigin.Y(); } + rMapRes.mfScaleX *= (double)rMapRes.mnMapScNumX * (double)aScaleX.GetNumerator() / + ((double)rMapRes.mnMapScDenomX * (double)aScaleX.GetDenominator()); + rMapRes.mfScaleY *= (double)rMapRes.mnMapScNumY * (double)aScaleY.GetNumerator() / + ((double)rMapRes.mnMapScDenomY * (double)aScaleY.GetDenominator()); + // calculate scaling factor according to MapMode // aTemp? = rMapRes.mnMapSc? * aScale? Fraction aTempX = ImplMakeFraction( rMapRes.mnMapScNumX, @@ -351,7 +367,6 @@ void OutputDevice::ImplInvalidateViewTransform() } } - static long ImplLogicToPixel( long n, long nDPI, long nMapNum, long nMapDenom, long nThres ) { @@ -719,6 +734,8 @@ void OutputDevice::SetMapMode( const MapMode& rNewMapMode ) Point aOrigin = rNewMapMode.GetOrigin(); maMapRes.mnMapOfsX = aOrigin.X(); maMapRes.mnMapOfsY = aOrigin.Y(); + maMapRes.mfOffsetX = aOrigin.X(); + maMapRes.mfOffsetY = aOrigin.Y(); maMapMode = rNewMapMode; // #i75163# @@ -734,6 +751,10 @@ void OutputDevice::SetMapMode( const MapMode& rNewMapMode ) maMapRes.mnMapScDenomY = mnDPIY; maMapRes.mnMapOfsX = 0; maMapRes.mnMapOfsY = 0; + maMapRes.mfOffsetX = 0.0; + maMapRes.mfOffsetY = 0.0; + maMapRes.mfScaleX = (double)1/(double)mnDPIX; + maMapRes.mfScaleY = (double)1/(double)mnDPIY; } // calculate new MapMode-resolution @@ -2112,4 +2133,33 @@ long Window::ImplLogicUnitToPixelY( long nY, MapUnit eUnit ) return nY; } + +DeviceCoordinate OutputDevice::LogicWidthToDeviceCoordinate( long nWidth ) const +{ +#if VCL_FLOAT_DEVICE_PIXEL + return (double)nWidth * maMapRes.mfScaleX * mnDPIX; +#else + if ( !mbMap ) + return nWidth; + + return ImplLogicToPixel( nWidth, mnDPIX, + maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, + maThresRes.mnThresLogToPixX ); +#endif +} + +DeviceCoordinate OutputDevice::LogicHeightToDeviceCoordinate( long nHeight ) const +{ +#if VCL_FLOAT_DEVICE_PIXEL + return (double)nHeight * maMapRes.mfScaleY * mnDPIY; +#else + if ( !mbMap ) + return nHeight; + + return ImplLogicToPixel( nHeight, mnDPIY, + maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, + maThresRes.mnThresLogToPixY ); +#endif +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index aa2cbc930f36..8717246d495c 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -159,6 +159,10 @@ OutputDevice::OutputDevice() : maMapRes.mnMapScNumY = 1; maMapRes.mnMapScDenomX = 1; maMapRes.mnMapScDenomY = 1; + maMapRes.mfOffsetX = 0.0; + maMapRes.mfOffsetY = 0.0; + maMapRes.mfScaleX = 1.0; + maMapRes.mfScaleY = 1.0; // struct ImplThresholdRes maThresRes.mnThresLogToPixX = 0; maThresRes.mnThresLogToPixY = 0; |