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 / Idling / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-03-26  |  3.6 KB  |  132 lines  |  [TEXT/CWIE]

  1. //    Copyright © 1995 Apple Computer, Inc. All rights reserved.
  2. //    Release Version:    $ 1.0 d11 $
  3.  
  4. //=======================================================================
  5. #ifndef FRAME_H
  6. #include "Frame.h"
  7. #endif
  8.  
  9. #ifndef PART_H
  10. #include "Part.h"
  11. #endif
  12.  
  13. // ----- Framework Layer -----
  14. #ifndef FWUTIL_H
  15. #include "FWUtil.h"                // FW_CFacetContext, FW_Beep()
  16. #endif
  17.  
  18. #ifndef FWCONTXT_H
  19. #include "FWContxt.h"            // FW_CViewContext
  20. #endif
  21.  
  22. // ----- Graphic Includes -----
  23. #ifndef FWRECT_H
  24. #include <FWRect.h>                // FW_CRect
  25. #endif
  26.  
  27. #ifndef FWRECSHP_H
  28. #include "FWRecShp.h"            // FW_CRectShape
  29. #endif
  30.  
  31. #ifndef FWODGEOM_H
  32. #include "FWODGeom.h"
  33. #endif
  34.  
  35. //========================================================================================
  36. #ifdef FW_BUILD_MAC
  37. #pragma segment Idling
  38. #endif
  39.  
  40. //========================================================================================
  41. FW_DEFINE_AUTO(CIdlingFrame)
  42.  
  43. //========================================================================================
  44. CIdlingFrame::CIdlingFrame(Environment* ev, ODFrame* odFrame, 
  45.                                     FW_CPresentation* presentation, CIdlingPart* idlingPart)
  46.   : FW_CFrame(ev, odFrame, presentation, idlingPart),
  47.       fIdlingPart(idlingPart),
  48.       fRegionShape(NULL),
  49.       fDrawRed(TRUE)
  50. {
  51.     fRegionShape = MyCreateRegionShape(ev);
  52.     FW_END_CONSTRUCTOR
  53. }
  54.  
  55. //----------------------------------------------------------------------------------------
  56. CIdlingFrame::~CIdlingFrame()
  57. {
  58.     FW_START_DESTRUCTOR
  59.     delete fRegionShape;
  60. }
  61.  
  62. //------------------------------------------------------------------------------
  63. FW_CRegionShape*
  64. CIdlingFrame::MyCreateRegionShape(Environment* ev)
  65. {
  66.     const FW_CPoint kBotRight( FW_IntToFixed(25), FW_IntToFixed(25) );
  67.     const FW_CPoint kOffset( FW_IntToFixed(32), FW_IntToFixed(0) );
  68.     const FW_Fixed kInset = FW_IntToFixed(4);
  69.  
  70.     FW_CRect fwR1(FW_kZeroPoint, kBotRight);
  71.     FW_CAcquiredODShape odR1 = FW_NewODShape (ev, fwR1);
  72.     
  73.     FW_CRect fwR2(fwR1);
  74.     fwR2.Offset(kOffset);
  75.     fwR2.Inset(kInset);
  76.     ODShape* odR2 = FW_NewODShape (ev, fwR2);
  77.  
  78.     odR2->Union(ev, odR1);
  79.     FW_CRegionShape* shp = FW_NEW(FW_CRegionShape, (odR2, FW_kFill) );
  80.     return shp;
  81. }
  82.  
  83. //----------------------------------------------------------------------------------------
  84. void 
  85. CIdlingFrame::MyToggleColor()
  86. {
  87.     fDrawRed = !fDrawRed;
  88.     if (fDrawRed)
  89.         fRegionShape->GetInk().SetForeColor(FW_kRGBRed);
  90.     else
  91.         fRegionShape->GetInk().SetForeColor(FW_kRGBBlue);
  92. }
  93.  
  94. //----------------------------------------------------------------------------------------
  95. void 
  96. CIdlingFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)    // Override
  97. {
  98.     FW_CViewContext context(ev, this, odFacet, invalidShape);
  99.     fRegionShape->Render(context);
  100. }
  101.  
  102. //----------------------------------------------------------------------------------------
  103. FW_Boolean 
  104. CIdlingFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  105. {    
  106.     FW_Boolean handledEvent = false;
  107.     if (theMouseEvent.GetNumberOfClicks(ev) == 2) {
  108.         fIdlingPart->MyToggleIdling(ev);
  109.         handledEvent = true;
  110.         }
  111.     return handledEvent;
  112. }
  113.  
  114. //----------------------------------------------------------------------------------------
  115. ODShape* 
  116. CIdlingFrame::AdjustUsedShape(Environment* ev, ODShape* suggestedUsedShape)
  117. {        
  118.     ODShape* myUsedShape = fRegionShape->GetODShape()->Copy(ev);
  119.     return myUsedShape;
  120. }
  121.  
  122. //----------------------------------------------------------------------------------------
  123. //    [HLX] Because OpenDoc uses the Frame shape as the default active shape I need to 
  124. //    adjust my active shape too.
  125. ODShape* 
  126. CIdlingFrame::AdjustActiveShape(Environment* ev, ODFacet* facet, ODShape* suggestedActiveShape)
  127. {
  128.     suggestedActiveShape->Acquire(ev);
  129.     return suggestedActiveShape;
  130. }
  131.  
  132.