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 / ODFDev / Draw / Sources / DrawPrxy.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  22.4 KB  |  710 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawPrxy.cpp
  4. //    Release Version:    $ ODF 2 $
  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(drawPart, kProxyShape, kFillOnly),
  146.     FW_MProxy(ev, drawPart),
  147.     fFrozen(FALSE),
  148.     fFrameRect(rect)
  149. {
  150.     SetRectGeometry(rect);
  151.     
  152.     FW_END_CONSTRUCTOR
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. // CProxyShape::CProxyShape
  157. //----------------------------------------------------------------------------------------
  158.  
  159. CProxyShape::CProxyShape(Environment* ev, CDrawPart* drawPart, FW_CReadableStream& archive) :
  160.     CRectShape(drawPart, archive),
  161.     FW_MProxy(ev, drawPart),
  162.     fFrozen(FALSE)
  163. {
  164.     archive >> fFrameRect;
  165.  
  166.     FW_END_CONSTRUCTOR
  167. }
  168.  
  169. //----------------------------------------------------------------------------------------
  170. // CProxyShape::~CProxyShape
  171. //----------------------------------------------------------------------------------------
  172.  
  173. CProxyShape::~CProxyShape()
  174. {
  175.     FW_START_DESTRUCTOR
  176. }
  177.     
  178. //----------------------------------------------------------------------------------------
  179. //    CProxyShape::FrameShapeRequested
  180. //----------------------------------------------------------------------------------------
  181.  
  182. ODShape* CProxyShape::FrameShapeRequested(Environment* ev, 
  183.                                         FW_CEmbeddingFrame* embeddingFrame, 
  184.                                         ODFrame* odEmbeddedFrame, 
  185.                                         ODShape* requestedFrameShape)
  186. {
  187. FW_UNUSED(embeddingFrame);
  188.     // ----- get the bounding box of the asked frame shape
  189.     FW_CRect frameRect = FW_GetShapeBoundingBox(ev, requestedFrameShape);
  190.     
  191.     fFrameRect.right = fFrameRect.left + frameRect.Width();
  192.     fFrameRect.bottom = fFrameRect.top + frameRect.Height();
  193.  
  194.     // ----- Invalidate the old used Shape in case the embedded frame doesn't do it-----
  195.     FW_CAcquiredODShape aqUsedShape = odEmbeddedFrame->AcquireUsedShape(ev, NULL);
  196.     odEmbeddedFrame->Invalidate(ev, aqUsedShape, NULL);
  197.     
  198.     // ----- Don't forget to bump the refcount
  199.     requestedFrameShape->Acquire(ev);
  200.     return requestedFrameShape;
  201. }
  202.  
  203. //----------------------------------------------------------------------------------------
  204. //    CProxyShape::UsedShapeChanged
  205. //----------------------------------------------------------------------------------------
  206.  
  207. void CProxyShape::UsedShapeChanged(Environment* ev, FW_CEmbeddingFrame* embeddingFrame, ODFrame* odEmbeddedFrame)
  208. {
  209.     FW_CAcquiredODShape aqFrameShape = odEmbeddedFrame->AcquireFrameShape(ev, NULL);
  210.     FW_CAcquiredODShape aqUsedShape = odEmbeddedFrame->AcquireUsedShape(ev, NULL);
  211.     
  212.     FW_CRect usedShapeRect = FW_GetShapeBoundingBox(ev, aqUsedShape);
  213.     FW_CRect newShapeRect = FW_GetShapeBoundingBox(ev, aqFrameShape);
  214.  
  215.     newShapeRect.Intersection(usedShapeRect);    
  216.     newShapeRect.Offset(fFrameRect.left, fFrameRect.top);
  217.  
  218.     // ----- Get previous update shape -----
  219.     FW_CAcquiredODShape aqInvalidShape = ::FW_NewODShape(ev);
  220.     GetUpdateBox(ev, aqInvalidShape);
  221.  
  222.     // ----- Set the geometry of the shape -----
  223.     SetRectGeometry(newShapeRect);
  224.         
  225.     // ----- Calculate the shape to update union minus intersection
  226.     {
  227.         FW_CAcquiredODShape aqNewUpdateBox = ::FW_NewODShape(ev);
  228.         GetUpdateBox(ev, aqNewUpdateBox);
  229.         
  230.         FW_CAcquiredODShape aqIntersect(aqInvalidShape->Copy(ev));
  231.         aqIntersect->Intersect(ev, aqNewUpdateBox);
  232.         
  233.         aqInvalidShape->Union(ev, aqNewUpdateBox);
  234.         
  235.         // ----- Clip our embedded facets using the union
  236.         CDrawFacetClipper facetClipper(fDrawPart);
  237.         facetClipper.Clip(ev, embeddingFrame, aqInvalidShape);
  238.  
  239.         aqInvalidShape->Subtract(ev, aqIntersect);
  240.     }
  241.     
  242.     fDrawPart->GetMainPresentation()->Invalidate(ev, aqInvalidShape);
  243.     
  244.     // ----- Invalidate the difference
  245.     embeddingFrame->Invalidate(ev, aqInvalidShape);
  246. }
  247.  
  248. //----------------------------------------------------------------------------------------
  249. //    CProxyShape::MoveBefore
  250. //----------------------------------------------------------------------------------------
  251.  
  252. void CProxyShape::MoveBefore(Environment* ev, CProxyShape* before)
  253. {
  254.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  255.     FW_CAcquiredODPart aqBeforePart = before->AcquireEmbeddedPart(ev);
  256.  
  257.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  258.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  259.     {
  260.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  261.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  262.         {
  263.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  264.             if (aqODPart == aqEmbeddedPart)
  265.             {
  266.                 FW_CFacetIterator ite2(ev, facet, kODChildrenOnly, kODFrontToBack);
  267.                 for (ODFacet* facet2 = ite2.First(ev); ite2.IsNotComplete(ev); facet2 = ite2.Next(ev))
  268.                 {
  269.                     FW_CAcquiredODPart aqODPart2 = facet2->GetFrame(ev)->AcquirePart(ev);
  270.                     if (aqODPart2 == aqBeforePart)
  271.                     {
  272.                         facet->MoveBefore(ev, facet1, facet2);
  273.                         break;
  274.                     }
  275.                 }
  276.             }
  277.         }
  278.     }
  279. }
  280.  
  281. //----------------------------------------------------------------------------------------
  282. //    CProxyShape::MoveBehind
  283. //----------------------------------------------------------------------------------------
  284.  
  285. void CProxyShape::MoveBehind(Environment* ev, CProxyShape* behind)
  286. {    
  287.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  288.     FW_CAcquiredODPart aqBehindPart = behind->AcquireEmbeddedPart(ev);
  289.  
  290.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  291.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  292.     {
  293.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  294.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  295.         {
  296.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  297.             if (aqODPart == aqEmbeddedPart)
  298.             {
  299.                 FW_CFacetIterator ite2(ev, facet1, kODChildrenOnly, kODFrontToBack);
  300.                 for (ODFacet* facet2 = ite2.First(ev); ite2.IsNotComplete(ev); facet2 = ite2.Next(ev))
  301.                 {
  302.                     FW_CAcquiredODPart aqODPart2 = facet2->GetFrame(ev)->AcquirePart(ev);
  303.                     if (aqODPart2 == aqBehindPart)
  304.                     {
  305.                         facet->MoveBehind(ev, facet1, facet2);
  306.                         break;
  307.                     }
  308.                 }
  309.             }
  310.         }
  311.     }
  312. }
  313.  
  314. //----------------------------------------------------------------------------------------
  315. // CProxyShape::RestoreShape
  316. //----------------------------------------------------------------------------------------
  317.  
  318. void CProxyShape::RestoreShape(Environment *ev)
  319. {
  320.     CRectShape::RestoreShape(ev);
  321.     
  322.     AttachEmbeddedFrames(ev);
  323. }
  324.  
  325. //----------------------------------------------------------------------------------------
  326. // CProxyShape::Removed
  327. //----------------------------------------------------------------------------------------
  328. //     the shape is going to be removed (for example for undo)
  329.  
  330. void CProxyShape::Removed(Environment* ev)
  331. {
  332.     CRectShape::Removed(ev);
  333.     
  334.     DetachEmbeddedFrames(ev);
  335. }
  336.  
  337. //----------------------------------------------------------------------------------------
  338. // CProxyShape::Deleted
  339. //----------------------------------------------------------------------------------------
  340. //     the shape is going to be deleted
  341.  
  342. void CProxyShape::Deleted(Environment* ev)
  343. {
  344.     CRectShape::Deleted(ev);
  345.     
  346.     RemoveEmbeddedFrames(ev);
  347. }
  348.  
  349. //----------------------------------------------------------------------------------------
  350. // CProxyShape::Flatten
  351. //----------------------------------------------------------------------------------------
  352.  
  353. void CProxyShape::Flatten(FW_CWritableStream& archive)
  354. {    
  355.     CRectShape::Flatten(archive);
  356.     
  357.     archive << fFrameRect;
  358.  
  359.     // [HLX] I know it's bad but I know I am archiving to a storage unit
  360.     CDrawWritableStream* drawArchive = (CDrawWritableStream*)&archive;
  361.     Externalize(drawArchive->GetEnvironment(), drawArchive->GetStorageUnitView(), drawArchive->GetCloneInfo());
  362. }
  363.  
  364. //----------------------------------------------------------------------------------------
  365. // CProxyShape::RenderShape
  366. //----------------------------------------------------------------------------------------
  367. //    Important Note: embedded frame during printing are not clipped because I draw them in z-ordering
  368.  
  369. void CProxyShape::RenderShape(Environment *ev, ODFacet* facet, FW_CGraphicContext& gc)
  370. {        
  371.     FW_CAcquiredODShape aqTempShape = ::FW_NewODShape(ev);
  372.     FW_CAcquiredODShape aqTempClipShape(gc.AcquireClip());    // AcquireClip returns a copy in content coordinate
  373.  
  374.     // ----- Because we are calling the draw method of an embedded facet, we want
  375.     // ----- to save our context. The embedded facet will be using the same grafport 
  376.     // ----- and may not be restoring it
  377.     FW_CSaveRestoreContext src(gc);
  378.     
  379.     FW_CEmbeddedODFacetsIterator ite(ev, this, facet, kODBackToFront);
  380.     ODFacet* embeddedODFacet = ite.First(ev);        // I know I create only one embedded Facets
  381.     
  382.     {
  383.         FW_CAcquiredODTransform aqFrameTransform = embeddedODFacet->AcquireExternalTransform(ev, NULL);
  384.         aqTempClipShape->InverseTransform(ev, aqFrameTransform);    // parent content (me) -> embedded frame
  385.     }
  386.                 
  387. #ifdef FW_BUILD_WIN
  388.     // [HLX] bug in windows? the invalidShape is expected to be in pixels instead of points
  389.     aqTempShape->Outset(ev, ff(1));    // [HLX] Because of rounding errors
  390.     FW_CGraphicDevice *device = gc.GetGraphicDevice();
  391.     device->PointToPixel(ev, aqTempShape);
  392. #endif
  393.     
  394.     embeddedODFacet->Draw(ev, aqTempClipShape, NULL);
  395.     embeddedODFacet->DrawChildren(ev, aqTempClipShape, NULL);
  396. }
  397.  
  398. //----------------------------------------------------------------------------------------
  399. // CProxyShape::AdjustRectForPenSize
  400. //----------------------------------------------------------------------------------------
  401.  
  402. void CProxyShape::AdjustRectForPenSize(FW_CRect& rect, FW_Fixed penSize) const
  403. {
  404. FW_UNUSED(rect);
  405. FW_UNUSED(penSize);
  406.     // Does nothing because I have a pensize of zero
  407. }
  408.  
  409. //----------------------------------------------------------------------------------------
  410. // CProxyShape::MapShape
  411. //----------------------------------------------------------------------------------------
  412.  
  413. void CProxyShape::MapShape(Environment *ev, const FW_CRect& srcRect, const FW_CRect& dstRect)
  414. {
  415.     CRectShape::MapShape(ev, srcRect, dstRect);    
  416.     
  417.     fFrameRect = GetRectGeometry();
  418.         
  419.     // ----- Resize every embedded frames -----
  420.     ChangeExternalTransforms(ev, fFrameRect.left, fFrameRect.top);
  421.     ChangeFrameShapes(ev, fFrameRect.right - fFrameRect.left, fFrameRect.bottom - fFrameRect.top);    
  422. }
  423.  
  424. //----------------------------------------------------------------------------------------
  425. // CProxyShape::OffsetShape
  426. //----------------------------------------------------------------------------------------
  427.  
  428. void CProxyShape::OffsetShape(Environment *ev, FW_Fixed xDelta, FW_Fixed yDelta)
  429. {    
  430.     CRectShape::OffsetShape(ev, xDelta, yDelta);
  431.     
  432.     fFrameRect.Offset(xDelta, yDelta);
  433.     
  434.     // ----- Change the external transform of all embedded facets -----
  435.     ChangeExternalTransforms(ev, fFrameRect.left, fFrameRect.top);
  436. }
  437.         
  438. //----------------------------------------------------------------------------------------
  439. // CProxyShape::SelectShape
  440. //----------------------------------------------------------------------------------------
  441.  
  442. void CProxyShape::SelectShape(Environment *ev, FW_Boolean state)
  443. {
  444.     CBaseShape::SelectShape(ev, state);
  445.     
  446.     // ----- Select all the embedded facet ----
  447.     SetSelectState(ev, state);
  448. }
  449.  
  450. //----------------------------------------------------------------------------------------
  451. // CProxyShape::MovedAfter
  452. //----------------------------------------------------------------------------------------
  453. //    shape has been moved after this
  454.  
  455. void CProxyShape::MovedAfter(Environment *ev, CBaseShape* shape)
  456. {
  457.     if (shape->GetShapeType() == kProxyShape)
  458.     {
  459.         ((CProxyShape*)shape)->MoveBehind(ev, this);
  460.     }
  461. }
  462.  
  463. //----------------------------------------------------------------------------------------
  464. // CProxyShape::MovedBefore
  465. //----------------------------------------------------------------------------------------
  466. //    shape has been moved before this
  467.  
  468. void CProxyShape::MovedBefore(Environment *ev, CBaseShape* shape)
  469. {
  470.     if (shape->GetShapeType() == kProxyShape)
  471.     {
  472.         ((CProxyShape*)shape)->MoveBefore(ev, this);
  473.     }
  474. }
  475.  
  476. //----------------------------------------------------------------------------------------
  477. // CProxyShape::MovedFirst
  478. //----------------------------------------------------------------------------------------
  479. //    this has been moved First
  480.  
  481. void CProxyShape::MovedFirst(Environment *ev)
  482. {
  483.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  484.  
  485.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  486.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  487.     {
  488.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  489.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  490.         {
  491.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  492.             if (aqODPart == aqEmbeddedPart)
  493.                 facet->MoveBefore(ev, facet1, NULL);
  494.         }
  495.     }
  496. }
  497.  
  498. //----------------------------------------------------------------------------------------
  499. // CProxyShape::MovedLast
  500. //----------------------------------------------------------------------------------------
  501. //    this has been moved Last
  502.  
  503. void CProxyShape::MovedLast(Environment *ev)
  504. {
  505.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  506.  
  507.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  508.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  509.     {
  510.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  511.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  512.         {
  513.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  514.             if (aqODPart == aqEmbeddedPart)
  515.                 facet->MoveBehind(ev, facet1, NULL);
  516.         }
  517.     }
  518. }
  519.  
  520. //----------------------------------------------------------------------------------------
  521. // CProxyShape::SetFrozen
  522. //----------------------------------------------------------------------------------------
  523.  
  524. FW_Boolean CProxyShape::SetFrozen(FW_Boolean state)
  525. {
  526.     if (fFrozen != state)
  527.     {
  528.         fFrozen = state;    
  529.         return TRUE;
  530.     }
  531.     
  532.     return FALSE;
  533. }
  534.  
  535. //----------------------------------------------------------------------------------------
  536. // CProxyShape::IsFrozen
  537. //----------------------------------------------------------------------------------------
  538.  
  539. FW_Boolean CProxyShape::IsFrozen() const
  540. {
  541.     return fFrozen;
  542. }
  543.  
  544. //----------------------------------------------------------------------------------------
  545. // CProxyShape::Read
  546. //----------------------------------------------------------------------------------------
  547.  
  548. void* CProxyShape::Read(FW_CReadableStream& stream, FW_ClassTypeConstant type)
  549. {
  550. FW_UNUSED(type);
  551.     // [HLX] This is a hack until I can register object with the archiver
  552.     CDrawReadableStream *drawArchive = (CDrawReadableStream*)&stream;
  553.     CProxyShape* proxyShape = FW_NEW(CProxyShape, (drawArchive->GetEnvironment(), drawArchive->GetDrawPart(), stream));
  554.     
  555.     proxyShape->Internalize(drawArchive->GetEnvironment(), drawArchive->GetStorageUnitView(), drawArchive->GetCloneInfo());
  556.     
  557.     return proxyShape;
  558. }
  559.  
  560. //----------------------------------------------------------------------------------------
  561. // CProxyShape::SubtractToWorkingClip
  562. //----------------------------------------------------------------------------------------
  563. //    ATTENTION: windowClip is in Content coordinates. tempShape is just a working shape. It is
  564. //    used by CBaseShape so I don't have to allocate a shape every time.
  565.  
  566. void CProxyShape::SubtractToWorkingClip(Environment *ev, 
  567.                                         CDrawFacetClipper* facetClipper, 
  568.                                         ODFacet* containingFacet, 
  569.                                         ODShape* workingClip, 
  570.                                         ODShape* tempShape,
  571.                                         ODShape* limitShape)
  572. {
  573. FW_UNUSED(tempShape);
  574.  
  575.     FW_CEmbeddedODFacetsIterator ite(ev, this, containingFacet, kODFrontToBack);
  576.     for (ODFacet *embeddedODFacet = ite.First(ev); ite.IsNotComplete(ev); embeddedODFacet = ite.Next(ev))
  577.     {
  578.         facetClipper->ClipOneEmbeddedFacet(ev, embeddedODFacet, workingClip, limitShape);
  579.     }
  580. }
  581.  
  582. //----------------------------------------------------------------------------------------
  583. // CProxyShape::ChangeRenderVerb
  584. //----------------------------------------------------------------------------------------
  585.  
  586. void CProxyShape::ChangeRenderVerb(Environment *ev, unsigned short renderVerb)
  587. {
  588. FW_UNUSED(ev);
  589. FW_UNUSED(renderVerb);
  590.  
  591.     // We don't do anything
  592. }
  593.  
  594. //----------------------------------------------------------------------------------------
  595. // CProxyShape::SetSubscribeLink
  596. //----------------------------------------------------------------------------------------
  597.  
  598. void CProxyShape::SetSubscribeLink(Environment* ev, CDrawSubscribeLink* subscribeLink)
  599. {
  600.     CBaseShape::SetSubscribeLink(ev, subscribeLink);
  601.     ChangeLinkStatus(ev, subscribeLink ? kODInLinkDestination : kODNotInLink);
  602. }
  603.  
  604. //----------------------------------------------------------------------------------------
  605. // CProxyShape::SetPublishLink
  606. //----------------------------------------------------------------------------------------
  607.  
  608. void CProxyShape::SetPublishLink(Environment* ev, CDrawPublishLink* publishLink)
  609. {
  610.     CBaseShape::SetPublishLink(ev, publishLink);
  611.     ChangeLinkStatus(ev, publishLink ? kODInLinkSource : kODNotInLink);
  612. }
  613.  
  614.  
  615. //----------------------------------------------------------------------------------------
  616. // CProxyShape::IsInLinkDestination
  617. //----------------------------------------------------------------------------------------
  618.  
  619. FW_Boolean CProxyShape::IsInLinkDestination(Environment* ev)
  620. {
  621.     // Check our local link status
  622.     if (this->IsSubscribed())
  623.         return TRUE;
  624.  
  625.     // Check the frame's link status
  626.     FW_CProxyProxyFrameIterator iter(this);
  627.     FW_CProxyFrame* frame = iter.First();    // only need to check one frame
  628.     if (frame->GetFrame(ev)->GetLinkStatus(ev) == kODInLinkDestination)
  629.         return TRUE;
  630.  
  631.     return FALSE;
  632. }
  633.  
  634. //----------------------------------------------------------------------------------------
  635. //    CProxyShape::NeedFacets
  636. //----------------------------------------------------------------------------------------
  637. //    The simplest way to test if my proxy needs facet is to intersect the visible content
  638. //    with the shape of the proxy.
  639. FW_Boolean CProxyShape::NeedFacets(Environment *ev, FW_CEmbeddingFrame* embeddingFrame) const
  640. {
  641.     FW_CRect bounds = embeddingFrame->GetContentView(ev)->GetBoundsInContent(ev);
  642.     FW_CRect rect = GetRectGeometry();
  643.     return rect.IsIntersecting(bounds);
  644. }
  645.  
  646. //----------------------------------------------------------------------------------------
  647. //    CProxyShape::CreateFacets
  648. //----------------------------------------------------------------------------------------
  649.  
  650. short CProxyShape::CreateFacets(Environment* ev,
  651.                                 FW_CEmbeddingFrame* embeddingFrame,
  652.                                 ODFacet* embeddingFacet,
  653.                                 ODFrame* embeddedFrame,
  654.                                 ODShape* proposedClipShape)
  655. {
  656. FW_UNUSED(embeddingFrame);
  657.     FW_CRect embeddedFrameBounds = GetFrameRect(ev);
  658.     
  659.     FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, embeddedFrameBounds.TopLeft());
  660.  
  661.     CreateFacet(ev,
  662.                 embeddingFacet,
  663.                 embeddedFrame,
  664.                 proposedClipShape,
  665.                 aqExternalTransform,
  666.                 NULL,                    // Canvas
  667.                 NULL,                    // biasCanvas
  668.                 NULL,                    // siblingFacet
  669.                 kODFrameInFront);
  670.     
  671.     return 1;    // one facet created
  672. }
  673.  
  674. //----------------------------------------------------------------------------------------
  675. //    CDrawFrame::RevealFrame
  676. //----------------------------------------------------------------------------------------
  677. //    Attention revealShape is in embedded frame coordinate
  678.  
  679. FW_Boolean CProxyShape::Reveal(Environment *ev, 
  680.                                FW_CEmbeddingFrame* embeddingFrame,
  681.                                ODFrame* embeddedFrame, 
  682.                                ODShape* revealShape)
  683. {
  684. FW_UNUSED(embeddedFrame);
  685.  
  686.     FW_ASSERT(revealShape);
  687.     
  688.     // bounds is in embedded frame coordinate
  689.     FW_CRect bounds = FW_GetShapeBoundingBox(ev, revealShape);
  690.     
  691.     // Convert bounds to content coordinate
  692.     FW_CRect embeddedFrameBounds = GetFrameRect(ev);
  693.     bounds.Offset(embeddedFrameBounds.left, embeddedFrameBounds.top);
  694.     
  695.     embeddingFrame->GetScroller(ev)->RevealRect(ev, bounds);
  696.  
  697.     return TRUE;
  698. }
  699.  
  700. //----------------------------------------------------------------------------------------
  701. // CProxyShape::MakePurgeable
  702. //----------------------------------------------------------------------------------------
  703.  
  704. void CProxyShape::MakePurgeable(Environment* ev, CDrawFrame* drawFrame, const FW_CRect& bounds)
  705. {
  706.     FW_CRect rect = GetRectGeometry();
  707.     SetPurgeable(ev, drawFrame, !rect.IsIntersecting(bounds));
  708. }
  709.  
  710.