home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 5.8 KB | 198 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWBndShp.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWBNDSHP_H
- #include "FWBndShp.h"
- #endif
-
- #ifndef FWGRGLOB_H
- #include "FWGrGlob.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _TRANSFORM_
- #include <Trnsform.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphxshape
- #endif
-
- FW_DEFINE_CLASS_M1(FW_CBoundedShape, FW_CShape)
-
- //========================================================================================
- // class FW_CBoundedShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::FW_CBoundedShape
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape::FW_CBoundedShape(const FW_CBoundedShape& other) :
- FW_CShape(other),
- fRect(other.fRect)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::FW_CBoundedShape
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape::FW_CBoundedShape(const FW_CRect& rect,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style,
- const FW_PFont& font) :
- FW_CShape(renderVerb, ink, style, font),
- fRect(rect)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::FW_CBoundedShape
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape::FW_CBoundedShape(FW_CReadableStream& archive) :
- FW_CShape(archive)
- {
- archive >> fRect;
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::~FW_CBoundedShape
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape::~FW_CBoundedShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape& FW_CBoundedShape::operator=(const FW_CBoundedShape& other)
- {
- if (this != &other)
- {
- FW_CShape::operator=(other);
- fRect = other.fRect;
- }
-
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::HitTest
- //----------------------------------------------------------------------------------------
- // Only test if the point is inside the bounds
-
- FW_Boolean FW_CBoundedShape::HitTest(FW_CGraphicContext& gc,
- const FW_CPoint& test,
- FW_CFixed tolerance) const
- {
- if(fRenderVerb == FW_kNoRendering)
- return FALSE;
-
- FW_CRect bounds(fRect);
- bounds.Inset(-tolerance, -tolerance);
- return bounds.Contains(test);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::Transform
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::Transform(Environment *ev, ODTransform* transform)
- {
- fRect.Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::Inset
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::Inset(FW_CFixed h, FW_CFixed v)
- {
- fRect.Inset(h, v);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::GetBounds
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::GetBounds(FW_CGraphicContext& gc, FW_CRect& rect) const
- {
- FW_UNUSED(gc);
-
- rect = fRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::InverseTransform
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::InverseTransform(Environment *ev, ODTransform* transform)
- {
- fRect.InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::MoveShape
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::MoveShape(FW_CFixed deltaX, FW_CFixed deltaY)
- {
- fRect.left += deltaX;
- fRect.top += deltaY;
- fRect.right += deltaX;
- fRect.bottom += deltaY;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::MoveShapeTo
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::MoveShapeTo(FW_CFixed x, FW_CFixed y)
- {
- fRect.right += x - fRect.left;
- fRect.bottom += y - fRect.top;
- fRect.left = x;
- fRect.top = y;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::Flatten(FW_CWritableStream& archive) const
- {
- FW_CShape::Flatten(archive);
- archive << fRect;
- }
-
-