home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-29 | 2.5 KB | 102 lines | [TEXT/MPS ] |
- // Copyright © 1995 Apple Computer, Inc. All rights reserved.
- // Release Version: $ 1.0 d11 $
-
- //==========================================================================
- #ifndef DUSELECTABLE_H
- #include "DUSelectable.h" // MSelectable
- #endif
-
- // ----- Foundation Layer -----
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- //==========================================================================
- FW_DEFINE_CLASS_M0(DU_MSelectable)
-
- FW_REGISTER_ARCHIVABLE_CLASS(LSelectable, DU_MSelectable, DU_MSelectable::Read, DU_MSelectable::Write)
-
- //--------------------------------------------------------------------------
- DU_MSelectable::DU_MSelectable(const FW_CRect& bounds)
- : fBounds(bounds),
- fSelected(FALSE)
- {
- }
-
- //--------------------------------------------------------------------------
- DU_MSelectable::DU_MSelectable(FW_CReadableStream& stream)
- {
- stream >> fBounds;
- fSelected = FALSE;
- }
-
- //--------------------------------------------------------------------------
- DU_MSelectable::~DU_MSelectable()
- {
- }
-
- //--------------------------------------------------------------------------
- void
- DU_MSelectable::Flatten(FW_CWritableStream& stream)
- {
- stream << fBounds;
- }
-
- //--------------------------------------------------------------------------
- void
- DU_MSelectable::Write(FW_CWritableStream& stream, const void* objectRep)
- {
- ((DU_MSelectable*)objectRep)->Flatten(stream);
- }
-
- //--------------------------------------------------------------------------
- void *
- DU_MSelectable::Read(FW_CReadableStream& stream)
- {
- return new DU_MSelectable(stream);
- }
-
- //--------------------------------------------------------------------------
- void
- DU_MSelectable::Draw(FW_CGraphicContext& gc)
- {
- }
-
- //--------------------------------------------------------------------------
- void
- DU_MSelectable::DrawSelectionFeedback(FW_CGraphicContext& gc)
- {
- if ( this->IsSelected() ) {
- FW_PInk ink(FW_kRGBDarkGray);
- FW_CRectShape::RenderRect(gc, fBounds, FW_kFrame, ink);
- }
- }
-
- //--------------------------------------------------------------------------
- FW_CRect
- DU_MSelectable::GetBounds()
- {
- return fBounds;
- }
-
- //--------------------------------------------------------------------------
- FW_Boolean
- DU_MSelectable::Hit(Environment *ev, const FW_CPoint& pt)
- {
- return fBounds.Contains(pt);
- }
-
- //--------------------------------------------------------------------------
- FW_Boolean
- DU_MSelectable::IsSelected()
- {
- return fSelected;
- }
-
- //--------------------------------------------------------------------------
- void
- DU_MSelectable::Select(FW_Boolean newState)
- {
- fSelected = newState;
- }
-