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 / DrawPart.h < prev    next >
Encoding:
Text File  |  1996-08-16  |  11.2 KB  |  362 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawPart.h
  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. #ifndef DRAWPART_H
  13. #define DRAWPART_H
  14.  
  15. // ----- Part Layer -----
  16.  
  17. #ifndef FWPARTNG_H
  18. #include "FWPartng.h"
  19. #endif
  20.  
  21. #ifndef FWSELECT_H
  22. #include "FWSelect.h"
  23. #endif
  24.  
  25. #ifndef FWPRTSCP_H
  26. #include "FWPrtScp.h"
  27. #endif
  28.  
  29. // ----- OS Layer -----
  30.  
  31. #ifndef FWCOLOR_H
  32. #include "FWColor.h"
  33. #endif
  34.  
  35. #ifndef FWPOINT_H
  36. #include "FWPoint.h"
  37. #endif
  38.  
  39. #ifndef FWRESFIL_H
  40. #include "FWResFil.h"
  41. #endif
  42.  
  43. //========================================================================================
  44. //    Forward Declarations
  45. //========================================================================================
  46.  
  47. class FW_CFloatingWindow;
  48. class FW_CMenuEvent;
  49. class FW_CDropCommand;
  50. class FW_CPresentation;
  51.  
  52. class CBaseShape;
  53. class CProxyShape;
  54. class CToolFrame;
  55. class CPaletteFrame;
  56. class CPatternFrame;
  57. class CDrawSelection;
  58. class FW_CGraphicContext;
  59. class CDrawLinkManager;
  60. class CShapeCollection;
  61. class CDrawPartContent;
  62.  
  63. //========================================================================================
  64. //    Defines
  65. //========================================================================================
  66.  
  67. #define kContentAnnotationProp        "Apple:Framework:Proposition:ContentAnnotation"
  68. #define kContentAnnotationValue        "Apple:Framework:Value:ContentAnnotation"
  69.  
  70. //========================================================================================
  71. //    class CDrawPart
  72. //========================================================================================
  73.  
  74. class CDrawPart : public FW_CEmbeddingPart, public FW_MEmbeddingPartScriptable
  75. {
  76. public:
  77.     FW_DECLARE_CLASS
  78.     FW_DECLARE_AUTO(CDrawPart)
  79.     
  80.     friend class CDrawLinkManager;
  81.  
  82. //----------------------------------------------------------------------------------------
  83. //    Initialization/Destruction
  84. //
  85. public:        
  86.     CDrawPart(ODPart* odPart);
  87.     virtual ~ CDrawPart();
  88.  
  89.     virtual void                ReleaseAll(Environment *ev);
  90.     virtual void                Initialize(Environment *ev);
  91.         
  92.     void                        InitializePalettes(Environment *ev);
  93.     
  94. //----------------------------------------------------------------------------------------
  95. //    Inherited API
  96. //
  97. public:
  98.     virtual void                EmbeddedFrameRemoved(Environment *ev, 
  99.                                     FW_MProxy* proxy);
  100.     
  101.     virtual FW_Boolean            DoMenu(Environment *ev, 
  102.                                     const FW_CMenuEvent& theMenuEvent);
  103.     virtual FW_Boolean            DoAdjustMenus(Environment *ev, 
  104.                                     FW_CMenuBar* menuBar, 
  105.                                     FW_Boolean hasMenuFocus, FW_Boolean isRoot);
  106.     
  107.     virtual FW_CFrame*             NewFrame(Environment *ev,
  108.                                     ODFrame* odFrame, 
  109.                                     FW_CPresentation* presentation,
  110.                                     FW_Boolean fromStorage);
  111.                                     
  112.     virtual FW_CLinkManager*     NewLinkManager(Environment *ev);
  113.     
  114.     virtual FW_CContent*        NewPartContent(Environment* ev);
  115.  
  116.     virtual FW_CWindow*            NewDocumentWindow(Environment* ev);
  117.  
  118. //----------------------------------------------------------------------------------------
  119. //    New API
  120. //
  121. public:    
  122.     void                         ExternalizeAnnotations(Environment *ev, ODStorageUnit* storageUnit);
  123.     void                         InternalizeAnnotations(Environment *ev, ODStorageUnit* storageUnit);
  124.  
  125.     void                        RemoveShapeFromPart(Environment* ev, CBaseShape* shape);
  126.     void                        AddShapeToPart(Environment* ev, CBaseShape* shape);
  127.  
  128.     CBaseShape*                 WhichShape(Environment *ev, 
  129.                                         FW_CGraphicContext& gc,
  130.                                         const FW_CMouseEvent& theMouseEvent,
  131.                                         FW_Boolean hasToBeSelected) const;
  132.  
  133.     FW_Fixed                    GetPenSize() const;
  134.     unsigned short                GetRenderVerb() const;
  135.  
  136.     FW_CPoint                GetDrawingSize() const;
  137.  
  138.     void                    CheckTool(Environment* ev, unsigned short oldTool, unsigned short newTool);
  139.     void                    CheckRenderVerb(Environment* ev, unsigned short oldRenderVerb, unsigned short newRenderVerb);
  140.     void                    SetRenderVerb(Environment* ev, unsigned short renderVerb);
  141.     
  142.     void                    GetFillColor(FW_CColor& color) const;
  143.     void                    GetFrameColor(FW_CColor& color) const;
  144.  
  145.     void                    SetFillColor(Environment* ev, const FW_CColor& color);
  146.     void                    SetFrameColor(Environment* ev, const FW_CColor& color);
  147.     
  148.     FW_CPattern                GetFillPattern() const;
  149.     FW_CPattern                GetFramePattern() const;
  150.  
  151.     void                    SetFillPattern(Environment* ev, short newFillPatIndex);
  152.     void                    SetFramePattern(Environment* ev, short newFramePatIndex);
  153.     
  154.     void                    UpdateAfterMove(Environment* ev);
  155.  
  156.     void                    SetTool(Environment* ev, unsigned short newTool);
  157.     unsigned short            GetTool() const;
  158.                                 
  159.     FW_CPattern                GetPattern(short patIndex) const;
  160.     
  161.     void                     UpdateAllToolFacets(Environment *ev);
  162.  
  163.     FW_CPresentation*        GetMainPresentation() const;
  164.     FW_CPresentation*        GetPalettePresentation() const;
  165.     FW_CPresentation*        GetPatternPresentation() const;
  166.     FW_CPresentation*        GetToolPresentation() const;
  167.  
  168.     FW_Boolean                IsAutoGridOn() const;
  169.     
  170.     long                    GetProxyCount() const;
  171.     
  172.     CBaseShape*                NewShape(Environment* ev, unsigned short shapeType);
  173.  
  174.     CDrawPartContent*        GetDrawContent() const;
  175.     
  176.     //--- Persistent link support ---
  177.     void                    DoPostCreate(Environment* ev);    // MacApp forever!
  178.     CBaseShape*                FindShapeWithIndex(short extIndex);
  179.  
  180.     //--- Semantic Object ---
  181.     
  182.     virtual FW_CElementIterator*    NewElementIterator(Environment* ev,
  183.                                                         FW_CPart* part,
  184.                                                         ODDescType elementType) const;
  185.  
  186.     virtual void                    DoAECreateElement(Environment* ev,
  187.                                                         FW_CPart* part,
  188.                                                         const FW_CAppleEvent& event,
  189.                                                         FW_CAppleEvent& reply);
  190. private:
  191.     
  192.  
  193. //----------------------------------------------------------------------------------------
  194. //    Data Members
  195. //
  196. private:    
  197.     short                fNbEmbedded;
  198.         
  199.     FW_CFloatingWindow*    fPaletteWindow;
  200.     FW_CFloatingWindow*    fPatternWindow;
  201.     FW_CFloatingWindow*    fToolsWindow;
  202.  
  203.     CToolFrame*            fToolFrame;
  204.     CPaletteFrame*        fPaletteFrame;
  205.     CPatternFrame*        fPatternFrame;
  206.         
  207.     CDrawPartContent*    fPartContent;
  208.     FW_CPoint            fDrawingSize;
  209.     
  210.     unsigned short        fTool;
  211.     FW_Fixed            fCurrentPenSize;
  212.     unsigned short        fRenderVerb;
  213.     FW_CColor            fFillColor;
  214.     FW_CColor            fFrameColor;
  215.     short                fFillPatIndex;
  216.     short                fFramePatIndex;
  217.     
  218.     CDrawSelection*        fDrawSelection;    // Attention I don't own the selection the presentation is
  219.     
  220.     FW_CPresentation*    fPalettePresentation;
  221.     FW_CPresentation*    fPatternPresentation;
  222.     FW_CPresentation*    fToolPresentation;
  223.     FW_CPresentation*    fMainPresentation;
  224.     FW_CPresentation*    fAlignObjectsPresentation;
  225.     
  226.     FW_CPattern            fPatternTable[12];
  227.     
  228.     FW_Boolean            fAutoGrid;
  229.  
  230.     ODCommandID            fUnit;
  231.     ODCommandID            fArcUnit;
  232.  
  233.     FW_Boolean            fPostCreated;    // perform DoPostCreate only once
  234. };
  235.  
  236. //========================================================================================
  237. //    Inlines
  238. //========================================================================================
  239.  
  240. //----------------------------------------------------------------------------------------
  241. //    CDrawPart::GetDrawContent
  242. //----------------------------------------------------------------------------------------
  243. inline CDrawPartContent* CDrawPart::GetDrawContent() const
  244. {
  245.     return fPartContent;
  246. }
  247.  
  248. //----------------------------------------------------------------------------------------
  249. //    CDrawPart::GetDrawingSize
  250. //----------------------------------------------------------------------------------------
  251. inline FW_CPoint CDrawPart::GetDrawingSize() const
  252. {
  253.     return fDrawingSize;
  254. }
  255.  
  256. //----------------------------------------------------------------------------------------
  257. //    CDrawPart::IsAutoGridOn
  258. //----------------------------------------------------------------------------------------
  259. inline FW_Boolean CDrawPart::IsAutoGridOn() const
  260. {
  261.     return fAutoGrid;
  262. }
  263.  
  264. //----------------------------------------------------------------------------------------
  265. //    CDrawPart::GetPenSize
  266. //----------------------------------------------------------------------------------------
  267. inline FW_Fixed CDrawPart::GetPenSize() const
  268. {
  269.     return fCurrentPenSize;
  270. }
  271.  
  272. //----------------------------------------------------------------------------------------
  273. //    CDrawPart::GetRenderVerb
  274. //----------------------------------------------------------------------------------------
  275. inline unsigned short CDrawPart::GetRenderVerb() const
  276. {
  277.     return fRenderVerb;
  278. }
  279.  
  280. //----------------------------------------------------------------------------------------
  281. //    CDrawPart::GetTool
  282. //----------------------------------------------------------------------------------------
  283. inline unsigned short CDrawPart::GetTool() const
  284. {
  285.     return fTool;
  286. }
  287.  
  288. //----------------------------------------------------------------------------------------
  289. //    CDrawPart::GetMainPresentation
  290. //----------------------------------------------------------------------------------------
  291. inline FW_CPresentation* CDrawPart::GetMainPresentation() const
  292. {
  293.     return fMainPresentation;
  294. }
  295.  
  296. //----------------------------------------------------------------------------------------
  297. //    CDrawPart::GetPalettePresentation
  298. //----------------------------------------------------------------------------------------
  299. inline FW_CPresentation* CDrawPart::GetPalettePresentation() const
  300. {
  301.     return fPalettePresentation;
  302. }
  303.  
  304. //----------------------------------------------------------------------------------------
  305. //    CDrawPart::GetPatternPresentation
  306. //----------------------------------------------------------------------------------------
  307. inline FW_CPresentation* CDrawPart::GetPatternPresentation() const
  308. {
  309.     return fPatternPresentation;
  310. }
  311.  
  312. //----------------------------------------------------------------------------------------
  313. //    CDrawPart::GetToolPresentation
  314. //----------------------------------------------------------------------------------------
  315. inline FW_CPresentation* CDrawPart::GetToolPresentation() const
  316. {
  317.     return fToolPresentation;
  318. }
  319.  
  320. //----------------------------------------------------------------------------------------
  321. //    CDrawPart::GetPattern
  322. //----------------------------------------------------------------------------------------
  323. inline FW_CPattern CDrawPart::GetPattern(short patIndex) const
  324. {
  325.     FW_ASSERT(patIndex>=0 && patIndex<12);
  326.     return fPatternTable[patIndex];
  327. }
  328.  
  329. //----------------------------------------------------------------------------------------
  330. //    CDrawPart::GetFillColor
  331. //----------------------------------------------------------------------------------------
  332. inline void CDrawPart::GetFillColor(FW_CColor& color) const
  333. {
  334.     color = fFillColor;
  335. }
  336.  
  337. //----------------------------------------------------------------------------------------
  338. //    CDrawPart::GetFrameColor
  339. //----------------------------------------------------------------------------------------
  340. inline void CDrawPart::GetFrameColor(FW_CColor& color) const
  341. {
  342.     color = fFrameColor;
  343. }
  344.  
  345. //----------------------------------------------------------------------------------------
  346. //    CDrawPart::GetFillPattern
  347. //----------------------------------------------------------------------------------------
  348. inline FW_CPattern CDrawPart::GetFillPattern() const
  349. {
  350.     return fPatternTable[fFillPatIndex];
  351. }
  352.  
  353. //----------------------------------------------------------------------------------------
  354. //    CDrawPart::GetFramePattern
  355. //----------------------------------------------------------------------------------------
  356. inline FW_CPattern CDrawPart::GetFramePattern() const
  357. {
  358.     return fPatternTable[fFramePatIndex];
  359. }
  360.  
  361. #endif
  362.