home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Developer University / DUProjects / DataSave / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-04-07  |  3.4 KB  |  129 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 1 $
  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 FWEVENTU_H
  31. #include "FWEventU.h"            // FW_IsCommandKeyPressed
  32. #endif
  33.  
  34. // ----- OS Layer -----
  35. #ifndef FWCFMRES_H
  36. #include "FWCFMRes.h"            // FW_CSharedLibraryResourceFile, FW_gInstance
  37. #endif
  38.  
  39. #ifndef FWMENU_H
  40. #include "FWMenu.h"                // FW_CMenuBar, etc.
  41. #endif
  42.  
  43. #ifndef FWEVENT_H
  44. #include "FWEvent.h"            // FW_CMenuEvent, FW_CMouseEvent
  45. #endif
  46.  
  47. #ifndef FWRECSHP_H
  48. #include "FWRecShp.h"            // FW_CRectShape
  49. #endif
  50.  
  51. #ifndef FWPICSHP_H
  52. #include "FWPicShp.h"            // FW_PPicture, FW_CPictureShape
  53. #endif
  54.  
  55. #ifndef FWRRCSHP_H
  56. #include "FWRRcShp.h"            // FW_CRoundRectShape
  57. #endif
  58.  
  59. #ifndef FWCMD_H
  60. #include "FWCmd.h"                // FW_CCommand
  61. #endif
  62.  
  63. #include "ShapeB.xh"
  64.  
  65. //========================================================================================
  66. #ifdef FW_BUILD_MAC
  67. #pragma segment DataSave
  68. #endif
  69.  
  70. FW_DEFINE_AUTO(CDataSaveFrame)
  71.  
  72. //========================================================================================
  73. CDataSaveFrame::CDataSaveFrame(Environment* ev, ODFrame* odFrame, 
  74.                                     FW_CPresentation* presentation, CDataSaveContent* content)
  75.   : FW_CFrame(ev, odFrame, presentation, content->GetPart(ev)),
  76.     fDataSaveContent(content)
  77. {
  78. }
  79.  
  80. //----------------------------------------------------------------------------------------
  81. CDataSaveFrame::~CDataSaveFrame()
  82. {
  83. }
  84.  
  85. //----------------------------------------------------------------------------------------
  86. FW_Boolean 
  87. CDataSaveFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  88. {    
  89.     FW_UNUSED(ev);
  90.     FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  91.     this->GetContentView(ev)->FrameToViewContent(ev, where);    
  92.     if (::FW_IsShiftKeyPressed()) {
  93.         fDataSaveContent->MyIncrement(ev, where);    // no Undo
  94.         }
  95.     else {
  96.         CPizzaCommand* cmd = FW_NEW(CPizzaCommand, (ev, cMakePizzaCmd, this, 
  97.                                                 fDataSaveContent, where) );
  98.         cmd->Execute(ev);
  99.         }
  100.     return true;
  101. }
  102.  
  103. //----------------------------------------------------------------------------------------
  104. void 
  105. CDataSaveFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)    // Override
  106. {
  107.     FW_CViewContext context(ev, this, odFacet, invalidShape);
  108.     FW_CRect invalidRect = FW_GetShapeBoundingBox(ev, invalidShape);
  109.     FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kRGBLightGray);
  110. //    FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kWhiteEraseInk);
  111.     
  112.     // draw pizzas
  113.     CPizzaCollection* list = fDataSaveContent->MyGetPizzaList();
  114.     CPizzaCollectionIterator iter(list);
  115.     CPizza* pizza = NULL;
  116.     ODShape* shape = NULL;
  117.     for (pizza = (CPizza*) iter.First(); iter.IsNotComplete(); pizza = (CPizza*) iter.Next()) {
  118.         if (::FW_IsCommandKeyPressed()) {
  119.             FW_CAcquiredODShape rectShape = ::FW_NewODShape(ev, pizza->GetBounds());
  120.             shape = rectShape->Intersect(ev, invalidShape);
  121.             if ( ! shape->IsEmpty(ev) ) 
  122.                 pizza->Draw(context);
  123.             }
  124.         else 
  125.             if (invalidRect.IsIntersecting( pizza->GetBounds() ) )
  126.                 pizza->Draw(context);
  127.         }
  128. }
  129.