home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Draw / Sources / DrawPrxy.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  21.2 KB  |  683 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawPrxy.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef DRAWPRXY_H
  15. #include "DrawPrxy.h"
  16. #endif
  17.  
  18. #ifndef DRAWPART_H
  19. #include "DrawPart.h"
  20. #endif
  21.  
  22. #ifndef DRAWFRM_H
  23. #include "DrawFrm.h"
  24. #endif
  25.  
  26. #ifndef BASESHP_H
  27. #include "BaseShp.h"
  28. #endif
  29.  
  30. #ifndef BOUNDSHP_H
  31. #include "BoundShp.h"
  32. #endif
  33.  
  34. #ifndef LINESHP_H
  35. #include "LineShp.h"
  36. #endif
  37.  
  38. #ifndef OVALSHP_H
  39. #include "OvalShp.h"
  40. #endif
  41.  
  42. #ifndef RECTSHP_H
  43. #include "RectShp.h"
  44. #endif
  45.  
  46. #ifndef RRECTSHP_H
  47. #include "RRectShp.h"
  48. #endif
  49.  
  50. #ifndef TEXTSHP_H
  51. #include "TextShp.h"
  52. #endif
  53.  
  54. #ifndef DRAWCLIP_H
  55. #include "DrawClip.h"
  56. #endif
  57.  
  58. #ifndef UTILS_H
  59. #include "Utils.h"
  60. #endif
  61.  
  62. // ----- Part Layer -----
  63.  
  64. #ifndef FWITERS_H
  65. #include "FWIters.h"
  66. #endif
  67.  
  68. #ifndef FWPXYITE_H
  69. #include "FWPxyIte.h"
  70. #endif
  71.  
  72. #ifndef FWUTIL_H
  73. #include "FWUtil.h"
  74. #endif
  75.  
  76. #ifndef FWPART_H
  77. #include "FWPart.h"
  78. #endif
  79.  
  80. #ifndef FWPRTITE_H
  81. #include "FWPrtIte.h"
  82. #endif
  83.  
  84. #ifndef FWPRESEN_H
  85. #include "FWPresen.h"
  86. #endif
  87.  
  88. #ifndef FWPXYFRM_H
  89. #include "FWPxyFrm.h"
  90. #endif
  91.  
  92. // ----- OS Layer -----
  93.  
  94. #ifndef FWRECT_H
  95. #include "FWRect.h"
  96. #endif
  97.  
  98. #ifndef FWODGEOM_H
  99. #include "FWODGeom.h"
  100. #endif
  101.  
  102. #ifndef FWEVENT_H
  103. #include "FWEvent.h"
  104. #endif
  105.  
  106. // ----- Foundation Includes -----
  107.  
  108. #ifndef FWSTREAM_H
  109. #include "FWStream.h"
  110. #endif
  111.  
  112. // ----- OpenDoc Includes -----
  113.  
  114. #ifndef SOM_ODShape_xh
  115. #include <Shape.xh>
  116. #endif
  117.  
  118. #ifndef SOM_ODTransform_xh
  119. #include <Trnsform.xh>
  120. #endif
  121.  
  122. //========================================================================================
  123. //    Runtime Information
  124. //========================================================================================
  125.  
  126. #ifdef FW_BUILD_MAC
  127. #pragma segment odfdraw
  128. #endif
  129.  
  130. FW_DEFINE_AUTO(CProxyShape)
  131. FW_DEFINE_CLASS_M1(CProxyShape, CRectShape)
  132.  
  133. const FW_ClassTypeConstant LProxyShape = FW_TYPE_CONSTANT('s','h','p','x');
  134. FW_REGISTER_ARCHIVABLE_CLASS(LProxyShape, CProxyShape, CProxyShape::Read, 0, 0, CBaseShape::Write)
  135.  
  136. //========================================================================================
  137. //    CProxyShape
  138. //========================================================================================
  139.  
  140. //----------------------------------------------------------------------------------------
  141. //    CProxyShape::CProxyShape
  142. //----------------------------------------------------------------------------------------
  143.  
  144. CProxyShape::CProxyShape(Environment* ev, const FW_CRect& rect, CDrawPart* drawPart) :
  145.     CRectShape(kProxyShape, kFillOnly),
  146.     FW_MProxy(ev, drawPart, drawPart->GetMainPresentation()),
  147.     fDrawPart(drawPart),
  148.     fFrozen(FALSE),
  149.     fFrameRect(rect)
  150. {
  151.     SetRectGeometry(rect);
  152.     
  153.     FW_END_CONSTRUCTOR
  154. }
  155.  
  156. //----------------------------------------------------------------------------------------
  157. // CProxyShape::CProxyShape
  158. //----------------------------------------------------------------------------------------
  159.  
  160. CProxyShape::CProxyShape(Environment* ev, CDrawPart* drawPart, FW_CReadableStream& archive) :
  161.     CRectShape(archive),
  162.     FW_MProxy(ev, drawPart, drawPart->GetMainPresentation()),
  163.     fDrawPart(drawPart),
  164.     fFrozen(FALSE)
  165. {
  166.     archive >> fFrameRect;
  167.  
  168.     FW_END_CONSTRUCTOR
  169. }
  170.  
  171. //----------------------------------------------------------------------------------------
  172. // CProxyShape::~CProxyShape
  173. //----------------------------------------------------------------------------------------
  174.  
  175. CProxyShape::~CProxyShape()
  176. {
  177.     FW_START_DESTRUCTOR
  178. }
  179.     
  180. //----------------------------------------------------------------------------------------
  181. //    CProxyShape::FrameShapeRequested
  182. //----------------------------------------------------------------------------------------
  183.  
  184. ODShape* CProxyShape::FrameShapeRequested(Environment* ev, 
  185.                                         FW_CEmbeddingFrame* embeddingFrame, 
  186.                                         ODFrame* odEmbeddedFrame, 
  187.                                         ODShape* requestedFrameShape)
  188. {
  189.     // ----- get the bounding box of the asked frame shape
  190.     FW_CRect frameRect = FW_GetShapeBoundingBox(ev, requestedFrameShape);
  191.     
  192.     fFrameRect.right = fFrameRect.left + frameRect.Width();
  193.     fFrameRect.bottom = fFrameRect.top + frameRect.Height();
  194.  
  195.     // ----- Invalidate the old used Shape in case the embedded frame doesn't do it-----
  196.     FW_CAcquiredODShape aqUsedShape = odEmbeddedFrame->AcquireUsedShape(ev, NULL);
  197.     odEmbeddedFrame->Invalidate(ev, aqUsedShape, NULL);
  198.     
  199.     // ----- Don't forget to bump the refcount
  200.     requestedFrameShape->Acquire(ev);
  201.     return requestedFrameShape;
  202. }
  203.  
  204. //----------------------------------------------------------------------------------------
  205. //    CProxyShape::UsedShapeChanged
  206. //----------------------------------------------------------------------------------------
  207.  
  208. void CProxyShape::UsedShapeChanged(Environment* ev, FW_CEmbeddingFrame* embeddingFrame, ODFrame* odEmbeddedFrame)
  209. {
  210.     FW_CAcquiredODShape aqFrameShape = odEmbeddedFrame->AcquireFrameShape(ev, NULL);
  211.     FW_CAcquiredODShape aqUsedShape = odEmbeddedFrame->AcquireUsedShape(ev, NULL);
  212.     
  213.     FW_CRect usedShapeRect = FW_GetShapeBoundingBox(ev, aqUsedShape);
  214.     FW_CRect newShapeRect = FW_GetShapeBoundingBox(ev, aqFrameShape);
  215.  
  216.     newShapeRect.Intersection(usedShapeRect);    
  217.     newShapeRect.Offset(fFrameRect.left, fFrameRect.top);
  218.  
  219.     // ----- Get previous update shape -----
  220.     FW_CAcquiredODShape aqInvalidShape = ::FW_NewODShape(ev);
  221.     GetUpdateBox(ev, aqInvalidShape);
  222.  
  223.     // ----- Set the geometry of the shape -----
  224.     SetRectGeometry(newShapeRect);
  225.         
  226.     // ----- Calculate the shape to update union minus intersection
  227.     {
  228.         FW_CAcquiredODShape aqNewUpdateBox = ::FW_NewODShape(ev);
  229.         GetUpdateBox(ev, aqNewUpdateBox);
  230.         
  231.         FW_CAcquiredODShape aqIntersect(aqInvalidShape->Copy(ev));
  232.         aqIntersect->Intersect(ev, aqNewUpdateBox);
  233.         
  234.         aqInvalidShape->Union(ev, aqNewUpdateBox);
  235.         
  236.         // ----- Clip our embedded facets using the union
  237.         CDrawFacetClipper facetClipper(ev, fDrawPart);
  238.         facetClipper.Clip(ev, embeddingFrame, aqInvalidShape);
  239.  
  240.         aqInvalidShape->Subtract(ev, aqIntersect);
  241.     }
  242.     
  243.     fDrawPart->GetMainPresentation()->Invalidate(ev, aqInvalidShape);
  244.     
  245.     // ----- Invalidate the difference
  246.     embeddingFrame->Invalidate(ev, aqInvalidShape);
  247. }
  248.  
  249. //----------------------------------------------------------------------------------------
  250. //    CProxyShape::MoveBefore
  251. //----------------------------------------------------------------------------------------
  252.  
  253. void CProxyShape::MoveBefore(Environment* ev, CProxyShape* before)
  254. {
  255.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  256.     FW_CAcquiredODPart aqBeforePart = before->AcquireEmbeddedPart(ev);
  257.  
  258.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  259.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  260.     {
  261.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  262.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  263.         {
  264.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  265.             if (aqODPart == aqEmbeddedPart)
  266.             {
  267.                 FW_CFacetIterator ite2(ev, facet, kODChildrenOnly, kODFrontToBack);
  268.                 for (ODFacet* facet2 = ite2.First(ev); ite2.IsNotComplete(ev); facet2 = ite2.Next(ev))
  269.                 {
  270.                     FW_CAcquiredODPart aqODPart2 = facet2->GetFrame(ev)->AcquirePart(ev);
  271.                     if (aqODPart2 == aqBeforePart)
  272.                     {
  273.                         facet->MoveBefore(ev, facet1, facet2);
  274.                         break;
  275.                     }
  276.                 }
  277.             }
  278.         }
  279.     }
  280. }
  281.  
  282. //----------------------------------------------------------------------------------------
  283. //    CProxyShape::MoveBehind
  284. //----------------------------------------------------------------------------------------
  285.  
  286. void CProxyShape::MoveBehind(Environment* ev, CProxyShape* behind)
  287. {    
  288.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  289.     FW_CAcquiredODPart aqBehindPart = behind->AcquireEmbeddedPart(ev);
  290.  
  291.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  292.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  293.     {
  294.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  295.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  296.         {
  297.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  298.             if (aqODPart == aqEmbeddedPart)
  299.             {
  300.                 FW_CFacetIterator ite2(ev, facet1, kODChildrenOnly, kODFrontToBack);
  301.                 for (ODFacet* facet2 = ite2.First(ev); ite2.IsNotComplete(ev); facet2 = ite2.Next(ev))
  302.                 {
  303.                     FW_CAcquiredODPart aqODPart2 = facet2->GetFrame(ev)->AcquirePart(ev);
  304.                     if (aqODPart2 == aqBehindPart)
  305.                     {
  306.                         facet->MoveBehind(ev, facet1, facet2);
  307.                         break;
  308.                     }
  309.                 }
  310.             }
  311.         }
  312.     }
  313. }
  314.  
  315. //----------------------------------------------------------------------------------------
  316. // CProxyShape::RestoreShape
  317. //----------------------------------------------------------------------------------------
  318.  
  319. void CProxyShape::RestoreShape(Environment *ev, CDrawPart* drawPart)
  320. {
  321.     CRectShape::RestoreShape(ev, drawPart);
  322.     
  323.     AttachEmbeddedFrames(ev);
  324. }
  325.  
  326. //----------------------------------------------------------------------------------------
  327. // CProxyShape::Removed
  328. //----------------------------------------------------------------------------------------
  329. //     the shape is going to be removed (for example for undo)
  330.  
  331. void CProxyShape::Removed(Environment* ev)
  332. {
  333.     CRectShape::Removed(ev);
  334.     
  335.     DetachEmbeddedFrames(ev);
  336. }
  337.  
  338. //----------------------------------------------------------------------------------------
  339. // CProxyShape::Deleted
  340. //----------------------------------------------------------------------------------------
  341. //     the shape is going to be deleted
  342.  
  343. void CProxyShape::Deleted(Environment* ev)
  344. {
  345.     CRectShape::Deleted(ev);
  346.     
  347.     RemoveEmbeddedFrames(ev);
  348. }
  349.  
  350. //----------------------------------------------------------------------------------------
  351. // CProxyShape::Flatten
  352. //----------------------------------------------------------------------------------------
  353.  
  354. void CProxyShape::Flatten(FW_CWritableStream& archive)
  355. {    
  356.     CRectShape::Flatten(archive);
  357.     
  358.     archive << fFrameRect;
  359.  
  360.     // [HLX] I know it's bad but I know I am archiving to a storage unit
  361.     CDrawWritableStream* drawArchive = (CDrawWritableStream*)&archive;
  362.     Externalize(drawArchive->GetEnvironment(), drawArchive->GetStorageUnitView(), drawArchive->GetCloneInfo());
  363. }
  364.  
  365. //----------------------------------------------------------------------------------------
  366. // CProxyShape::RenderShape
  367. //----------------------------------------------------------------------------------------
  368. //    Because there can be multiple CProxyShape pointing on an embedded
  369. //    frame, I only draw those belonging to this frame.
  370.  
  371. void CProxyShape::RenderShape(Environment *ev, ODFacet* facet, FW_CGraphicContext& gc)
  372. {
  373.     // if the canvas is not dynamic (printing) I let ODF/OpenDoc draw embedded facet
  374.     if (!facet->GetCanvas(ev)->IsDynamic(ev))
  375.         return;
  376.         
  377.     FW_CAcquiredODShape aqTempShape = ::FW_NewODShape(ev);
  378.     FW_CAcquiredODShape aqTempClipShape(gc.AcquireClip());    // GetClip returns a copy in content coordinate
  379.  
  380.     // ----- Because we are calling the draw method of an embedded facet, we want
  381.     // ----- to save our context. The embedded facet will be using the same grafport 
  382.     // ----- and may not be restoring it.    
  383.     FW_CSaveRestoreContext src(gc);
  384.     
  385.     FW_CEmbeddedODFacetsIterator ite(ev, this, facet, kODFrontToBack);
  386.     for (ODFacet *embeddedODFacet = ite.First(ev); ite.IsNotComplete(ev); embeddedODFacet = ite.Next(ev))
  387.     {    
  388.         aqTempShape->CopyFrom(ev, aqTempClipShape);
  389.         
  390.         {
  391.             FW_CAcquiredODTransform aqFrameTransform = embeddedODFacet->AcquireExternalTransform(ev, NULL);
  392.             aqTempShape->InverseTransform(ev, aqFrameTransform);    // parent content (me) -> embedded frame
  393.         }
  394.                 
  395. #ifdef FW_BUILD_WIN
  396.         // [HLX] bug in windows? the invalidShape is expected to be in pixels instead of points
  397.         aqTempShape->Outset(ev, ff(1));    // [HLX] Because of rounding errors
  398.         FW_CGraphicDevice *device = gc.GetGraphicDevice();
  399.         device->PointToPixel(ev, aqTempShape);
  400. #endif
  401.     
  402.         embeddedODFacet->Draw(ev, aqTempShape, NULL);
  403.         embeddedODFacet->DrawChildren(ev, aqTempShape, NULL);
  404.         
  405.         {
  406.             FW_CAcquiredODShape aqClipShape = embeddedODFacet->AcquireClipShape(ev, NULL);
  407.             aqTempShape->CopyFrom(ev, aqClipShape);
  408.         }
  409.         
  410.         {
  411.             FW_CAcquiredODTransform aqExternalTransform = embeddedODFacet->AcquireExternalTransform(ev, NULL);
  412.             aqTempShape->Transform(ev, aqExternalTransform);
  413.         }
  414.         
  415.         aqTempClipShape->Subtract(ev, aqTempShape);
  416.     }
  417. }
  418.  
  419. //----------------------------------------------------------------------------------------
  420. // CProxyShape::AdjustRectForPenSize
  421. //----------------------------------------------------------------------------------------
  422.  
  423. void CProxyShape::AdjustRectForPenSize(FW_CRect& rect, FW_Fixed penSize) const
  424. {
  425.     // Does nothing because I have a pensize of zero
  426. }
  427.  
  428. //----------------------------------------------------------------------------------------
  429. // CProxyShape::GetHandleCenter
  430. //----------------------------------------------------------------------------------------
  431.  
  432. void CProxyShape::GetHandleCenter(short whichHandle, FW_CPoint& center) const
  433. {
  434.     CRectShape::GetHandleCenter(whichHandle, center);
  435. /*
  436.     const FW_Fixed fxHalf = FW_ODFixedToFixed(0x00008000);
  437.  
  438.     switch (whichHandle)
  439.     {
  440.         case kInTopLeftCorner:
  441.             center.x = fRect.left;
  442.             center.y = fRect.top;
  443.             break;
  444.         case kInTopRightCorner:
  445.             center.x = fRect.right - fxHalf;
  446.             center.y = fRect.top;
  447.             break;
  448.         case kInBottomLeftCorner:
  449.             center.x = fRect.left;
  450.             center.y = fRect.bottom - fxHalf;
  451.             break;
  452.         case kInBottomRightCorner:
  453.             center.x = fRect.right - fxHalf;
  454.             center.y = fRect.bottom - fxHalf;
  455.             break;
  456.     }
  457. */
  458. }
  459.  
  460. //----------------------------------------------------------------------------------------
  461. // CProxyShape::MapShape
  462. //----------------------------------------------------------------------------------------
  463.  
  464. void CProxyShape::MapShape(Environment *ev, CDrawPart* part, const FW_CRect& srcRect, const FW_CRect& dstRect)
  465. {
  466.     CRectShape::MapShape(ev, part, srcRect, dstRect);    
  467.     
  468.     fFrameRect = GetRectGeometry();
  469.         
  470.     // ----- Resize every embedded frames -----
  471.     ChangeExternalTransforms(ev, fFrameRect.left, fFrameRect.top);
  472.     ChangeFrameShapes(ev, fFrameRect.right - fFrameRect.left, fFrameRect.bottom - fFrameRect.top);    
  473. }
  474.  
  475. //----------------------------------------------------------------------------------------
  476. // CProxyShape::OffsetShape
  477. //----------------------------------------------------------------------------------------
  478.  
  479. void CProxyShape::OffsetShape(Environment *ev, FW_Fixed xDelta, FW_Fixed yDelta)
  480. {    
  481.     CRectShape::OffsetShape(ev, xDelta, yDelta);
  482.     
  483.     fFrameRect.Offset(xDelta, yDelta);
  484.     
  485.     // ----- Change the external transform of all embedded facets -----
  486.     ChangeExternalTransforms(ev, fFrameRect.left, fFrameRect.top);
  487. }
  488.         
  489. //----------------------------------------------------------------------------------------
  490. // CProxyShape::SelectShape
  491. //----------------------------------------------------------------------------------------
  492.  
  493. void CProxyShape::SelectShape(Environment *ev, FW_Boolean state)
  494. {
  495.     CBaseShape::SelectShape(ev, state);
  496.     
  497.     // ----- Select all the embedded facet ----
  498.     SetSelectState(ev, state);
  499. }
  500.  
  501. //----------------------------------------------------------------------------------------
  502. // CProxyShape::MovedAfter
  503. //----------------------------------------------------------------------------------------
  504. //    shape has been moved after this
  505.  
  506. void CProxyShape::MovedAfter(Environment *ev, CBaseShape* shape)
  507. {
  508.     if (shape->GetShapeType() == kProxyShape)
  509.     {
  510.         ((CProxyShape*)shape)->MoveBehind(ev, this);
  511.     }
  512. }
  513.  
  514. //----------------------------------------------------------------------------------------
  515. // CProxyShape::MovedBefore
  516. //----------------------------------------------------------------------------------------
  517. //    shape has been moved before this
  518.  
  519. void CProxyShape::MovedBefore(Environment *ev, CBaseShape* shape)
  520. {
  521.     if (shape->GetShapeType() == kProxyShape)
  522.     {
  523.         ((CProxyShape*)shape)->MoveBefore(ev, this);
  524.     }
  525. }
  526.  
  527. //----------------------------------------------------------------------------------------
  528. // CProxyShape::MovedFirst
  529. //----------------------------------------------------------------------------------------
  530. //    this has been moved First
  531.  
  532. void CProxyShape::MovedFirst(Environment *ev)
  533. {
  534.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  535.  
  536.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  537.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  538.     {
  539.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  540.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  541.         {
  542.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  543.             if (aqODPart == aqEmbeddedPart)
  544.                 facet->MoveBefore(ev, facet1, NULL);
  545.         }
  546.     }
  547. }
  548.  
  549. //----------------------------------------------------------------------------------------
  550. // CProxyShape::MovedLast
  551. //----------------------------------------------------------------------------------------
  552. //    this has been moved Last
  553.  
  554. void CProxyShape::MovedLast(Environment *ev)
  555. {
  556.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  557.  
  558.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  559.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  560.     {
  561.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  562.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  563.         {
  564.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  565.             if (aqODPart == aqEmbeddedPart)
  566.                 facet->MoveBehind(ev, facet1, NULL);
  567.         }
  568.     }
  569. }
  570.  
  571. //----------------------------------------------------------------------------------------
  572. // CProxyShape::SetFrozen
  573. //----------------------------------------------------------------------------------------
  574.  
  575. FW_Boolean CProxyShape::SetFrozen(FW_Boolean state)
  576. {
  577.     if (fFrozen != state)
  578.     {
  579.         fFrozen = state;    
  580.         return TRUE;
  581.     }
  582.     
  583.     return FALSE;
  584. }
  585.  
  586. //----------------------------------------------------------------------------------------
  587. // CProxyShape::IsFrozen
  588. //----------------------------------------------------------------------------------------
  589.  
  590. FW_Boolean CProxyShape::IsFrozen() const
  591. {
  592.     return fFrozen;
  593. }
  594.  
  595. //----------------------------------------------------------------------------------------
  596. // CProxyShape::Read
  597. //----------------------------------------------------------------------------------------
  598.  
  599. void* CProxyShape::Read(FW_CReadableStream& stream, FW_ClassTypeConstant type)
  600. {
  601. FW_UNUSED(type);
  602.     // [HLX] This is a hack until I can register object with the archiver
  603.     CDrawReadableStream *drawArchive = (CDrawReadableStream*)&stream;
  604.     CProxyShape* proxyShape = FW_NEW(CProxyShape, (drawArchive->GetEnvironment(), drawArchive->GetDrawPart(), stream));
  605.     
  606.     proxyShape->Internalize(drawArchive->GetEnvironment(), drawArchive->GetStorageUnitView(), drawArchive->GetCloneInfo());
  607.     
  608.     return proxyShape;
  609. }
  610.  
  611. //----------------------------------------------------------------------------------------
  612. // CProxyShape::SubtractToWindowClip
  613. //----------------------------------------------------------------------------------------
  614. //    ATTENTION: windowClip is in Window coordinates. tempShape is just a working shape. It is
  615. //    used by CBaseShape so I don't have to allocate a shape every time.
  616.  
  617. void CProxyShape::SubtractToWindowClip(Environment *ev, 
  618.                                         CDrawFacetClipper* facetClipper, 
  619.                                         ODFacet* containingFacet, 
  620.                                         ODShape* windowClip, ODShape* tempShape)
  621. {
  622. FW_UNUSED(tempShape);
  623.  
  624.     FW_CEmbeddedODFacetsIterator ite(ev, this, containingFacet, kODFrontToBack);
  625.     for (ODFacet *embeddedODFacet = ite.First(ev); ite.IsNotComplete(ev); embeddedODFacet = ite.Next(ev))
  626.     {
  627.         facetClipper->ClipOneEmbeddedFacet(ev, embeddedODFacet, windowClip);
  628.     }
  629. }
  630.  
  631. //----------------------------------------------------------------------------------------
  632. // CProxyShape::ChangeRenderVerb
  633. //----------------------------------------------------------------------------------------
  634.  
  635. void CProxyShape::ChangeRenderVerb(Environment *ev, CDrawPart* part, unsigned short renderVerb)
  636. {
  637. FW_UNUSED(ev);
  638. FW_UNUSED(part);
  639. FW_UNUSED(renderVerb);
  640.  
  641.     // We don't do anything
  642. }
  643.  
  644. //----------------------------------------------------------------------------------------
  645. // CProxyShape::SetSubscribeLink
  646. //----------------------------------------------------------------------------------------
  647.  
  648. void CProxyShape::SetSubscribeLink(Environment* ev, CDrawSubscribeLink *subscribeLink)
  649. {
  650.     CBaseShape::SetSubscribeLink(ev, subscribeLink);
  651.     ChangeLinkStatus(ev, kODInLinkDestination);
  652. }
  653.  
  654. //----------------------------------------------------------------------------------------
  655. // CProxyShape::SetPublishLink
  656. //----------------------------------------------------------------------------------------
  657.  
  658. void CProxyShape::SetPublishLink(Environment* ev, CDrawPublishLink *subscribeLink)
  659. {
  660.     CBaseShape::SetPublishLink(ev, subscribeLink);
  661.     ChangeLinkStatus(ev, kODInLinkSource);
  662. }
  663.  
  664.  
  665. //----------------------------------------------------------------------------------------
  666. // CProxyShape::IsInLinkDestination
  667. //----------------------------------------------------------------------------------------
  668.  
  669. FW_Boolean CProxyShape::IsInLinkDestination(Environment* ev)
  670. {
  671.     // Check our local link status
  672.     if (this->IsSubscribed())
  673.         return TRUE;
  674.  
  675.     // Check the frame's link status
  676.     FW_CProxyProxyFrameIterator iter(this);
  677.     FW_CProxyFrame* frame = iter.First();    // only need to check one frame
  678.     if (frame->GetFrame(ev)->GetLinkStatus(ev) == kODInLinkDestination)
  679.         return TRUE;
  680.  
  681.     return FALSE;
  682. }
  683.