home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.0 KB | 179 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWRecShp.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.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_RectShape
- #endif
-
- //========================================================================================
- // class FW_CRectShape
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CRectShape)
- FW_DEFINE_CLASS_M1(FW_CRectShape, 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_CRectShape::FW_CRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRectShape::FW_CRectShape() :
- FW_CBoundedShape(FW_kZeroRect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRectShape::FW_CRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRectShape::FW_CRectShape(const FW_CRectShape& other) :
- FW_CBoundedShape(other)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRectShape::FW_CRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRectShape::FW_CRectShape(const FW_CRect& rect,
- FW_ERenderVerbs renderVerb,
- const FW_CInk& ink,
- const FW_CStyle& style) :
- FW_CBoundedShape(rect, renderVerb, ink, style, FW_kNormalFont)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRectShape::FW_CRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRectShape::FW_CRectShape(FW_CReadableStream& stream) :
- FW_CBoundedShape(stream)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRectShape::~FW_CRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRectShape::~FW_CRectShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRectShape::Render
- //----------------------------------------------------------------------------------------
-
- void FW_CRectShape::Render(FW_CGraphicContext& gc) const
- {
- FW_PrivRenderRect(gc.GetEnvironment(),
- gc,
- fRect,
- GetRenderVerb(),
- fInk,
- fStyle);
- FW_FailOnEvError(gc.GetEnvironment());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRectShape::RenderRect
- //----------------------------------------------------------------------------------------
-
- void FW_CRectShape::RenderRect(FW_CGraphicContext& gc,
- const FW_CRect& rect,
- FW_ERenderVerbs renderVerb,
- const FW_CInk& ink,
- const FW_CStyle& style)
- {
- FW_PrivRenderRect(gc.GetEnvironment(),
- gc,
- rect,
- renderVerb,
- ink,
- style);
- FW_FailOnEvError(gc.GetEnvironment());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRectShape::HitTest
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CRectShape::HitTest(FW_CGraphicContext& gc,
- const FW_CPoint& test,
- FW_Fixed tolerance) const
- {
- if (FW_CBoundedShape::HitTest(gc, test, tolerance))
- {
- if (fRenderVerb == FW_kFrame)
- {
- FW_CRect bounds(fRect);
- FW_Fixed inset = tolerance + GetPenSize();
- bounds.Inset(inset, inset);
- return ! bounds.Contains(test);
- }
-
- return TRUE;
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRectShape::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CShape* FW_CRectShape::Copy() const
- {
- return FW_NEW(FW_CRectShape, (*this));
- }
-