home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / DU Folder / DU Selection FW / Sources / DUSelectable.cpp < prev   
Encoding:
Text File  |  1995-11-29  |  2.5 KB  |  102 lines  |  [TEXT/MPS ]

  1. //    Copyright © 1995 Apple Computer, Inc. All rights reserved.
  2. //    Release Version:    $ 1.0 d11 $
  3.  
  4. //==========================================================================
  5. #ifndef DUSELECTABLE_H
  6. #include "DUSelectable.h"        // MSelectable
  7. #endif
  8.  
  9. // ----- Foundation Layer -----
  10. #ifndef FWSTREAM_H
  11. #include "FWStream.h"
  12. #endif
  13.  
  14. //==========================================================================
  15. FW_DEFINE_CLASS_M0(DU_MSelectable)
  16.  
  17. FW_REGISTER_ARCHIVABLE_CLASS(LSelectable, DU_MSelectable, DU_MSelectable::Read, DU_MSelectable::Write)
  18.  
  19. //--------------------------------------------------------------------------
  20. DU_MSelectable::DU_MSelectable(const FW_CRect& bounds)
  21.  :    fBounds(bounds),
  22.      fSelected(FALSE)
  23. {
  24. }
  25.  
  26. //--------------------------------------------------------------------------
  27. DU_MSelectable::DU_MSelectable(FW_CReadableStream& stream)
  28. {
  29.     stream >> fBounds;
  30.     fSelected = FALSE;
  31. }
  32.  
  33. //--------------------------------------------------------------------------
  34. DU_MSelectable::~DU_MSelectable()
  35. {
  36. }
  37.  
  38. //--------------------------------------------------------------------------
  39. void 
  40. DU_MSelectable::Flatten(FW_CWritableStream& stream)
  41. {    
  42.     stream << fBounds;
  43. }
  44.  
  45. //--------------------------------------------------------------------------
  46. void
  47. DU_MSelectable::Write(FW_CWritableStream& stream, const void* objectRep)
  48. {
  49.      ((DU_MSelectable*)objectRep)->Flatten(stream);
  50. }
  51.  
  52. //--------------------------------------------------------------------------
  53. void *
  54. DU_MSelectable::Read(FW_CReadableStream& stream)
  55. {
  56.     return new DU_MSelectable(stream);
  57. }
  58.  
  59. //--------------------------------------------------------------------------
  60. void    
  61. DU_MSelectable::Draw(FW_CGraphicContext& gc)
  62. {
  63. }
  64.  
  65. //--------------------------------------------------------------------------
  66. void    
  67. DU_MSelectable::DrawSelectionFeedback(FW_CGraphicContext& gc)
  68. {
  69.     if ( this->IsSelected() ) {
  70.         FW_PInk ink(FW_kRGBDarkGray);
  71.         FW_CRectShape::RenderRect(gc, fBounds, FW_kFrame, ink);
  72.     }
  73. }
  74.  
  75. //--------------------------------------------------------------------------
  76. FW_CRect    
  77. DU_MSelectable::GetBounds()
  78. {
  79.     return fBounds;
  80. }
  81.  
  82. //--------------------------------------------------------------------------
  83. FW_Boolean    
  84. DU_MSelectable::Hit(Environment *ev, const FW_CPoint& pt)
  85. {
  86.     return fBounds.Contains(pt);
  87. }
  88.  
  89. //--------------------------------------------------------------------------
  90. FW_Boolean    
  91. DU_MSelectable::IsSelected()
  92. {
  93.     return fSelected;
  94. }
  95.  
  96. //--------------------------------------------------------------------------
  97. void    
  98. DU_MSelectable::Select(FW_Boolean newState)
  99. {
  100.     fSelected = newState;
  101. }
  102.