home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.6 KB | 209 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPoly.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWPOLY_H
- #include "FWPoly.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWEXCEPT_H
- #include "FWExcept.h"
- #endif
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWMEMORY_H
- #include "FWMemory.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _TRANSFORM_
- #include <Trnsform.xh>
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Polygon
- #endif
-
- //========================================================================================
- // Template instantiation
- //========================================================================================
-
- #include "FWGrRef.tpp"
-
- FW_DEFINE_AUTO_TEMPLATE(FW_TGrRefPtr, FW_HPolygon)
-
- #ifdef FW_USE_TEMPLATE_PRAGMAS
-
- #pragma template_access public
- #pragma template FW_TGrRefPtr<FW_HPolygon>
-
- #else
-
- template class FW_TGrRefPtr<FW_HPolygon>;
-
- #endif
-
- //========================================================================================
- // class FW_CPolygon
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CPolygon)
-
- //----------------------------------------------------------------------------------------
- // FW_PrivAcquireGrRep
- //----------------------------------------------------------------------------------------
-
- void FW_PrivAcquireGrRep(FW_HPolygon rep)
- {
- if (rep != 0)
- FW_PrivPolygon_Acquire(rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivReleaseGrRep
- //----------------------------------------------------------------------------------------
-
- void FW_PrivReleaseGrRep(FW_HPolygon rep)
- {
- if (rep != 0)
- FW_PrivPolygon_Release(rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::FW_CPolygon
- //----------------------------------------------------------------------------------------
-
- FW_CPolygon::FW_CPolygon()
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::FW_CPolygon
- //----------------------------------------------------------------------------------------
-
- FW_CPolygon::FW_CPolygon(long count, const FW_SPoint* points)
- {
- FW_PlatformError error;
- FW_HPolygon rep = FW_PrivPolygon_CreateFromPoints(count, points, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::FW_CPolygon
- //----------------------------------------------------------------------------------------
-
- FW_CPolygon::FW_CPolygon(FW_CReadableStream& stream)
- {
- FW_PlatformError error;
- FW_HPolygon rep = FW_PrivPolygon_Read(stream, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::FW_CPolygon
- //----------------------------------------------------------------------------------------
-
- FW_CPolygon::FW_CPolygon(const FW_CPolygon& other) :
- FW_TGrRefPtr<FW_HPolygon>(other)
- {
- SetRep(other.fRep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::~FW_CPolygon
- //----------------------------------------------------------------------------------------
-
- FW_CPolygon::~FW_CPolygon()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CPolygon FW_CPolygon::Copy() const
- {
- FW_PlatformError error;
- FW_HPolygon rep = FW_PrivPolygon_Copy(fRep, &error);
- FW_FailOnError(error);
-
- FW_CPolygon poly;
- poly.SetRep(rep);
- return poly;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CPolygon& FW_CPolygon::operator=(const FW_CPolygon& other)
- {
- FW_TGrRefPtr<FW_HPolygon>::operator=(other);
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::operator>>
- //----------------------------------------------------------------------------------------
-
- FW_CReadableStream& operator>>(FW_CReadableStream& stream, FW_CPolygon& poly)
- {
- FW_PlatformError error;
- FW_HPolygon rep = FW_PrivPolygon_Read(stream, &error);
- FW_FailOnError(error);
- poly.SetRep(rep);
- return stream;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPolygon::operator<<
- //----------------------------------------------------------------------------------------
-
- FW_CWritableStream& operator<<(FW_CWritableStream& stream, const FW_CPolygon& poly)
- {
- FW_PlatformError error;
- FW_PrivPolygon_Write(poly.fRep, stream, &error);
- FW_FailOnError(error);
- return stream;
- }
-
- #ifdef FW_BUILD_WIN
-
- //----------------------------------------------------------------------------------------
- // OpenDoc for Windows doesn't export ODPolygon::GetNContours, so we have to do it here
-
- ODSLong ODPolygon::GetNContours() const
- {
- return _length > 0 ? _buf->nContours : 0;
- }
-
- #endif
-