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 / ODFDev / Table / Sources / Proxy.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  6.2 KB  |  210 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Proxy.cpp
  4. //    Release Version:    $ ODF 1 $ 
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Table.hpp"
  11.  
  12. // ----- TablePart Includes -----
  13.  
  14. #ifndef PROXY_H
  15. #include "Proxy.h"
  16. #endif
  17.  
  18. #ifndef FRAME_H
  19. #include "Frame.h"
  20. #endif
  21.  
  22. #ifndef CONTENT_H
  23. #include "Content.h"
  24. #endif
  25.  
  26. // ----- Framework Includes -----
  27.  
  28. #ifndef FWFRMING_H
  29. #include "FWFrming.h"
  30. #endif
  31.  
  32. #ifndef FWITERS_H
  33. #include "FWIters.h"
  34. #endif
  35.  
  36. #ifndef FWUTIL_H
  37. #include "FWUtil.h"
  38. #endif
  39.  
  40. #ifndef FWFCTCLP_H
  41. #include "FWFctClp.h"
  42. #endif
  43.  
  44. #ifndef FWPXYFRM_H
  45. #include "FWPxyFrm.h"
  46. #endif
  47.  
  48. #ifndef FWTCOLL_H
  49. #include "FWTColl.h"
  50. #endif
  51.  
  52. // ----- OS Includes -----
  53.  
  54. #ifndef FWODGEOM_H
  55. #include "FWODGeom.h"
  56. #endif
  57.  
  58. #ifndef FWFXMATH_H
  59. #include "FWFxMath.h"
  60. #endif
  61.  
  62. //========================================================================================
  63. // RunTime Info
  64. //========================================================================================
  65.  
  66. #ifdef FW_BUILD_MAC
  67. #pragma segment odfTable
  68. #endif
  69.  
  70. //========================================================================================
  71. // class CShapeCollection
  72. //========================================================================================
  73.  
  74. FW_DEFINE_AUTO(CTableProxyCollection)
  75.  
  76. //========================================================================================
  77. // class CShapeCollectionIterator
  78. //========================================================================================
  79.  
  80. FW_DEFINE_AUTO(CTableProxyCollectionIterator)
  81.  
  82. //========================================================================================
  83. //    class CTableProxy
  84. //========================================================================================
  85.  
  86. //----------------------------------------------------------------------------------------
  87. //    CTableProxy::CTableProxy
  88. //----------------------------------------------------------------------------------------
  89.  
  90. CTableProxy::CTableProxy(Environment* ev, CTablePart* tablePart, CTableContent* tableContent, FW_CPresentation* presentation) :
  91.     FW_MProxy(ev, tablePart, presentation),
  92.     fTablePart(tablePart),
  93.     fTableContent(tableContent),
  94.     fCell(0, 0),
  95.     fSelected(FALSE)
  96. {
  97. }
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    CTableProxy::~CTableProxy
  101. //----------------------------------------------------------------------------------------
  102.  
  103. CTableProxy::~CTableProxy()
  104. {
  105. }
  106.  
  107. //----------------------------------------------------------------------------------------
  108. //    CTableProxy::UsedShapeChanged
  109. //----------------------------------------------------------------------------------------
  110.  
  111. void CTableProxy::UsedShapeChanged(Environment *ev,
  112.                                    FW_CEmbeddingFrame* embeddingFrame,
  113.                                    ODFrame* odEmbeddedFrame)
  114. {
  115.     FW_CRect cellRect;
  116.     fTableContent->FindRect(fCell, cellRect);
  117.     FW_CAcquiredODShape aqInvalidShape = ::FW_NewODShape(ev, cellRect);
  118.  
  119.     FW_CAcquiredODShape aqUsedShape(FW_CopyAndRelease(ev, odEmbeddedFrame->AcquireUsedShape(ev, NULL)));
  120.         
  121.     // ----- For the Table part, all embedded facets have the same externalTransform
  122.     ODFacet *facet;
  123.     {
  124.         FW_CODFrameFacetIterator ite(ev, odEmbeddedFrame);
  125.         facet = ite.First(ev);
  126.     }
  127.     if (facet == NULL)
  128.         return;
  129.     
  130.     {
  131.         FW_CAcquiredODTransform aqExternalTransform(facet->AcquireExternalTransform(ev, NULL));
  132.         aqUsedShape->Transform(ev, aqExternalTransform);
  133.         aqInvalidShape->Subtract(ev, aqUsedShape);
  134.     }
  135.     
  136.     // ----- Invalidate
  137.     embeddingFrame->Invalidate(ev, aqInvalidShape);
  138.     
  139.     // ----- Recalculate the clip
  140.     FW_CFacetClipper facetClipper(ev, fTablePart);
  141.     facetClipper.Clip(ev, GetPresentation(ev), NULL);
  142. }
  143.  
  144. //----------------------------------------------------------------------------------------
  145. //    CTableProxy::FrameShapeRequested
  146. //----------------------------------------------------------------------------------------
  147.  
  148. ODShape* CTableProxy::FrameShapeRequested(Environment* ev, 
  149.                                         FW_CEmbeddingFrame* embeddingFrame, 
  150.                                         ODFrame* odEmbeddedFrame, 
  151.                                         ODShape* askedFrameShape)
  152. {
  153. FW_UNUSED(askedFrameShape);
  154.  
  155.     FW_CRect cellRect;
  156.     fTableContent->FindRect(fCell, cellRect);
  157.  
  158.     cellRect.Place(FW_kZeroPoint);
  159.     ODShape* cellShape = ::FW_NewODShape(ev, cellRect);
  160.     
  161.     return cellShape;
  162. }
  163.  
  164. //----------------------------------------------------------------------------------------
  165. //    CTableProxy::MoveEmbeddedFrames
  166. //----------------------------------------------------------------------------------------
  167.  
  168. void CTableProxy::MoveEmbeddedFrames(Environment* ev, const CCell& destCell)
  169. {
  170.     FW_CRect rect;
  171.     fTableContent->FindRect(destCell, rect);
  172.     ChangeFrameShapes(ev, rect.Width(), rect.Height());
  173.     ChangeExternalTransforms(ev, rect.left, rect.top);
  174.     
  175.     //     [HLX] because I can't create facets with a NULL clip (bug in OpenDoc???) I have to 
  176.     //    Clip my embedded facets everytime
  177.     FW_CFacetClipper facetClipper(ev, fTablePart);
  178.     facetClipper.Clip(ev, GetPresentation(ev), NULL);
  179. }
  180.  
  181. //----------------------------------------------------------------------------------------
  182. //    CTableProxy::AcquireHiliteShape
  183. //----------------------------------------------------------------------------------------
  184.  
  185. ODShape* CTableProxy::AcquireHiliteShape(Environment* ev, const CCell& cell, FW_CEmbeddingFrame* frame)
  186. {
  187.     FW_CRect rect;
  188.     fTableContent->FindRect(cell, rect);
  189.  
  190.     FW_CAcquiredODFrame embeddedFrame = this->AcquireEmbeddedFrame(ev, frame);
  191.     FW_CAcquiredODShape usedShape = FW_CopyAndRelease(ev, embeddedFrame->AcquireUsedShape(ev, NULL));
  192.     FW_CAcquiredODTransform transform = ::FW_NewODTransform(ev, rect.TopLeft());
  193.     usedShape->Transform(ev, transform);
  194.     ODShape* hiliteShape = ::FW_NewODShape(ev, rect);
  195.     hiliteShape->Subtract(ev, usedShape);
  196.     return hiliteShape;
  197. }
  198.  
  199. //----------------------------------------------------------------------------------------
  200. //    CTableProxy::OpenInWindow
  201. //----------------------------------------------------------------------------------------
  202. //    Because proxys are always all selected I need to only open the one that's really selected
  203.  
  204. void CTableProxy::OpenInWindow(Environment* ev, FW_CProxyFrame* proxyFrame)
  205. {
  206.     if (fSelected)
  207.         FW_MProxy::OpenInWindow(ev, proxyFrame);
  208. }
  209.  
  210.