home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 11.9 KB | 463 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPoint.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _XMPTYPES_
- #include <XMPTypes.h>
- #endif
-
- // ----- Macintosh Includes -----
- #if defined(FW_BUILD_MAC) && !defined(__FIXMATH__)
- #include <FixMath.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(mathRoutinesIncludes)
- #include <math routines.h>
- #endif
-
- //==============================================================================
- // •• RunTime Info
- //==============================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphx
- #endif
-
- //==============================================================================
- // •• struct FW_CPoint
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::FW_CPoint
- //------------------------------------------------------------------------------
-
- FW_CPoint::FW_CPoint(FW_SPlatformPoint plfmPoint)
- {
- #ifdef FW_BUILD_MAC
- x = ff(plfmPoint.h);
- y = ff(plfmPoint.v);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::FW_CPoint
- //------------------------------------------------------------------------------
- FW_CPoint::FW_CPoint(const FW_CPoint &pt)
- {
- x = pt.x;
- y = pt.y;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::FW_CPoint
- //------------------------------------------------------------------------------
- FW_CPoint::FW_CPoint(const XMPPoint &xmpPoint)
- {
- x = xmpPoint.x;
- y = xmpPoint.y;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator=(const FW_CPoint &pt)
- {
- x = pt.x;
- y = pt.y;
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator=(const XMPPoint &xmpPoint)
- {
- x = xmpPoint.x;
- y = xmpPoint.y;
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator=(FW_SPlatformPoint plfmPoint)
- {
- #ifdef FW_BUILD_MAC
- x = ff(plfmPoint.h);
- y = ff(plfmPoint.v);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
-
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::Offset
- //------------------------------------------------------------------------------
-
- void FW_CPoint::Offset(XMPCoordinate xx, XMPCoordinate yy)
- {
- x += xx;
- y += yy;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator+=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator+=(const FW_CPoint &pt)
- {
- x += pt.x;
- y += pt.y;
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator-=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator-=(const FW_CPoint &pt)
- {
- x -= pt.x;
- y -= pt.y;
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator+=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator+=(const XMPPoint &xmpPoint)
- {
- x += xmpPoint.x;
- y += xmpPoint.y;
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator-=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator-=(const XMPPoint &xmpPoint)
- {
- x -= xmpPoint.x;
- y -= xmpPoint.y;
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator+
- //------------------------------------------------------------------------------
-
- FW_CPoint FW_CPoint::operator+(const FW_CPoint &pt) const
- {
- FW_CPoint returnPt;
- returnPt.x = x + pt.x;
- returnPt.y = y + pt.y;
- return returnPt;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator-
- //------------------------------------------------------------------------------
-
- FW_CPoint FW_CPoint::operator-(const FW_CPoint &pt) const
- {
- FW_CPoint returnPt;
- returnPt.x = x - pt.x;
- returnPt.y = y - pt.y;
- return returnPt;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator+
- //------------------------------------------------------------------------------
-
- FW_CPoint FW_CPoint::operator+(const XMPPoint &xmpPoint) const
- {
- FW_CPoint returnPt;
- returnPt.x = x + xmpPoint.x;
- returnPt.y = y + xmpPoint.y;
- return returnPt;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator-
- //------------------------------------------------------------------------------
-
- FW_CPoint FW_CPoint::operator-(const XMPPoint &xmpPoint) const
- {
- FW_CPoint returnPt;
- returnPt.x = x - xmpPoint.x;
- returnPt.y = y - xmpPoint.y;
- return returnPt;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator-
- //------------------------------------------------------------------------------
-
- FW_CPoint FW_CPoint::operator-() const
- {
- FW_CPoint returnPt;
- returnPt.x = -x;
- returnPt.y = -y;
- return returnPt;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator+=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator+=(FW_SPlatformPoint plfmPoint)
- {
- #ifdef FW_BUILD_MAC
- x += ff(plfmPoint.h);
- y += ff(plfmPoint.v);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
-
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator-=
- //------------------------------------------------------------------------------
-
- FW_CPoint& FW_CPoint::operator-=(FW_SPlatformPoint plfmPoint)
- {
- #ifdef FW_BUILD_MAC
- x -= ff(plfmPoint.h);
- y -= ff(plfmPoint.v);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
-
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator+
- //------------------------------------------------------------------------------
-
- FW_CPoint FW_CPoint::operator+(FW_SPlatformPoint plfmPoint) const
- {
- FW_CPoint returnPt;
-
- #ifdef FW_BUILD_MAC
- returnPt.x = x + ff(plfmPoint.h);
- returnPt.y = y + ff(plfmPoint.v);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
-
- return returnPt;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator-
- //------------------------------------------------------------------------------
-
- FW_CPoint FW_CPoint::operator-(FW_SPlatformPoint plfmPoint) const
- {
- FW_CPoint returnPt;
-
- #ifdef FW_BUILD_MAC
- returnPt.x = x - ff(plfmPoint.h);
- returnPt.y = y - ff(plfmPoint.v);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
-
- return returnPt;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::opertor FW_SPlatformPoint const
- //------------------------------------------------------------------------------
-
- FW_CPoint::operator FW_SPlatformPoint() const
- {
- FW_SPlatformPoint plfmPoint;
-
- #ifdef FW_BUILD_MAC
- plfmPoint.h = FixedToInt(x);
- plfmPoint.v = FixedToInt(y);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
-
- return plfmPoint;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::AsPlatformPoint
- //------------------------------------------------------------------------------
-
- void FW_CPoint::AsPlatformPoint(FW_SPlatformPoint& plfmPoint) const
- {
- #ifdef FW_BUILD_MAC
- plfmPoint.h = FixedToInt(x);
- plfmPoint.v = FixedToInt(y);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::IntX
- //------------------------------------------------------------------------------
-
- short FW_CPoint::IntX() const
- {
- #ifdef FW_BUILD_MAC
- return FixedToInt(x);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::IntY
- //------------------------------------------------------------------------------
-
- short FW_CPoint::IntY() const
- {
- #ifdef FW_BUILD_MAC
- return FixedToInt(y);
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator==
- //------------------------------------------------------------------------------
-
- FW_Boolean FW_CPoint::operator==(const FW_CPoint &pt) const
- {
- return x==pt.x && y==pt.y;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator!=
- //------------------------------------------------------------------------------
-
- FW_Boolean FW_CPoint::operator!=(const FW_CPoint &pt) const
- {
- return x!=pt.x || y!=pt.y;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator==
- //------------------------------------------------------------------------------
-
- FW_Boolean FW_CPoint::operator==(const XMPPoint &xmpPoint) const
- {
- return x==xmpPoint.x && y==xmpPoint.y;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CPoint::operator!=
- //------------------------------------------------------------------------------
-
- FW_Boolean FW_CPoint::operator!=(const XMPPoint &xmpPoint) const
- {
- return x!=xmpPoint.x || y!=xmpPoint.y;
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CPoint::operator[]
- //----------------------------------------------------------------------------------------
-
- XMPCoordinate& FW_CPoint::operator[](FW_XYSelector selector)
- {
- return selector == FW_kVertical ? y : x;
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CPoint::operator[]
- //----------------------------------------------------------------------------------------
-
- XMPCoordinate FW_CPoint::operator[](FW_XYSelector selector) const
- {
- return selector == FW_kVertical ? y : x;
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CPoint::Map
- //----------------------------------------------------------------------------------------
-
- void FW_CPoint::Map(const FW_CRect& srcRect, const FW_CRect& destRect)
- {
- FW_CPoint delta;
- delta.x = x - srcRect.left;
- delta.y = y - srcRect.top;
-
- delta.x = ::FixDiv(delta.x * destRect.Width(), srcRect.Width());
- delta.y = ::FixDiv(delta.y * destRect.Height(), srcRect.Height());
-
- x = destRect.left + delta.x;
- y = destRect.top + delta.y;
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CPoint::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CPoint::Flatten(FW_CWritableStream& stream)
- {
- stream.Write((char*)this, sizeof(XMPPoint));
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CPoint::Unflatten
- //----------------------------------------------------------------------------------------
-
- void FW_CPoint::Unflatten(FW_CReadableStream& stream)
- {
- stream.Read((char*)this, sizeof(XMPPoint));
- }
-
-
-
-
-