home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 7.9 KB | 313 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMaping.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMAPING_H
- #define FWMAPING_H
-
- #ifndef FWGRDEF_H
- #include "FWGrDef.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward Class Declarations
- //========================================================================================
-
- class FW_CLASS_ATTR ODShape;
- class FW_CLASS_ATTR ODTransform;
- class FW_CLASS_ATTR FW_CGraphicDevice;
-
- //========================================================================================
- // defines
- //========================================================================================
-
- enum FW_EMappingModes
- {
- FW_kCentimeter,
- FW_kInch,
- FW_kPoint,
- FW_kDevice,
- FW_kCustomConstrained,
- FW_kCustomUnconstrained
- };
-
- //========================================================================================
- // class FW_CMapping
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMapping FW_AUTO_DESTRUCT_OBJECT
- {
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CMapping();
- FW_CMapping(FW_EMappingModes mappingMode);
- FW_CMapping(const FW_CMapping& mapping);
-
- virtual ~FW_CMapping();
-
- //----------------------------------------------------------------------------------------
- // operators
- //
- public:
- FW_CMapping& operator= (const FW_CMapping& mapping);
- FW_Boolean operator==(const FW_CMapping& mapping) const;
- FW_Boolean operator!=(const FW_CMapping& mapping) const;
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
-
- // ----- Setting the mapping -----
-
- void Reset(Environment* ev); // Reset to default values;
-
- void SetMappingMode(Environment* ev, FW_EMappingModes newMappingMode);
- void SetExtents(Environment* ev,
- const FW_CPoint& logicalExtent,
- const FW_CPoint& deviceExtent);
-
- FW_CPoint GetLogicalExtent() const
- {return fLogicalExtent;}
-
- FW_CPoint GetDeviceExtent() const
- {return fDeviceExtent;}
-
- void SetDeviceOrigin(Environment* ev, FW_CFixed x, FW_CFixed y); // in device units (pixels)
- void SetLogicalOrigin(Environment* ev, FW_CFixed x, FW_CFixed y); // in logical units
-
- FW_CPoint GetDeviceOrigin() const
- {return fDeviceOrg;}
-
- FW_CPoint GetLogicalOrigin() const
- {return fLogicalOrg;}
-
- // ----- Transform info -----
-
- FW_SPlatformPoint GetOriginOffset(
- Environment* ev,
- FW_CGraphicDevice* device,
- ODTransform* transform) const;
-
- //----------------------------------------------------------------------------------------
- // Conversion
- //
- public:
-
- // ----- Logical ---> Content
-
- void LogicalToContent(
- Environment* ev,
- const FW_CPoint& ptFrom,
- FW_CPoint& ptTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- void LogicalToContent(
- Environment* ev,
- const FW_CRect& rectFrom,
- FW_CRect& rectTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- ODShape* LogicalToContent(
- Environment* ev,
- ODShape* shape,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- // ----- Logical ---> Device
-
- void LogicalToDevice(
- Environment* ev,
- const FW_CPoint& ptFrom,
- FW_SPlatformPoint& ptTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- void LogicalToDevice(
- Environment* ev,
- const FW_CRect& rectFrom,
- FW_SPlatformRect& rectTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- ODShape* LogicalToDevice(
- Environment* ev,
- ODShape* shape,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- // ----- Device ---> Logical
-
- void DeviceToLogical(
- Environment* ev,
- const FW_SPlatformPoint& ptFrom,
- FW_CPoint& ptTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- void DeviceToLogical(
- Environment* ev,
- const FW_SPlatformRect& rectFrom,
- FW_CRect& rectTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- ODShape* DeviceToLogical(
- Environment* ev,
- ODShape* shape,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- // ----- Device ---> Content
-
- void DeviceToContent(
- Environment* ev,
- const FW_SPlatformPoint& ptFrom,
- FW_CPoint& ptTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- void DeviceToContent(
- Environment* ev,
- const FW_SPlatformRect& rectFrom,
- FW_CRect& rectTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- ODShape* DeviceToContent(
- Environment* ev,
- ODShape* shape,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- // ----- Content ---> Logical
-
- void ContentToLogical(
- Environment* ev,
- const FW_CPoint& ptFrom,
- FW_CPoint& ptTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- void ContentToLogical(
- Environment* ev,
- const FW_CRect& rectFrom,
- FW_CRect& rectTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- ODShape* ContentToLogical(
- Environment* ev,
- ODShape* shape,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- // ----- Content ---> Device
-
- void ContentToDevice(
- Environment* ev,
- const FW_CPoint& ptFrom,
- FW_SPlatformPoint& ptTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- void ContentToDevice(
- Environment* ev,
- const FW_CRect& rectFrom,
- FW_SPlatformRect& rectTo,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- ODShape* ContentToDevice(
- Environment* ev,
- ODShape* shape,
- FW_CGraphicDevice* device,
- ODTransform* transform = NULL) const;
-
- //----------------------------------------------------------------------------------------
- // Implementation
- //
- protected:
- void ClearCache(Environment* ev);
-
- void CheckCache(
- Environment* ev,
- FW_CGraphicDevice* device,
- ODTransform* transform) const;
-
- void CalcCache(
- Environment* ev,
- FW_CGraphicDevice* device,
- ODTransform* transform);
-
- void CalcOriginOffset(
- Environment* ev,
- FW_CGraphicDevice* device);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- public:
- FW_EMappingModes fMappingMode;
-
- FW_CPoint fLogicalExtent;
- FW_CPoint fDeviceExtent;
-
- FW_CPoint fDeviceOrg;
- FW_CPoint fLogicalOrg;
-
- FW_SPlatformPoint fOriginOffset;
-
- // ----- Cache -----
- FW_CGraphicDevice* fRecentDevice;
- ODTransform* fRecentODTransform;
-
- FW_Boolean fHaveTransforms;
-
- ODTransform* fLogicalToContentTransform;
- ODTransform* fContentToDeviceTransform;
- ODTransform* fLogicalToDeviceTransform;
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CMapping::operator!=
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CMapping::operator!=(const FW_CMapping& mapping) const
- {
- return !(*this == mapping);
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-