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 / DrawPart.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  12.1 KB  |  385 lines  |  [TEXT/MPS ]

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