home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.5 KB | 228 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWRRcShp.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef SLGRGLOB_H
- #include "SLGrGlob.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef SLRENDER_H
- #include "SLRender.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- //========================================================================================
- // File scope definitions
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_RoundRectShape
- #endif
-
- //========================================================================================
- // class FW_CRoundRectShape
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CRoundRectShape)
- FW_DEFINE_CLASS_M1(FW_CRoundRectShape, FW_CBoundedShape)
-
- // This class is archivable, but we provide the archiving implementation in a separate
- // translation unit in order to enable deadstripping of the archiving-related code
- // in parts that do not use archiving with this class.
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(const FW_CRoundRectShape& other) :
- FW_CBoundedShape(other),
- fOvalSize(other.fOvalSize)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(const FW_CRect& rect,
- const FW_CPoint& ovalSize,
- FW_ERenderVerbs renderVerb,
- const FW_CInk& ink,
- const FW_CStyle& style) :
- FW_CBoundedShape(rect, renderVerb, ink, style, FW_kNormalFont),
- fOvalSize(ovalSize)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(FW_CReadableStream& stream) :
- FW_CBoundedShape(stream)
- {
- stream >> fOvalSize;
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::~FW_CRoundRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape::~FW_CRoundRectShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape& FW_CRoundRectShape::operator=(const FW_CRoundRectShape& other)
- {
- if (this != &other)
- {
- FW_CBoundedShape::operator=(other);
- fOvalSize = other.fOvalSize;
- }
-
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::Render
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::Render(FW_CGraphicContext& gc) const
- {
- FW_PrivRenderRoundRect(gc.GetEnvironment(),
- gc,
- fRect, fOvalSize,
- GetRenderVerb(),
- fInk,
- fStyle);
- FW_FailOnEvError(gc.GetEnvironment());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::RenderRoundRect
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::RenderRoundRect(FW_CGraphicContext& gc,
- const FW_CRect& rect,
- const FW_CPoint& ovalSize,
- FW_ERenderVerbs renderVerb,
- const FW_CInk& ink,
- const FW_CStyle& style)
- {
- FW_PrivRenderRoundRect(gc.GetEnvironment(),
- gc,
- rect, ovalSize,
- renderVerb,
- ink,
- style);
- FW_FailOnEvError(gc.GetEnvironment());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::HitTest
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CRoundRectShape::HitTest(FW_CGraphicContext& gc,
- const FW_CPoint& test,
- FW_Fixed tolerance) const
- {
- FW_UNUSED(gc);
-
- if(fRenderVerb == FW_kNoRendering)
- return FALSE;
-
- FW_CRect bounds(fRect);
- bounds.Inset(-tolerance, -tolerance);
-
- if(::FW_PtInRoundRect(bounds, fOvalSize, test))
- {
- if (fRenderVerb == FW_kFrame)
- {
- FW_Fixed inset = tolerance + GetPenSize();
- bounds = fRect;
- bounds.Inset(inset, inset);
- return !::FW_PtInRoundRect(bounds, fOvalSize, test);
- }
-
- return TRUE;
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CShape* FW_CRoundRectShape::Copy() const
- {
- return FW_NEW(FW_CRoundRectShape, (*this));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::GetGeometry
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::GetGeometry(FW_CRect& rect, FW_CPoint& ovalSize) const
- {
- ovalSize = fOvalSize;
- rect = fRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::SetGeometry
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::SetGeometry(const FW_CRect& rect, const FW_CPoint& ovalSize)
- {
- fOvalSize = ovalSize;
- fRect = rect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::Flatten(FW_CWritableStream& stream) const
- {
- FW_CBoundedShape::Flatten(stream);
- stream << fOvalSize;
- }
-
-