home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 9.3 KB | 320 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWArcShp.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWARCSHP_H
- #include "FWArcShp.h"
- #endif
-
- #ifndef FWSHAPE_H
- #include "FWShape.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWDFAULT_H
- #include "FWDfault.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWRGNSHP_H
- #include "FWRgnShp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _TRNSFORM_
- #include <Trnsform.h>
- #endif
-
- //==============================================================================
- // •• RunTime Info
- //==============================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphx
- #endif
-
- //==============================================================================
- // •• class FW_CArcShape
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::FW_CArcShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::FW_CArcShape() :
- FW_CShape()
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::FW_CArcShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::FW_CArcShape(const FW_CRect& rect, short startAngle, short arcAngle) :
- FW_CShape()
- {
- SetRep(new FW_CArcShapeRep(rect, startAngle, arcAngle));
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::FW_CArcShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::FW_CArcShape(const FW_CArcShape& other) :
- FW_CShape(other)
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::FW_CArcShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::FW_CArcShape(FW_CArcShapeRep* rep) :
- FW_CShape(rep)
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::operator=
- //------------------------------------------------------------------------------
-
- FW_CArcShape& FW_CArcShape::operator=(const FW_CArcShape& other)
- {
- SetRep(other.GetRep());
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::operator=
- //------------------------------------------------------------------------------
-
- FW_CArcShape& FW_CArcShape::operator=(FW_CArcShapeRep* other)
- {
- SetRep(other);
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::operator FW_COvalShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::operator FW_COvalShape() const
- {
- FW_COvalShape ovalShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
- ovalShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return ovalShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::operator FW_CRoundRectShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::operator FW_CRoundRectShape() const
- {
- FW_CRoundRectShape roundRectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), FW_kZeroPoint);
- roundRectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return roundRectShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::operator FW_CRectShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::operator FW_CRectShape() const
- {
- FW_CRectShape rectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
- rectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return rectShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::operator FW_CLineShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::operator FW_CLineShape() const
- {
- // NotYetImplemented();
-
- FW_CRect rect = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
- FW_CLineShape lineShape(rect[FW_kTopLeft], rect[FW_kBotRight]);
- lineShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return lineShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CArcShape::operator FW_CRegionShape
- //------------------------------------------------------------------------------
-
- FW_CArcShape::operator FW_CRegionShape() const
- {
- // NotYetImplemented();
-
- FW_CRegionShape regionShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
- regionShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return regionShape;
- }
-
- //==============================================================================
- // •• class FW_CArcShapeRep
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • FW_CArcShapeRep::FW_CArcShapeRep
- //------------------------------------------------------------------------------
-
- FW_CArcShapeRep::FW_CArcShapeRep() :
- FW_CBoundedShapeRep(gGraphicGlobales.gArc, FW_CRect(0,0,0,0)),
- fStartAngle(0),
- fArcAngle(0)
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CArcShapeRep::FW_CArcShapeRep
- //------------------------------------------------------------------------------
-
- FW_CArcShapeRep::FW_CArcShapeRep(const FW_CRect& rect, short startAngle, short arcAngle) :
- FW_CBoundedShapeRep(gGraphicGlobales.gArc, rect),
- fStartAngle(startAngle),
- fArcAngle(arcAngle)
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CArcShapeRep::~FW_CArcShapeRep
- //------------------------------------------------------------------------------
-
- FW_CArcShapeRep::~FW_CArcShapeRep()
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CArcShapeRep::Draw
- //------------------------------------------------------------------------------
-
- void FW_CArcShapeRep::Draw(FW_CGraphicContext* graphicContext)
- {
- FW_ShapeFills shapeFill = GetShapeFill();
-
- if (shapeFill == FW_kNullShape)
- return;
-
- graphicContext->SelectInkAndStyle(GetShapeInk(), GetShapeStyle(), FW_kGeometricShape, shapeFill);
-
- FW_SPlatformRect rect = graphicContext->AsPlatformRect(fRect);
-
- #ifdef FW_BUILD_MAC
- if (shapeFill == FW_kFramed)
- ::FrameArc(&rect, fStartAngle, fArcAngle);
- else
- ::PaintArc(&rect, fStartAngle, fArcAngle);
- #endif
- #ifdef FW_BUILD_WIN
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CArcShapeRep::DrawArc
- //------------------------------------------------------------------------------
-
- void FW_CArcShapeRep::DrawArc(FW_CGraphicContext* graphicContext,
- const FW_CRect& rect, short startAngle, short arcAngle)
- {
- if (gGraphicGlobales.gArc.fFill == FW_kNullShape)
- return;
-
- graphicContext->SelectInkAndStyle(gGraphicGlobales.gArc.fInk,
- gGraphicGlobales.gArc.fStyle,
- FW_kGeometricShape,
- gGraphicGlobales.gArc.fFill);
-
- FW_SPlatformRect qdRect = graphicContext->AsPlatformRect(rect);
-
- #ifdef FW_BUILD_MAC
- if (gGraphicGlobales.gArc.fFill == FW_kFramed)
- ::FrameArc(&qdRect, startAngle, arcAngle);
- else
- ::PaintArc(&qdRect, startAngle, arcAngle);
- #endif
- #ifdef FW_BUILD_WIN
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CArcShapeRep::Copy
- //------------------------------------------------------------------------------
-
- FW_CArcShape FW_CArcShapeRep::Copy() const
- {
- FW_CArcShape arcShape(fRect, fStartAngle, fArcAngle);
- return arcShape;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CArcShapeRep::SetAsDefault
- //------------------------------------------------------------------------------
-
- void FW_CArcShapeRep::SetAsDefault() const
- {
- SetDefaultProperties(gGraphicGlobales.gArc);
- }
-
- //------------------------------------------------------------------------------
- // • FW_CArcShapeRep::HitTest
- //------------------------------------------------------------------------------
-
- FW_HitTestPart FW_CArcShapeRep::HitTest(const FW_CPoint& test) const
- {
- return FW_kOutside;
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CArcShapeRep::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CArcShapeRep::Flatten(FW_CWritableStream& stream)
- {
- FW_CBoundedShapeRep::Flatten(stream);
- stream << fStartAngle;
- stream << fArcAngle;
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CArcShapeRep::Unflatten
- //----------------------------------------------------------------------------------------
-
- void FW_CArcShapeRep::Unflatten(FW_CReadableStream& stream)
- {
- FW_CBoundedShapeRep::Unflatten(stream);
- stream >> fStartAngle;
- stream >> fArcAngle;
- }
-
-
-