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 / DataSave / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-08-22  |  3.1 KB  |  114 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. #ifndef COMMANDS_H
  18. #include "Commands.h"            // CPizzaCommand
  19. #endif
  20.  
  21. #ifndef DEFINES_K
  22. #include "Defines.k"            // command numbers
  23. #endif
  24.  
  25. // ----- Framework Layer -----
  26. #ifndef FWCONTXT_H
  27. #include "FWContxt.h"            // FW_CViewContext
  28. #endif
  29.  
  30. #ifndef FWEVENT_H
  31. #include "FWEvent.h"            // FW_CMenuEvent, FW_CMouseEvent
  32. #endif
  33.  
  34. #ifndef FWEVENTU_H
  35. #include "FWEventU.h"            // FW_IsCommandKeyPressed
  36. #endif
  37.  
  38. // ----- OS Layer -----
  39. #ifndef FWODGEOM_H
  40. #include "FWODGeom.h"            // FW_NewODShape
  41. #endif
  42.  
  43. #ifndef FWACQUIR_H
  44. #include "FWAcquir.h"            // FW_CAcquiredODShape
  45. #endif
  46.  
  47. #ifndef FWRECSHP_H
  48. #include "FWRecShp.h"            // FW_CRectShape
  49. #endif
  50.  
  51. //========================================================================================
  52. #ifdef FW_BUILD_MAC
  53. #pragma segment DataSave
  54. #endif
  55.  
  56. FW_DEFINE_AUTO(CDataSaveFrame)
  57.  
  58. //========================================================================================
  59. CDataSaveFrame::CDataSaveFrame(Environment* ev, ODFrame* odFrame, 
  60.                                 FW_CPresentation* presentation, CDataSaveContent* content)
  61.   : FW_CFrame(ev, odFrame, presentation, content->GetPart(ev)),
  62.     fDataSaveContent(content)
  63. {
  64. }
  65.  
  66. //----------------------------------------------------------------------------------------
  67. CDataSaveFrame::~CDataSaveFrame()
  68. {
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. FW_Handled 
  73. CDataSaveFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  74. {    
  75.     FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  76.     this->GetContentView(ev)->FrameToViewContent(ev, where);    
  77.     if (::FW_IsShiftKeyPressed()) {
  78.         fDataSaveContent->MyIncrement(ev, where);    // no Undo
  79.         }
  80.     else {
  81.         CPizzaCommand* cmd = FW_NEW(CPizzaCommand, (ev, cMakePizzaCmd, this, 
  82.                                                 fDataSaveContent, where) );
  83.         cmd->Execute(ev);
  84.         }
  85.     return true;
  86. }
  87.  
  88. //----------------------------------------------------------------------------------------
  89. void 
  90. CDataSaveFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)    // Override
  91. {
  92.     FW_CViewContext context(ev, this, odFacet, invalidShape);
  93.     FW_CRect invalidRect = FW_GetShapeBoundingBox(ev, invalidShape);
  94.     FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kRGBLightGray);
  95. //    FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kWhiteEraseInk);
  96.     
  97.     // draw pizzas
  98.     CPizzaCollection* list = fDataSaveContent->MyGetPizzaList();
  99.     CPizzaCollectionIterator iter(list);
  100.     CPizza* pizza = NULL;
  101.     ODShape* shape = NULL;
  102.     for (pizza = (CPizza*) iter.First(); iter.IsNotComplete(); pizza = (CPizza*) iter.Next()) {
  103.         if (::FW_IsCommandKeyPressed()) {
  104.             FW_CAcquiredODShape rectShape = ::FW_NewODShape(ev, pizza->GetBounds());
  105.             shape = rectShape->Intersect(ev, invalidShape);
  106.             if ( ! shape->IsEmpty(ev) ) 
  107.                 pizza->Draw(context);
  108.             }
  109.         else 
  110.             if (invalidRect.IsIntersecting( pizza->GetBounds() ) )
  111.                 pizza->Draw(context);
  112.         }
  113. }
  114.