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 / DrawClip.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  3.7 KB  |  150 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawClip.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 DRAWCLIP_H
  15. #include "DrawClip.h"
  16. #endif
  17.  
  18. #ifndef DRAWPART_H
  19. #include "DrawPart.h"
  20. #endif
  21.  
  22. #ifndef BASESHP_H
  23. #include "BaseShp.h"
  24. #endif
  25.  
  26. #ifndef BOUNDSHP_H
  27. #include "BoundShp.h"
  28. #endif
  29.  
  30. #ifndef LINESHP_H
  31. #include "LineShp.h"
  32. #endif
  33.  
  34. #ifndef OVALSHP_H
  35. #include "OvalShp.h"
  36. #endif
  37.  
  38. #ifndef RECTSHP_H
  39. #include "RectShp.h"
  40. #endif
  41.  
  42. #ifndef RRECTSHP_H
  43. #include "RRectShp.h"
  44. #endif
  45.  
  46. #ifndef TEXTSHP_H
  47. #include "TextShp.h"
  48. #endif
  49.  
  50. #ifndef DRAWFRM_H
  51. #include "DrawFrm.h"
  52. #endif
  53.  
  54. #ifndef DRAWPRXY_H
  55. #include "DrawPrxy.h"
  56. #endif
  57.  
  58. #ifndef DRAWCONT_H
  59. #include "DrawCont.h"
  60. #endif
  61.  
  62. // ----- Part Includes -----
  63.  
  64. #ifndef FWUTIL_H
  65. #include "FWUtil.h"
  66. #endif
  67.  
  68. // ----- OS Includes -----
  69.  
  70. #ifndef FWODGEOM_H
  71. #include "FWODGeom.h"
  72. #endif
  73.  
  74. // ----- OpenDoc Includes -----
  75.  
  76. #ifndef SOM_ODShape_xh
  77. #include <Shape.xh>
  78. #endif
  79.  
  80. //========================================================================================
  81. // RunTime Info
  82. //========================================================================================
  83.  
  84. #ifdef FW_BUILD_MAC
  85. #pragma segment odfdraw
  86. #endif
  87.  
  88. //========================================================================================
  89. //    class CDrawFacetClipper
  90. //========================================================================================
  91.  
  92. //---------------------------------------------------------------------------------------
  93. //    CDrawFacetClipper::CDrawFacetClipper
  94. //---------------------------------------------------------------------------------------
  95.  
  96. CDrawFacetClipper::CDrawFacetClipper(Environment *ev, CDrawPart* part):
  97.     FW_CFacetClipper(ev, part),
  98.     fDrawPart(part)
  99. {
  100. }
  101.  
  102. //---------------------------------------------------------------------------------------
  103. //    CDrawFacetClipper::~CDrawFacetClipper
  104. //---------------------------------------------------------------------------------------
  105.  
  106. CDrawFacetClipper::~CDrawFacetClipper()
  107. {
  108. }
  109.  
  110. //----------------------------------------------------------------------------------------
  111. // CDrawFacetClipper::ClipEmbeddedFacets
  112. //----------------------------------------------------------------------------------------
  113.  
  114. void CDrawFacetClipper::ClipEmbeddedFacets(Environment *ev, 
  115.                                             FW_CEmbeddingFrame* embeddingFrame, 
  116.                                             ODFacet* containingFacet, 
  117.                                             ODShape* limitShape)
  118. {
  119.     // ----- If no proxy shape we don't have anything to do -----
  120.     if (fDrawPart->GetDrawContent()->GetProxyShapeCount() == 0)
  121.         return;
  122.     
  123.     FW_CPoint extent;
  124.     embeddingFrame->GetContentExtent(ev, extent);
  125.     FW_CRect extentRect(FW_kFixed0, FW_kFixed0, extent.x, extent.y);
  126.     
  127.     FW_CRect limitRect;
  128.     if (limitShape)
  129.         limitRect = FW_GetShapeBoundingBox(ev, limitShape);
  130.     else
  131.         limitRect = extentRect;
  132.     
  133.     // ----- Create a temporary shape -----
  134.     FW_CAcquiredODShape aqTempShape = ::FW_NewODShape(ev);
  135.     aqTempShape->SetGeometryMode(ev, kODLoseGeometry);
  136.     
  137.     // ----- Create the working clip -----
  138.     FW_CAcquiredODShape aqWorkingClip = AcquireWorkingClip(ev, embeddingFrame, containingFacet, NULL);
  139.     
  140.     // ----- Go through my shapes (backward) ------
  141.     CDrawContentShapeIterator ite(fDrawPart->GetDrawContent());
  142.     for (CBaseShape* shape = ite.Last(); ite.IsNotComplete(); shape = ite.Previous())
  143.     {
  144.         FW_CRect dragRect;
  145.         shape->GetDragRect(dragRect);
  146.         if (limitRect.IsIntersecting(dragRect))
  147.             shape->SubtractToWindowClip(ev, this, containingFacet, aqWorkingClip, aqTempShape);
  148.     }
  149. }
  150.