home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Developer University / DU Projects / Data / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-08-22  |  2.4 KB  |  88 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 2 $
  2. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //=======================================================================
  5. #ifndef PART_H
  6. #include "Part.h"
  7. #endif
  8.  
  9. #ifndef CONTENT_H
  10. #include "Content.h"
  11. #endif
  12.  
  13. #ifndef FRAME_H
  14. #include "Frame.h"
  15. #endif
  16.  
  17. // ----- Framework Layer -----
  18. #ifndef FWCONTXT_H
  19. #include "FWContxt.h"            // FW_CViewContext
  20. #endif
  21.  
  22. #ifndef FWEVENT_H
  23. #include "FWEvent.h"            // FW_CMenuEvent, FW_CMouseEvent
  24. #endif
  25.  
  26. #ifndef FWEVENTU_H
  27. #include "FWEventU.h"            // FW_IsCommandKeyPressed
  28. #endif
  29.  
  30. // ----- OS Layer -----
  31. #ifndef FWRECSHP_H
  32. #include "FWRecShp.h"            // FW_CRectShape
  33. #endif
  34.  
  35. //========================================================================================
  36. #ifdef FW_BUILD_MAC
  37. #pragma segment Data
  38. #endif
  39.  
  40. FW_DEFINE_AUTO(CDataFrame)
  41.  
  42. //========================================================================================
  43. CDataFrame::CDataFrame(Environment* ev, ODFrame* odFrame, 
  44.                                     FW_CPresentation* presentation, CDataContent* content)
  45.   : FW_CFrame(ev, odFrame, presentation, content->GetPart(ev)),
  46.     fDataContent(content)
  47. {
  48. }
  49.  
  50. //----------------------------------------------------------------------------------------
  51. CDataFrame::~CDataFrame()
  52. {
  53. }
  54.  
  55. //----------------------------------------------------------------------------------------
  56. void 
  57. CDataFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)    // Override
  58. {
  59.     FW_CViewContext context(ev, this, odFacet, invalidShape);
  60.     FW_CRect invalidRect = FW_GetShapeBoundingBox(ev, invalidShape);
  61.     FW_CRect frameRect = this->GetBounds(ev);
  62.     FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kRGBLightGray);
  63.     
  64.     // draw pizzas
  65.     CPizzaCollection* list = fDataContent->MyGetPizzaList();
  66.     CPizzaCollectionIterator iter(list);
  67.     CPizza* pizza = NULL;
  68.     for (pizza = iter.First(); iter.IsNotComplete(); pizza = iter.Next())
  69.         {
  70.         if (::FW_IsCommandKeyPressed()) 
  71.                 pizza->Draw(context);
  72.         else
  73.             if (invalidRect.IsIntersecting( pizza->GetBounds() ) )
  74.                 pizza->Draw(context);
  75.         }
  76. }
  77.  
  78. //----------------------------------------------------------------------------------------
  79. FW_Handled 
  80. CDataFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  81. {    
  82.     FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  83.     this->GetContentView(ev)->FrameToViewContent(ev, where);    
  84.     fDataContent->MyIncrement(ev, where);
  85.     return true;
  86. }
  87.  
  88.