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 / Container / Sources / Proxy.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  6.5 KB  |  224 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Proxy.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef PROXY_H
  11. #define PROXY_H
  12.  
  13. // ----- Part Layer -----
  14.  
  15. #ifndef FWFRMING_H
  16. #include "FWFrming.h"
  17. #endif
  18.  
  19. #ifndef FWPROXY_H
  20. #include "FWProxy.h"
  21. #endif
  22.  
  23. // ----- OS Layer -----
  24.  
  25. #ifndef FWRECT_H
  26. #include "FWRect.h"
  27. #endif
  28.  
  29. //========================================================================================
  30. // Constants
  31. //========================================================================================
  32.  
  33. // ----- Selection handle locations -----
  34. const short kInTopLeftCorner = 1;
  35. const short kInBottomRightCorner = kInTopLeftCorner + 1;
  36. const short kInTopRightCorner = kInBottomRightCorner + 1;
  37. const short kInBottomLeftCorner = kInTopRightCorner + 1;
  38. const short kInTopMiddle = kInBottomLeftCorner + 1;
  39. const short kInLeftMiddle = kInTopMiddle + 1;
  40. const short kInBottomMiddle = kInLeftMiddle + 1;
  41. const short kInRightMiddle = kInBottomMiddle + 1;
  42.  
  43. #define kNumberOfHandles 8
  44.  
  45. //========================================================================================
  46. // Forward Declarations
  47. //========================================================================================
  48.  
  49. class ODFrame;
  50. class CContainerPart;
  51. class FW_CFacetClipper;
  52. class FW_CInk;
  53. class FW_CStyle;
  54. class FW_CRectShape;
  55. class CContainerFrame;
  56.  
  57. //========================================================================================
  58. // Global Methods
  59. //========================================================================================
  60.  
  61. inline FW_Fixed CalcHandlePenSize(FW_Fixed zoomFactor)
  62. {
  63.     return (FW_kFixedPos2 + FW_ODFixedToFixed(0x00008000)) / zoomFactor;
  64. }
  65.  
  66. //========================================================================================
  67. //    class CProxy
  68. //========================================================================================
  69.  
  70. class CProxy : public FW_MProxy
  71. {
  72. //----------------------------------------------------------------------------------------
  73. //    Initialization/Destruction
  74. //
  75.   public:
  76.     CProxy(Environment* ev, const FW_CRect& bounds, CContainerPart* part, ODTypeToken viewAs);
  77.     virtual ~CProxy();
  78.  
  79.   protected:
  80.     void                 InitStatic();
  81.  
  82. //----------------------------------------------------------------------------------------
  83. //    Inherited API from FW_MProxy
  84. //
  85.   public:
  86.     virtual void         UsedShapeChanged(Environment* ev, 
  87.                                     FW_CEmbeddingFrame* embeddingFrame, 
  88.                                     ODFrame* odEmbeddedFrame);
  89.     
  90.     virtual ODShape*    FrameShapeRequested(Environment* ev, 
  91.                                     FW_CEmbeddingFrame* embeddingFrame, 
  92.                                     ODFrame* odEmbeddedFrame, 
  93.                                     ODShape* requestedFrameShape);
  94.  
  95.     virtual void        Internalize(Environment* ev, 
  96.                                     ODStorageUnitView* sourceSUView,
  97.                                     FW_CCloneInfo *cloneInfo);
  98.     virtual void        Externalize(Environment* ev, 
  99.                                     ODStorageUnitView* destinationSUView, 
  100.                                     FW_CCloneInfo* cloneInfo);
  101.     
  102.     virtual short        CreateFacets(Environment* ev,
  103.                                     FW_CEmbeddingFrame* embeddingFrame,
  104.                                     ODFacet* embeddingFacet,
  105.                                     ODFrame* embeddedFrame,
  106.                                     ODShape* proposedClipShape);
  107.                             
  108. //-----------------------------------------------------------------------------------------
  109. //    New API
  110. //
  111.   public:
  112.     void        Render(Environment *ev, ODFacet* facet, FW_CGraphicContext& gc);
  113.  
  114.     FW_CRect    GetBounds(Environment* ev) const;
  115.     void        SetBounds(Environment* ev, 
  116.                         const FW_CRect& bounds);
  117.     
  118.     ODShape*    CreateProxyOutline(Environment *ev);
  119.     
  120.     void        GetUpdateBox(Environment* ev, 
  121.                         ODShape* updateBox) const;
  122.  
  123.     FW_Boolean    InSelectionRect(const FW_CRect& selectRect) const;
  124.  
  125.     void        ResizeFeedback(FW_CGraphicContext& gc, 
  126.                         const FW_CInk& ink, 
  127.                         const FW_CStyle& style, 
  128.                         short whichHandle, 
  129.                         const FW_CPoint& mouseLoc);
  130.  
  131.     FW_Boolean    HitTest(Environment *ev, 
  132.                         FW_CGraphicContext& gc, 
  133.                         const FW_CPoint& where) const;
  134.  
  135.     void        OffsetProxy(Environment* ev, 
  136.                         FW_Fixed xDelta, 
  137.                         FW_Fixed yDelta);
  138.     void        ResizeProxy(Environment* ev, 
  139.                         const FW_CRect& srcRect, 
  140.                         const FW_CRect& dstRect);
  141.  
  142.     void        CalcHandle(short whichHandle, 
  143.                         FW_CRectShape* handle, 
  144.                         FW_Fixed penSize) const;
  145.     void        CalcHandle(short whichHandle, 
  146.                         FW_CRect& rect, 
  147.                         FW_Fixed penSize) const;
  148.     void        GetHandleCenter(short whichHandle, 
  149.                         FW_CPoint& center) const;
  150.     void        RenderHandles(FW_CGraphicContext& gc, FW_Fixed zoomFactor);
  151.     void        RenderSelectionFrame(FW_CGraphicContext& gc);
  152.     void        InvalidateHandles(Environment* ev, 
  153.                     FW_CView* contentView, 
  154.                     ODShape* workingShape1, ODShape* workingShape2, 
  155.                     FW_Fixed penSize);
  156.     void        InvalidateHandles(Environment* ev, CContainerFrame* frame);
  157.     
  158.     short        WhichHandle(FW_CGraphicContext& gc, 
  159.                         const FW_CPoint& mouse,
  160.                         FW_Fixed zoomFactor) const;
  161.  
  162.     void        SelectProxy(Environment* ev, 
  163.                         FW_Boolean state);
  164.  
  165.     void        SubtractToWindowClip(Environment* ev, 
  166.                          FW_CFacetClipper* facetClipper, 
  167.                          ODFacet* containingFacet, 
  168.                          ODShape* windowClip,
  169.                          ODShape* tempShape);
  170.  
  171.     FW_Boolean    IsSelected() const;
  172.     
  173.     ODTypeToken    GetViewAs() const;
  174.     void        ChangeViewAs(Environment* ev, ODTypeToken viewAs);
  175.     
  176.     void        GetMappedRects(short whichHandle, 
  177.                         const FW_CPoint& mouseLoc, 
  178.                         FW_CRect& srcRect, 
  179.                         FW_CRect& dstRect);
  180.  
  181.     FW_Boolean    HasChanged() const
  182.                     {return fChanged;}
  183.     void        SetHasChanged(FW_Boolean state)
  184.                     {fChanged = state;}
  185.                     
  186. //----------------------------------------------------------------------------------------
  187. //    Data Members
  188. //
  189.   public:
  190.     static unsigned long    fgProxyCount;
  191.     static FW_CRectShape*    fgWorkingHandle;
  192.  
  193.   private:
  194.     CContainerPart*            fContainerPart;
  195.     FW_CRect                fBounds;
  196.     FW_Boolean                fSelected;
  197.     ODTypeToken                fViewAs;    // I am caching the view as
  198.     FW_Boolean                fChanged;
  199. };
  200.  
  201. //========================================================================================
  202. //    Inlines
  203. //========================================================================================
  204.  
  205. //----------------------------------------------------------------------------------------
  206. inline FW_CRect CProxy::GetBounds(Environment*) const
  207. {
  208.     return fBounds;
  209. }
  210.  
  211. //----------------------------------------------------------------------------------------
  212. inline FW_Boolean CProxy::IsSelected() const
  213. {
  214.     return fSelected;
  215. }
  216.  
  217. //----------------------------------------------------------------------------------------
  218. inline ODTypeToken CProxy::GetViewAs() const
  219. {
  220.     return fViewAs;
  221. }
  222.  
  223. #endif
  224.