home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 3.4 KB | 107 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWRect.h
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWRECT_H
- #define FWRECT_H
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- //==============================================================================
- // •• Typedefs
- //==============================================================================
-
- typedef unsigned short FW_PointSelector;
-
- const FW_PointSelector FW_kTopLeft = 0;
- const FW_PointSelector FW_kBotRight = 1;
-
- //==============================================================================
- // •• struct FW_CRect
- //==============================================================================
-
- struct FW_CRect : public XMPRect
- {
-
- public:
- // ----- Constructors -----
- FW_CRect() {left = right = top = bottom = 0;}
- FW_CRect(XMPCoordinate l, XMPCoordinate t, XMPCoordinate r, XMPCoordinate b)
- {left=l; top=t; right=r; bottom=b; }
- FW_CRect(const FW_CPoint& topLeft, const FW_CPoint& botRight);
- FW_CRect(const FW_CPoint &topLeft, XMPCoordinate width, XMPCoordinate height);
- FW_CRect(const FW_SPlatformRect& plfmRect);
-
- // ----- Assignement -----
- FW_CRect& operator=(const XMPRect& xmpRect);
- FW_CRect& operator=(const FW_SPlatformRect& plfmRect);
-
- // ----- Conversion -----
- void AsPlatformRect(FW_SPlatformRect& plfmRect) const;
- operator FW_SPlatformRect() const;
-
- // ----- Modification -----
- void Clear();
- void Set(XMPCoordinate left, XMPCoordinate top, XMPCoordinate right, XMPCoordinate bottom);
- void Set(const FW_CPoint& topLeft, XMPCoordinate width, XMPCoordinate height);
- void SetInt(short left, short top, short right, short bottom);
- void Offset(XMPCoordinate x, XMPCoordinate y);
- void Offset(const FW_CPoint& offset);
- void Place(XMPCoordinate x, XMPCoordinate y);
- void Place(const FW_CPoint& offset);
- void Inset(XMPCoordinate x, XMPCoordinate y);
- void Map(const FW_CRect& srcRect, const FW_CRect& dstRect);
-
- void operator&=(const FW_CRect& rect); // Intersect with rectangle
- void operator|=(const FW_CRect& rect); // Union with rectangle
- void operator|=(const FW_CPoint& point); // Expand to fit point
-
- void Sort();
-
- // ----- Accessors -----
-
- const FW_CPoint& TopLeft() const
- {return *(FW_CPoint*)&left;}
- FW_CPoint& TopLeft()
- {return *(FW_CPoint*)&left;}
- const FW_CPoint& BotRight() const
- {return *(FW_CPoint*)&right;}
- FW_CPoint& BotRight()
- {return *(FW_CPoint*)&right;}
- XMPCoordinate Width() const
- {return right-left;}
- XMPCoordinate Height() const
- {return bottom-top;}
-
- FW_CPoint& operator[](FW_PointSelector sel);
- const FW_CPoint& operator[](FW_PointSelector sel) const;
-
- // ----- Testing -----
- FW_Boolean operator==( const FW_CRect& ) const;
- FW_Boolean operator!=( const FW_CRect &r ) const
- {return !(*this==r);}
-
- FW_Boolean IsEmpty() const;
- FW_Boolean Contains(const FW_CPoint& point) const;
- FW_Boolean Contains(const FW_CRect& rect) const;
- FW_Boolean IsIntersecting(const FW_CRect& rect) const;
- FW_CRect Intersects(const FW_CRect& rect) const;
-
-
- // ----- Stream -----
- void Flatten(FW_CWritableStream& stream);
- void Unflatten(FW_CReadableStream& stream);
- };
-
-
- #endif
-