home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 8.5 KB | 289 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWRecShp.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.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 FWARCSHP_H
- #include "FWArcShp.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_CRectShape
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::FW_CRectShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::FW_CRectShape() :
- FW_CShape()
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::FW_CRectShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::FW_CRectShape(const FW_CRect& rect) :
- FW_CShape()
- {
- SetRep(new FW_CRectShapeRep(rect));
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::FW_CRectShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::FW_CRectShape(const FW_CRectShape& other) :
- FW_CShape(other)
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::FW_CRectShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::FW_CRectShape(FW_CRectShapeRep* other) :
- FW_CShape(other)
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::operator=
- //------------------------------------------------------------------------------
-
- FW_CRectShape& FW_CRectShape::operator=(const FW_CRectShape& other)
- {
- SetRep(other.GetRep());
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::operator=
- //------------------------------------------------------------------------------
-
- FW_CRectShape& FW_CRectShape::operator=(FW_CRectShapeRep* other)
- {
- SetRep(other);
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::operator FW_COvalShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::operator FW_COvalShape() const
- {
- FW_COvalShape ovalShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
- ovalShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return ovalShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::operator FW_CRoundRectShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::operator FW_CRoundRectShape() const
- {
- FW_CRoundRectShape roundRectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), FW_kZeroPoint);
- roundRectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return roundRectShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::operator FW_CArcShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::operator FW_CArcShape() const
- {
- FW_CArcShape arcShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), 0, 0);
- arcShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return arcShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_CRectShape::operator FW_CLineShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::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_CRectShape::operator FW_CRegionShape
- //------------------------------------------------------------------------------
-
- FW_CRectShape::operator FW_CRegionShape() const
- {
- FW_CRegionShape regionShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
- regionShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return regionShape;
- }
-
- //==============================================================================
- // •• class FW_CRectShapeRep
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • FW_CRectShapeRep::FW_CRectShapeRep
- //------------------------------------------------------------------------------
-
- FW_CRectShapeRep::FW_CRectShapeRep() :
- FW_CBoundedShapeRep(gGraphicGlobales.gRect, FW_CRect(0,0,0,0))
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRectShapeRep::FW_CRectShapeRep
- //------------------------------------------------------------------------------
-
- FW_CRectShapeRep::FW_CRectShapeRep(const FW_CRect& rect) :
- FW_CBoundedShapeRep(gGraphicGlobales.gRect, rect)
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRectShapeRep::~FW_CRectShapeRep
- //------------------------------------------------------------------------------
-
- FW_CRectShapeRep::~FW_CRectShapeRep()
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRectShapeRep::Draw
- //------------------------------------------------------------------------------
-
- void FW_CRectShapeRep::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)
- ::FrameRect(&rect);
- else
- ::PaintRect(&rect);
- #endif
- #ifdef FW_BUILD_WIN
- ::Rectangle(graphicContext->GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRectShapeRep::DrawRect
- //------------------------------------------------------------------------------
-
- void FW_CRectShapeRep::DrawRect(FW_CGraphicContext* graphicContext, const FW_CRect& rect)
- {
- if (gGraphicGlobales.gRect.fFill == FW_kNullShape)
- return;
-
- graphicContext->SelectInkAndStyle(gGraphicGlobales.gRect.fInk,
- gGraphicGlobales.gRect.fStyle,
- FW_kGeometricShape,
- gGraphicGlobales.gRect.fFill);
-
- FW_SPlatformRect qdRect = graphicContext->AsPlatformRect(rect);
-
- #ifdef FW_BUILD_MAC
- if (gGraphicGlobales.gRect.fFill == FW_kFramed)
- ::FrameRect(&qdRect);
- else
- ::PaintRect(&qdRect);
- #endif
- #ifdef FW_BUILD_WIN
- ::Rectangle(graphicContext->GetHDC(), qdRect.left, qdRect.top, qdRect.right, qdRect.bottom);
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRectShapeRep::SetAsDefault
- //------------------------------------------------------------------------------
-
- void FW_CRectShapeRep::SetAsDefault() const
- {
- SetDefaultProperties(gGraphicGlobales.gRect);
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRectShapeRep::HitTest
- //------------------------------------------------------------------------------
-
- FW_HitTestPart FW_CRectShapeRep::HitTest(const FW_CPoint& test) const
- {
- return FW_kOutside;
- }
-
- //------------------------------------------------------------------------------
- // • FW_CRectShapeRep::Copy
- //------------------------------------------------------------------------------
-
- FW_CRectShape FW_CRectShapeRep::Copy() const
- {
- FW_CRectShape rect(fRect);
- return rect;
- }
-