home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 10.2 KB | 336 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWRRcShp.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWSHAPE_H
- #include "FWShape.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWDFAULT_H
- #include "FWDfault.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef FWARCSHP_H
- #include "FWArcShp.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWRGNSHP_H
- #include "FWRgnShp.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _TRNSFORM_
- #include <Trnsform.h>
- #endif
-
- //==============================================================================
- // •• RunTime Info
- //==============================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphx
- #endif
-
- //==============================================================================
- // •• class FW_CRoundRectShape
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape() :
- FW_CShape()
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(const FW_CRect& rect, const FW_CPoint& ovalSize) :
- FW_CShape()
- {
- SetRep(new FW_CRoundRectShapeRep(rect, ovalSize));
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(const FW_CRoundRectShape& other) :
- FW_CShape(other)
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(FW_CRoundRectShapeRep* rep) :
- FW_CShape(rep)
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::operator=
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape& FW_CRoundRectShape::operator=(const FW_CRoundRectShape& other)
- {
- SetRep(other.GetRep());
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::operator=
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape& FW_CRoundRectShape::operator=(FW_CRoundRectShapeRep* other)
- {
- SetRep(other);
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::operator FW_CRectShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::operator FW_CRectShape() const
- {
- FW_CRectShape rectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
- rectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return rectShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::operator FW_COvalShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::operator FW_COvalShape() const
- {
- FW_COvalShape ovalShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
- ovalShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return ovalShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::operator FW_CArcShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::operator FW_CArcShape() const
- {
- FW_CArcShape arcShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), 0, 0);
- arcShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return arcShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRoundRectShape::operator FW_CLineShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::operator FW_CLineShape() const
- {
- 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_CRoundRectShape::operator FW_CRegionShape
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape::operator FW_CRegionShape() const
- {
- XMPShape *xmpShape = NULL;
-
- #ifdef FW_BUILD_MAC
- GrafPtr svPort;
- ::GetPort(&svPort);
- ::SetPort(gGraphicGlobales.gScratchWindow);
- ::OpenRgn();
- FW_SPlatformRect rect = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
- FW_SPlatformPoint ovalSize = ((FW_CRoundRectShapeRep*)GetRep())->GetOvalSize();
- ::FrameRoundRect(&rect, ovalSize.h, ovalSize.v);
- FW_PlatformRegion rgn = ::NewRgn();
- ::CloseRgn(rgn);
- xmpShape = ::NewXMPShape(rgn);
- ::SetPort(svPort);
- #endif
-
- #ifdef FW_BUILD_WIN
- NotYetImplemented();
- #endif
-
- FW_CRegionShape regionShape(xmpShape);
- regionShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return regionShape;
- }
-
- //==============================================================================
- // •• class FW_CRoundRectShapeRep
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::FW_CRoundRectShapeRep
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShapeRep::FW_CRoundRectShapeRep() :
- FW_CBoundedShapeRep(gGraphicGlobales.gRoundRect, FW_CRect(0,0,0,0)),
- fOvalSize(0, 0)
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::FW_CRoundRectShapeRep
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShapeRep::FW_CRoundRectShapeRep(const FW_CRect& rect, const FW_CPoint& ovalSize) :
- FW_CBoundedShapeRep(gGraphicGlobales.gRoundRect, rect),
- fOvalSize(ovalSize)
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::~FW_CRoundRectShapeRep
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShapeRep::~FW_CRoundRectShapeRep()
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::Draw
- //------------------------------------------------------------------------------
-
- void FW_CRoundRectShapeRep::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);
- FW_SPlatformPoint ovalSize = graphicContext->AsPlatformPoint(fOvalSize);
-
- #ifdef FW_BUILD_MAC
- if (shapeFill == FW_kFramed)
- ::FrameRoundRect(&rect, ovalSize.h, ovalSize.v);
- else
- ::PaintRoundRect(&rect, ovalSize.h, ovalSize.v);
- #endif
- #ifdef FW_BUILD_WIN
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::DrawRoundRect
- //------------------------------------------------------------------------------
-
- void FW_CRoundRectShapeRep::DrawRoundRect(FW_CGraphicContext* graphicContext,
- const FW_CRect& rect,
- const FW_CPoint& ovalSize)
- {
- if (gGraphicGlobales.gRoundRect.fFill == FW_kNullShape)
- return;
-
- graphicContext->SelectInkAndStyle(gGraphicGlobales.gRoundRect.fInk, gGraphicGlobales.gRoundRect.fStyle, FW_kGeometricShape, gGraphicGlobales.gRoundRect.fFill);
-
- FW_SPlatformRect qdRect = graphicContext->AsPlatformRect(rect);
- FW_SPlatformPoint qdOvalSize = graphicContext->AsPlatformPoint(ovalSize);
-
- #ifdef FW_BUILD_MAC
- if (gGraphicGlobales.gRoundRect.fFill == FW_kFramed)
- ::FrameRoundRect(&qdRect, qdOvalSize.h, qdOvalSize.v);
- else
- ::PaintRoundRect(&qdRect, qdOvalSize.h, qdOvalSize.v);
- #endif
- #ifdef FW_BUILD_WIN
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::Copy
- //------------------------------------------------------------------------------
-
- FW_CRoundRectShape FW_CRoundRectShapeRep::Copy() const
- {
- FW_CRoundRectShape roundRect(fRect, fOvalSize);
- return roundRect;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::SetAsDefault
- //------------------------------------------------------------------------------
-
- void FW_CRoundRectShapeRep::SetAsDefault() const
- {
- SetDefaultProperties(gGraphicGlobales.gRoundRect);
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::HitTest
- //------------------------------------------------------------------------------
-
- FW_HitTestPart FW_CRoundRectShapeRep::HitTest(const FW_CPoint& test) const
- {
- return FW_kOutside;
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShapeRep::Flatten(FW_CWritableStream& stream)
- {
- FW_CBoundedShapeRep::Flatten(stream);
- fOvalSize.Flatten(stream);
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_CRoundRectShapeRep::Unflatten
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShapeRep::Unflatten(FW_CReadableStream& stream)
- {
- FW_CBoundedShapeRep::Unflatten(stream);
- fOvalSize.Unflatten(stream);
- }
-
-
-