home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 23.8 KB | 852 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: SLMaping.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWMAPING_H
- #include "SLMaping.h"
- #endif
-
- #ifndef PRGDEV_H
- #include "PRGDev.h"
- #endif
-
- #ifndef SLREGION_H
- #include "SLRegion.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FW_Graphics
- #endif
-
- //========================================================================================
- // Local prototypes
- //========================================================================================
-
- static void ClearCache(FW_SMapping& mapping, Environment* ev);
-
- static void CheckCache(
- const FW_SMapping& mapping,
- Environment* ev,
- FW_HGDevice device,
- ODTransform* transform);
-
- static void CalcCache(
- FW_SMapping& mapping,
- Environment* ev,
- FW_HGDevice device,
- ODTransform* transform);
-
- static void CalcOriginOffset(
- FW_SMapping& mapping,
- Environment* ev,
- FW_HGDevice device);
-
- //========================================================================================
- // Mapping functions
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_Init
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_Init(FW_SMapping& mapping, FW_EMappingModes mappingMode)
- {
- // No try block necessary - Do not throw
- mapping.fMappingMode = mappingMode;
- mapping.fRecentDevice = NULL;
- mapping.fRecentODTransform = NULL;
- mapping.fLogicalToContentTransform = NULL;
- mapping.fContentToDeviceTransform = NULL;
- mapping.fLogicalToDeviceTransform = NULL;
- mapping.fHaveTransforms = FALSE;
-
- mapping.fDeviceOrg.x =
- mapping.fDeviceOrg.y =
- mapping.fLogicalOrg.x =
- mapping.fLogicalOrg.y = FW_kFixed0;
-
- mapping.fLogicalExtent.x =
- mapping.fLogicalExtent.y =
- mapping.fDeviceExtent.x =
- mapping.fDeviceExtent.y = FW_kFixedPos1;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_InitFromCopy
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_InitFromCopy(FW_SMapping& mapping, const FW_SMapping& mapping2)
- {
- // No try block necessary - Do not throw
- mapping.fMappingMode = mapping2.fMappingMode;
- mapping.fRecentDevice = NULL;
- mapping.fRecentODTransform = NULL;
- mapping.fLogicalToContentTransform = NULL;
- mapping.fContentToDeviceTransform = NULL;
- mapping.fLogicalToDeviceTransform = NULL;
- mapping.fHaveTransforms = FALSE;
-
- mapping.fDeviceOrg = mapping2.fDeviceOrg;
- mapping.fLogicalOrg = mapping2.fLogicalOrg;
-
- mapping.fLogicalExtent = mapping2.fLogicalExtent;
- mapping.fDeviceExtent = mapping2.fDeviceExtent;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_Term
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_Term(FW_SMapping& mapping, Environment* ev)
- {
- // No try block necessary - Do not throw
- ClearCache(mapping, ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_Reset
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_Reset(FW_SMapping& mapping, Environment* ev)
- {
- // No try block necessary - Do not throw
- ClearCache(mapping, ev);
-
- mapping.fMappingMode = FW_kPoint;
-
- mapping.fLogicalExtent.x =
- mapping.fLogicalExtent.y =
- mapping.fDeviceExtent.x =
- mapping.fDeviceExtent.y = FW_kFixedPos1;
-
- mapping.fDeviceOrg = FW_kZeroPoint;
- mapping.fLogicalOrg = FW_kZeroPoint;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_SetMode
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_SetMode(FW_SMapping& mapping, Environment* ev, FW_EMappingModes newMappingMode)
- {
- // No try block necessary - Do not throw
- mapping.fMappingMode = newMappingMode;
-
- if (mapping.fMappingMode == FW_kCustomConstrained)
- FW_PrivMapping_SetExtents(mapping, ev, mapping.fLogicalExtent, mapping.fDeviceExtent); // already calls ClearCache
- else
- ClearCache(mapping, ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_SetExtents
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_SetExtents(
- FW_SMapping& mapping,
- Environment* ev,
- const FW_SPoint& logicalExtent,
- const FW_SPoint& deviceExtent)
- {
- // No try block necessary - Do not throw
- mapping.fLogicalExtent = logicalExtent;
- mapping.fDeviceExtent = deviceExtent;
- ClearCache(mapping, ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_SetDeviceOrigin
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_SetDeviceOrigin(FW_SMapping& mapping, Environment* ev, FW_Fixed x, FW_Fixed y)
- {
- // No try block necessary - Do not throw
- mapping.fDeviceOrg.x = x;
- mapping.fDeviceOrg.y = y;
- ClearCache(mapping, ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_SetLogicalOrigin
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_SetLogicalOrigin(FW_SMapping& mapping, Environment* ev, FW_Fixed x, FW_Fixed y)
- {
- // No try block necessary - Do not throw
- mapping.fLogicalOrg.x = x;
- mapping.fLogicalOrg.y = y;
- ClearCache(mapping, ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivMapping_GetOriginOffset
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_GetOriginOffset(
- const FW_SMapping& mapping,
- Environment* ev,
- FW_PlatformPoint& offset,
- FW_HGDevice device,
- ODTransform* transform)
- {
- // No try block necessary - Do not throw
- CheckCache(mapping, ev, device, transform);
- offset = mapping.fOriginOffset;
- }
-
- //========================================================================================
- // Local helpers
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // ClearCache
- //----------------------------------------------------------------------------------------
-
- static void ClearCache(FW_SMapping& mapping, Environment* ev)
- {
- // Will not throw
- FW_SOM_TRY
- {
- if (mapping.fRecentDevice != NULL)
- {
- mapping.fRecentDevice->Release();
- mapping.fRecentDevice = NULL;
- }
-
- if (mapping.fRecentODTransform != NULL)
- {
- mapping.fRecentODTransform->Release(ev);
- mapping.fRecentODTransform = NULL;
- }
-
- if (mapping.fLogicalToContentTransform != NULL)
- {
- mapping.fLogicalToContentTransform->Release(ev);
- mapping.fLogicalToContentTransform = NULL;
- }
-
- if (mapping.fContentToDeviceTransform != NULL)
- {
- mapping.fContentToDeviceTransform->Release(ev);
- mapping.fContentToDeviceTransform = NULL;
- }
-
- if (mapping.fLogicalToDeviceTransform != NULL)
- {
- mapping.fLogicalToDeviceTransform->Release(ev);
- mapping.fLogicalToDeviceTransform = NULL;
- }
-
- mapping.fHaveTransforms = FALSE;
- }
- FW_SOM_CATCH
- }
-
- //----------------------------------------------------------------------------------------
- // CheckCache
- //----------------------------------------------------------------------------------------
-
- static void CheckCache(const FW_SMapping& mapping,
- Environment* ev,
- FW_HGDevice device,
- ODTransform* transform)
- {
- // No try block necessary - Do not throw
- if (!mapping.fHaveTransforms || device != mapping.fRecentDevice || transform != mapping.fRecentODTransform)
- CalcCache((FW_SMapping&)mapping, ev, device, transform);
-
- FW_ASSERT(mapping.fHaveTransforms);
- FW_ASSERT(mapping.fLogicalToContentTransform != NULL);
- FW_ASSERT(mapping.fContentToDeviceTransform != NULL);
- FW_ASSERT(mapping.fLogicalToDeviceTransform != NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // CalcCache
- //----------------------------------------------------------------------------------------
-
- static void CalcCache(FW_SMapping& mapping,
- Environment* ev,
- FW_HGDevice device,
- ODTransform* transform)
- {
- // #define LOG_TRANSFORMS
-
- FW_SOM_TRY
- {
- ClearCache(mapping, ev);
-
- mapping.fRecentDevice = device;
- if(mapping.fRecentDevice != NULL)
- {
- mapping.fRecentDevice->Acquire();
- }
-
- mapping.fRecentODTransform = transform;
- if(mapping.fRecentODTransform != NULL)
- {
- #ifdef FW_BUILD_WIN
- mapping.fRecentODTransform->IncrementRefCount(ev);
- #endif
- #ifdef FW_BUILD_MAC
- mapping.fRecentODTransform->Acquire(ev);
- #endif
- }
-
- ODCanvas* canvas = device != NULL ? device->GetODCanvas() : NULL;
-
- FW_CPoint resScreen;
-
- #ifdef FW_BUILD_WIN
- HDC hDC = ::GetDC(NULL);
-
- resScreen.x = FW_IntToFixed(::GetDeviceCaps(hDC, LOGPIXELSX));
- resScreen.y = FW_IntToFixed(::GetDeviceCaps(hDC, LOGPIXELSY));
-
- ::ReleaseDC(NULL, hDC);
-
- BOOL bWinIsPrinting = canvas != NULL ? canvas->HasPlatformPrintJob(ev, kODWindows) : FALSE;
- #endif
- #ifdef FW_BUILD_MAC
- resScreen.Set(FW_kFixed72, FW_kFixed72);
- #endif
-
- FW_CPoint resDevice = device == NULL ? resScreen : device->GetResolution();
-
- FW_CPoint ptLogicalToContentOffset(-mapping.fLogicalOrg.x, -mapping.fLogicalOrg.y);
- FW_CPoint ptLogicalToContentScaling;
- FW_CPoint resScale;
-
- switch (mapping.fMappingMode)
- {
- case FW_kCentimeter:
- ptLogicalToContentScaling.x = FW_DoubleToFixed(28.346456691);
- ptLogicalToContentScaling.y = FW_DoubleToFixed(28.346456691);
- break;
-
- case FW_kInch:
- ptLogicalToContentScaling.x = FW_kFixed72;
- ptLogicalToContentScaling.y = FW_kFixed72;
- break;
-
- case FW_kPoint:
- // On the Mac:
- // The screen is always assumed to be 72dpi, even though actual
- // resolution may vary (this is the tradition!)
- // On Windows:
- // OpenDoc/Win emulates 72dpi
- ptLogicalToContentScaling.x = FW_kFixedPos1;
- ptLogicalToContentScaling.y = FW_kFixedPos1;
- break;
-
- case FW_kDevice:
- #ifdef FW_BUILD_MAC
- ptLogicalToContentScaling.x = FW_kFixedPos1;
- ptLogicalToContentScaling.y = FW_kFixedPos1;
- #endif
- #ifdef FW_BUILD_WIN
- if (bWinIsPrinting)
- {
- // For printing, preserve the visual image size
- ptLogicalToContentScaling.x = FW_kFixed72 / resScreen.x;
- ptLogicalToContentScaling.y = FW_kFixed72 / resScreen.y;
- }
- else
- {
- // Counter-act OpenDoc's 72 dpi emulation
- ptLogicalToContentScaling.x = FW_kFixed72 / resDevice.x;
- ptLogicalToContentScaling.y = FW_kFixed72 / resDevice.y;
- }
- #endif
- break;
-
- case FW_kCustomConstrained:
- {
- FW_Fixed oneUnitx = mapping.fDeviceExtent.x / mapping.fLogicalExtent.x / resDevice.x;
- FW_Fixed oneUnity = mapping.fDeviceExtent.y / mapping.fLogicalExtent.y / resDevice.y;
- if (oneUnitx < oneUnity)
- mapping.fDeviceExtent.y = oneUnitx * resDevice.y * mapping.fLogicalExtent.y;
- else if (oneUnitx > oneUnity)
- mapping.fDeviceExtent.x = oneUnity * resDevice.x * mapping.fLogicalExtent.x;
- }
- // continue
- case FW_kCustomUnconstrained:
- resScale.x = FW_kFixed72 / resDevice.x;
- resScale.y = FW_kFixed72 / resDevice.y;
-
- ptLogicalToContentScaling.x =
- FW_WideMultiply(resScale.x, mapping.fDeviceExtent.x) / mapping.fLogicalExtent.x;
-
- ptLogicalToContentScaling.y =
- FW_WideMultiply(resScale.y, mapping.fDeviceExtent.y) / mapping.fLogicalExtent.y;
-
- ptLogicalToContentOffset.x =
- FW_WideMultiply(mapping.fDeviceOrg.x, FW_kFixed72) / resDevice.x - mapping.fLogicalOrg.x * ptLogicalToContentScaling.x;
-
- ptLogicalToContentOffset.y =
- FW_WideMultiply(mapping.fDeviceOrg.y, FW_kFixed72) / resDevice.y - mapping.fLogicalOrg.y * ptLogicalToContentScaling.y;
-
- break;
- }
-
- // ----- Logical to content transform
- mapping.fLogicalToContentTransform = ::FW_NewODTransform(ev, ptLogicalToContentOffset, ptLogicalToContentScaling);
-
- // ----- Content to device transform
- if(transform != NULL)
- {
- #ifdef LOG_TRANSFORMS
- FW_LogTransform(ev, "OD Content ", transform);
- #endif
- mapping.fContentToDeviceTransform = ::FW_NewODTransform(ev, transform);
- }
- else
- {
- FW_CPoint scaling;
- #ifdef FW_BUILD_WIN
- if (bWinIsPrinting && mapping.fMappingMode == FW_kDevice)
- {
- // Preserve visual image size
- scaling.x = resScreen.x / FW_kFixed72;
- scaling.y = resScreen.y / FW_kFixed72;
- }
- else
- #endif
- {
- scaling.x = resDevice.x / FW_kFixed72;
- scaling.y = resDevice.y / FW_kFixed72;
- }
-
- mapping.fContentToDeviceTransform = ::FW_NewODTransform(ev);
- mapping.fContentToDeviceTransform->ScaleBy(ev, (ODPoint*) &scaling);
- }
-
- // ------ Logical to device transform -----
- mapping.fLogicalToDeviceTransform = ::FW_NewODTransform(ev, mapping.fLogicalToContentTransform);
- mapping.fLogicalToDeviceTransform->PostCompose(ev, mapping.fContentToDeviceTransform);
-
- // ----- Adjust the origin
- CalcOriginOffset(mapping, ev, device);
-
- #ifdef LOG_TRANSFORMS
- FW_LogTransform(ev, "Logical -> Content", mapping.fLogicalToContentTransform);
- FW_LogTransform(ev, "Content -> Device ", mapping.fContentToDeviceTransform);
- FW_LogTransform(ev, "Logical -> Device ", mapping.fLogicalToDeviceTransform);
- #endif
-
- mapping.fHaveTransforms = TRUE;
- }
- FW_SOM_CATCH
- }
-
- //----------------------------------------------------------------------------------------
- // CalcOriginOffset
- //----------------------------------------------------------------------------------------
-
- static void CalcOriginOffset(FW_SMapping& mapping,
- Environment* ev,
- FW_HGDevice device)
- {
- FW_SOM_TRY
- {
- ODCanvas* canvas = device != NULL ? device->GetODCanvas() : NULL;
- FW_Boolean isPrinting = canvas != NULL &&
- #ifdef FW_BUILD_WIN
- (canvas->HasPlatformPrintJob(ev, kODWindows));
- #endif
- #ifdef FW_BUILD_MAC
- (canvas->HasPlatformPrintJob(ev, kODQuickDrawGX) || canvas->HasPlatformPrintJob(ev, kODQuickDraw));
- #endif
-
- FW_CPoint offset;
- mapping.fLogicalToDeviceTransform->GetOffset(ev, offset);
- if ((offset.x != FW_kFixed0 || offset.y != FW_kFixed0) && !isPrinting)
- {
- FW_SetXY(mapping.fOriginOffset, FW_FixedToInt(offset.x) % 8, FW_FixedToInt(offset.y) % 8);
- offset.x = FW_IntToFixed(-FW_PointX(mapping.fOriginOffset));
- offset.y = FW_IntToFixed(-FW_PointY(mapping.fOriginOffset));
- mapping.fLogicalToDeviceTransform->MoveBy(ev, offset);
- }
- else
- {
- FW_SetXY(mapping.fOriginOffset, 0, 0);
- }
- }
- FW_SOM_CATCH
- }
-
- //----------------------------------------------------------------------------------------
- // ----- Logical ---> Content
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_LogicalToContentPoint(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_SPoint& ptFrom,
- FW_SPoint& ptTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- ptTo = FW_TransformCopy(ev, ptFrom, mapping.fLogicalToContentTransform);
- }
- FW_SOM_CATCH
- }
-
- void SL_API FW_PrivMapping_LogicalToContentRect(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_SRect& rectFrom,
- FW_SRect& rectTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- rectTo = FW_TransformCopy(ev, rectFrom, mapping.fLogicalToContentTransform);
- }
- FW_SOM_CATCH
- }
-
- ODShape* SL_API FW_PrivMapping_LogicalToContentShape(
- const FW_SMapping& mapping,
- Environment* ev,
- ODShape* shape,
- FW_HGDevice device,
- ODTransform* transform)
- {
- ODShape* newShape = 0;
-
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- newShape = shape->Copy(ev);
- mapping.fLogicalToContentTransform->TransformShape(ev, newShape);
- }
- FW_SOM_CATCH
-
- return newShape;
- }
-
- //----------------------------------------------------------------------------------------
- // ----- Logical ---> Device
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_LogicalToDevicePoint(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_SPoint& ptFrom,
- FW_PlatformPoint& ptTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- FW_CPoint pt = FW_TransformCopy(ev, ptFrom, mapping.fLogicalToDeviceTransform);
- ptTo = pt.AsPlatformPoint();
- }
- FW_SOM_CATCH
- }
-
- void SL_API FW_PrivMapping_LogicalToDeviceRect(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_SRect& rectFrom,
- FW_PlatformRect& rectTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- FW_CRect rect = FW_TransformCopy(ev, rectFrom, mapping.fLogicalToDeviceTransform);
- rectTo = rect.AsPlatformRect();
- }
- FW_SOM_CATCH
- }
-
- ODShape* SL_API FW_PrivMapping_LogicalToDeviceShape(
- const FW_SMapping& mapping,
- Environment* ev,
- ODShape* shape,
- FW_HGDevice device,
- ODTransform* transform)
- {
- ODShape* newShape = 0;
-
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- newShape = shape->Copy(ev);
- mapping.fLogicalToDeviceTransform->TransformShape(ev, newShape);
- }
- FW_SOM_CATCH
-
- return newShape;
- }
-
- //----------------------------------------------------------------------------------------
- // ----- Device ---> Logical
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_DeviceToLogicalPoint(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_PlatformPoint& ptFrom,
- FW_SPoint& ptTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- FW_CPoint pt = ptFrom;
- ptTo = FW_InverseTransformCopy(ev, pt, mapping.fLogicalToDeviceTransform);
- }
- FW_SOM_CATCH
- }
-
- void SL_API FW_PrivMapping_DeviceToLogicalRect(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_PlatformRect& rectFrom,
- FW_SRect& rectTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- FW_CRect rect = rectFrom;
- rectTo = rect.InverseTransformCopy(ev, mapping.fLogicalToDeviceTransform);
- }
- FW_SOM_CATCH
- }
-
- ODShape* SL_API FW_PrivMapping_DeviceToLogicalShape(
- const FW_SMapping& mapping,
- Environment* ev,
- ODShape* shape,
- FW_HGDevice device,
- ODTransform* transform)
- {
- ODShape* newShape = 0;
-
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- newShape = shape->Copy(ev);
- mapping.fLogicalToDeviceTransform->InvertShape(ev, newShape);
- }
- FW_SOM_CATCH
-
- return newShape;
- }
-
- //----------------------------------------------------------------------------------------
- // ----- Device ---> Content
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_DeviceToContentPoint(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_PlatformPoint& ptFrom,
- FW_SPoint& ptTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- FW_CPoint pt = ptFrom;
- ptTo = FW_InverseTransformCopy(ev, pt, mapping.fContentToDeviceTransform);
- }
- FW_SOM_CATCH
- }
-
- void SL_API FW_PrivMapping_DeviceToContentRect(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_PlatformRect& rectFrom,
- FW_SRect& rectTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- FW_CRect rect = rectFrom;
- rectTo = rect.InverseTransformCopy(ev, mapping.fContentToDeviceTransform);
- }
- FW_SOM_CATCH
- }
-
- ODShape* SL_API FW_PrivMapping_DeviceToContentShape(
- const FW_SMapping& mapping,
- Environment* ev,
- ODShape* shape,
- FW_HGDevice device,
- ODTransform* transform)
- {
- ODShape* newShape = 0;
-
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- newShape = shape->Copy(ev);
- mapping.fContentToDeviceTransform->InvertShape(ev, newShape);
- }
- FW_SOM_CATCH
-
- return newShape;
- }
-
- //----------------------------------------------------------------------------------------
- // ----- Content ---> Logical
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_ContentToLogicalPoint(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_SPoint& ptFrom,
- FW_SPoint& ptTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- ptTo = FW_InverseTransformCopy(ev, ptFrom, mapping.fLogicalToContentTransform);
- }
- FW_SOM_CATCH
- }
-
- void SL_API FW_PrivMapping_ContentToLogicalRect(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_SRect& rectFrom,
- FW_SRect& rectTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- rectTo = FW_InverseTransformCopy(ev, rectFrom, mapping.fLogicalToContentTransform);
- }
- FW_SOM_CATCH
- }
-
-
- ODShape* SL_API FW_PrivMapping_ContentToLogicalShape(
- const FW_SMapping& mapping,
- Environment* ev,
- ODShape* shape,
- FW_HGDevice device,
- ODTransform* transform)
- {
- ODShape* newShape = 0;
-
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- newShape = shape->Copy(ev);
- mapping.fLogicalToContentTransform->InvertShape(ev, newShape);
- }
- FW_SOM_CATCH
-
- return newShape;
- }
-
- //----------------------------------------------------------------------------------------
- // ----- Content ---> Device
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMapping_ContentToDevicePoint(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_SPoint& ptFrom,
- FW_PlatformPoint& ptTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- FW_CPoint pt = FW_TransformCopy(ev, ptFrom, mapping.fContentToDeviceTransform);
- ptTo = pt.AsPlatformPoint();
- }
- FW_SOM_CATCH
- }
-
- void SL_API FW_PrivMapping_ContentToDeviceRect(
- const FW_SMapping& mapping,
- Environment* ev,
- const FW_SRect& rectFrom,
- FW_PlatformRect& rectTo,
- FW_HGDevice device,
- ODTransform* transform)
- {
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- FW_CRect rect = FW_TransformCopy(ev, rectFrom, mapping.fContentToDeviceTransform);
- rectTo = rect.AsPlatformRect();
- }
- FW_SOM_CATCH
- }
-
- ODShape* SL_API FW_PrivMapping_ContentToDeviceShape(
- const FW_SMapping& mapping,
- Environment* ev,
- ODShape* shape,
- FW_HGDevice device,
- ODTransform* transform)
- {
- ODShape* newShape = 0;
-
- FW_SOM_TRY
- {
- CheckCache(mapping, ev, device, transform);
- newShape = shape->Copy(ev);
- mapping.fContentToDeviceTransform->TransformShape(ev, newShape);
- }
- FW_SOM_CATCH
-
- return newShape;
- }
-
-