home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 9.7 KB | 295 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWShLiSh.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWSHLISH_H
- #include "FWShLiSh.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_ShapeListShape
- #endif
-
- FW_DEFINE_CLASS_M1(FW_CShapeListShape, FW_CShape)
- FW_REGISTER_ARCHIVABLE_CLASS(FW_LShapeListShape, FW_CShapeListShape, FW_CShapeListShape::Read, FW_CShape::Write)
-
- //========================================================================================
- // class FW_CShapeListShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::FW_CShapeListShape
- //----------------------------------------------------------------------------------------
-
- FW_CShapeListShape::FW_CShapeListShape(const FW_PShapeList& list) :
- FW_CShape(FW_kFrame, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
- fShapeList(list)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::FW_CShapeListShape
- //----------------------------------------------------------------------------------------
-
- FW_CShapeListShape::FW_CShapeListShape(FW_CReadableStream& archive) :
- FW_CShape(archive),
- fShapeList(archive)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::FW_CShapeListShape
- //----------------------------------------------------------------------------------------
-
- FW_CShapeListShape::FW_CShapeListShape(const FW_CShapeListShape& other) :
- FW_CShape(FW_kFrame, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
- fShapeList(other.fShapeList)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::~FW_CShapeListShape
- //----------------------------------------------------------------------------------------
-
- FW_CShapeListShape::~FW_CShapeListShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::HitTestList
- //----------------------------------------------------------------------------------------
-
- FW_CShape* FW_CShapeListShape::HitTestList(FW_CGraphicContext& gc,
- const FW_CPoint& test,
- FW_CFixed tolerance) const
- {
- FW_CShape* shape = NULL;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kFrontToBack, fShapeList);
- while((shape = ite.Next()) != NULL)
- {
- if(shape->HitTest(gc, test, tolerance))
- break;
- }
-
- return shape;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CShapeListShape& FW_CShapeListShape::operator=(const FW_CShapeListShape& other)
- {
- fShapeList = other.fShapeList;
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::GetShapeList
- //----------------------------------------------------------------------------------------
-
- FW_PShapeList FW_CShapeListShape::GetShapeList() const
- {
- return fShapeList;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::SetShapeList
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::SetShapeList(const FW_PShapeList& list)
- {
- fShapeList = list;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::Purge
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::Purge()
- {
- FW_CShape* shape;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kFrontToBack, fShapeList);
- while((shape = ite.Next()) != NULL)
- shape->Purge();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::Render
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::Render(FW_CGraphicContext& gc) const
- {
- FW_CShape* shape;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kBackToFront, fShapeList);
- while((shape = ite.Next()) != NULL)
- shape->Render(gc);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::Render
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::RenderShapeList(FW_CGraphicContext& gc,
- const FW_PShapeList& shapeList)
- {
- FW_CShape* shape;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kBackToFront, shapeList);
- while((shape = ite.Next()) != NULL)
- shape->Render(gc);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CShape* FW_CShapeListShape::Copy() const
- {
- return FW_NEW(FW_CShapeListShape, (*this));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::HitTest
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CShapeListShape::HitTest(FW_CGraphicContext& gc,
- const FW_CPoint& test,
- FW_CFixed tolerance) const
- {
- if (GetRenderVerb() == FW_kNoRendering)
- return NULL;
-
- return HitTestList(gc, test, tolerance) != NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::Transform
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::Transform(Environment *ev, ODTransform* transform)
- {
- FW_CShape* shape;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kFrontToBack, fShapeList);
- while((shape = ite.Next()) != NULL)
- shape->Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::InverseTransform
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::InverseTransform(Environment *ev, ODTransform* transform)
- {
- FW_CShape* shape;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kFrontToBack, fShapeList);
- while((shape = ite.Next()) != NULL)
- shape->InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::MoveShape
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::MoveShape(FW_CFixed deltaX, FW_CFixed deltaY)
- {
- FW_CShape* shape;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kFrontToBack, fShapeList);
- while((shape = ite.Next()) != NULL)
- shape->MoveShape(deltaX, deltaY);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::MoveShapeTo
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::MoveShapeTo(FW_CFixed x, FW_CFixed y)
- {
- FW_CShape* shape;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kFrontToBack, fShapeList);
- while((shape = ite.Next()) != NULL)
- shape->MoveShapeTo(x, y);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::Inset
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::Inset(FW_CFixed h, FW_CFixed v)
- {
- FW_CShape* shape;
- FW_CShapeListIterator ite(FW_CShapeListIterator::kFrontToBack, fShapeList);
- while((shape = ite.Next()) != NULL)
- shape->Inset(h, v);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::GetBounds
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::GetBounds(FW_CGraphicContext& gc, FW_CRect& rect) const
- {
- FW_CShapeListIterator ite(FW_CShapeListIterator::kFrontToBack, fShapeList);
- FW_CShape* shape = ite.First();
-
- if(shape == NULL)
- {
- rect.SetInt(0, 0, 0, 0);
- }
- else
- {
- shape->GetBounds(gc, rect);
-
- while((shape = ite.Next()) != NULL)
- {
- FW_CRect bounds;
- shape->GetBounds(gc, bounds);
- rect.Union(bounds);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CShapeListShape::Flatten(FW_CWritableStream& archive) const
- {
- FW_CShape::Flatten(archive);
- fShapeList->Flatten(archive);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShapeListShape::Read
- //----------------------------------------------------------------------------------------
-
- void* FW_CShapeListShape::Read(FW_CReadableStream& archive)
- {
- FW_CShapeListShape* rep = FW_NEW(FW_CShapeListShape, (archive));
- return rep;
- }
-