home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 12.1 KB | 385 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawPart.h
- // Release Version: $ ODF 2 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef DRAWPART_H
- #define DRAWPART_H
-
- #ifndef FWPARTNG_H
- #include "FWPartng.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWPRTSCP_H
- #include "FWPrtScp.h"
- #endif
-
- #ifndef FWPAT_H
- #include "FWPat.h"
- #endif
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRESFIL_H
- #include "FWResFil.h"
- #endif
-
- #ifndef FWRECEVR_H
- #include "FWRecevr.h"
- #endif
-
- #ifndef FWNOTIFR_H
- #include "FWNotifr.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_CFloatingWindow;
- class FW_CMenuEvent;
- class FW_CDropCommand;
- class FW_CPresentation;
-
- class CBaseShape;
- class CProxyShape;
- class CToolFrame;
- class CPaletteFrame;
- class CPatternFrame;
- class CDrawSelection;
- class FW_CGraphicContext;
- class CDrawLinkManager;
- class CShapeCollection;
- class CDrawPartContent;
- class CDrawFrame;
-
- //========================================================================================
- // Defines
- //========================================================================================
-
- #define kContentAnnotationProp "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:ODFExamples:Annotation:Property:ODFDraw"
- #define kContentAnnotationValue "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:ODFExamples:Annotation:Value:ODFDraw"
-
- //========================================================================================
- // class CDrawPart
- //========================================================================================
-
- class CDrawPart : public FW_CEmbeddingPart, public FW_MEmbeddingPartScriptable, public FW_MReceiver, public FW_MNotifier
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(CDrawPart)
-
- friend class CDrawLinkManager;
-
- //----------------------------------------------------------------------------------------
- // Initialization/Destruction
- //
- public:
- CDrawPart(ODPart* odPart);
- virtual ~ CDrawPart();
-
- virtual void ReleaseAll(Environment *ev);
- virtual void Initialize(Environment *ev, ODStorageUnit* storageUnit, FW_Boolean fromStorage);
-
- void InitializePalettes(Environment *ev);
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- virtual void EmbeddedFrameRemoved(Environment *ev,
- FW_MProxy* proxy);
-
- virtual FW_Handled DoMenu(Environment *ev,
- const FW_CMenuEvent& theMenuEvent);
- virtual FW_Handled DoAdjustMenus(Environment *ev,
- FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus, FW_Boolean isRoot);
-
- virtual FW_Handled DoAbout(Environment* ev);
-
- virtual FW_CFrame* NewFrame(Environment *ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage);
-
- virtual FW_CLinkManager* NewLinkManager(Environment *ev);
-
- virtual FW_CContent* NewPartContent(Environment* ev);
-
- virtual FW_CWindow* NewDocumentWindow(Environment* ev);
-
- virtual void HandleNotification(Environment* ev, const FW_CNotification& notification);
-
- virtual FW_Boolean InternalizeContent(Environment* ev,
- ODStorageUnit* storageUnit,
- FW_CCloneInfo* cloneInfo);
-
- virtual void ExternalizeContent(Environment* ev,
- ODStorageUnit* storageUnit,
- FW_CCloneInfo* cloneInfo);
-
- virtual void PrintInfoChanged(Environment *ev, FW_CPrintInfo* printInfo);
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- void RemoveShapeFromPart(Environment* ev, CBaseShape* shape);
- void AddShapeToPart(Environment* ev, CBaseShape* shape);
-
- CBaseShape* WhichShape(Environment *ev,
- FW_CGraphicContext& gc,
- const FW_CMouseEvent& theMouseEvent,
- FW_Boolean hasToBeSelected) const;
-
- FW_Fixed GetPenSize() const;
- unsigned short GetRenderVerb() const;
-
- FW_CPoint GetDrawingSize() const;
- void SetDrawingSize(Environment* ev, const FW_CPoint& newSize);
-
- void CheckTool(Environment* ev, unsigned short oldTool, unsigned short newTool);
- void CheckRenderVerb(Environment* ev, unsigned short oldRenderVerb, unsigned short newRenderVerb);
- void SetRenderVerb(Environment* ev, unsigned short renderVerb);
-
- void GetFillColor(FW_CColor& color) const;
- void GetFrameColor(FW_CColor& color) const;
-
- void SetColor(Environment* ev, const FW_CColor& color, FW_ERenderVerbs renderVerb);
-
- FW_CPattern GetFillPattern() const;
- FW_CPattern GetFramePattern() const;
-
- void SetPattern(Environment* ev, short newFillPatIndex, FW_ERenderVerbs renderVerb);
-
- void UpdateAfterMove(Environment* ev);
-
- void SetTool(Environment* ev, unsigned short newTool);
- unsigned short GetTool() const;
-
- FW_CPattern GetPattern(short patIndex) const;
-
- void NotifyForColorChanged(Environment *ev, const FW_CColor& color, FW_ERenderVerbs renderVerb);
- void NotifyForPatternChanged(Environment *ev, short patIndex, FW_ERenderVerbs renderVerb);
-
- FW_CPresentation* GetMainPresentation() const;
- FW_CPresentation* GetPalettePresentation() const;
- FW_CPresentation* GetPatternPresentation() const;
- FW_CPresentation* GetToolPresentation() const;
-
- FW_Boolean IsAutoGridOn() const;
-
- long GetProxyCount() const;
-
- CBaseShape* NewShape(Environment* ev, unsigned short shapeType);
-
- CDrawPartContent* GetDrawContent() const;
-
- void OnAcquireSelectionFocus(Environment* ev, CDrawFrame* frame);
-
- //--- Persistent link support ---
- void DoPostCreate(Environment* ev); // MacApp forever!
- CBaseShape* FindShapeWithIndex(short extIndex);
-
- //--- Semantic Object ---
-
- virtual FW_CElementIterator* NewElementIterator(Environment* ev,
- FW_CPart* part,
- ODDescType desiredClass) const;
-
- virtual void DoAECreateElement(Environment* ev,
- FW_CPart* part,
- const FW_CAppleEvent& event,
- FW_CAppleEvent& reply);
-
- FW_Boolean ShapeClassToType(ODDescType shapeClass,
- unsigned short& shapeType) const;
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- short fNbEmbedded;
-
- FW_CFloatingWindow* fPaletteWindow;
- FW_CFloatingWindow* fPatternWindow;
- FW_CFloatingWindow* fToolsWindow;
-
- CToolFrame* fToolFrame;
- CPaletteFrame* fPaletteFrame;
- CPatternFrame* fPatternFrame;
-
- CDrawPartContent* fPartContent;
- FW_CPoint fDrawingSize;
-
- unsigned short fTool;
- FW_Fixed fCurrentPenSize;
- unsigned short fRenderVerb;
- FW_CColor fFillColor;
- FW_CColor fFrameColor;
- short fFillPatIndex;
- short fFramePatIndex;
-
- CDrawSelection* fDrawSelection; // Attention I don't own the selection the presentation is
-
- FW_CPresentation* fPalettePresentation;
- FW_CPresentation* fPatternPresentation;
- FW_CPresentation* fToolPresentation;
- FW_CPresentation* fMainPresentation;
- FW_CPresentation* fAlignObjectsPresentation;
-
- FW_CPattern fPatternTable[12];
-
- FW_Boolean fAutoGrid;
-
- ODCommandID fUnit;
- ODCommandID fArcUnit;
-
- FW_Boolean fPostCreated; // perform DoPostCreate only once
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetDrawContent
- //----------------------------------------------------------------------------------------
- inline CDrawPartContent* CDrawPart::GetDrawContent() const
- {
- return fPartContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetDrawingSize
- //----------------------------------------------------------------------------------------
- inline FW_CPoint CDrawPart::GetDrawingSize() const
- {
- return fDrawingSize;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::IsAutoGridOn
- //----------------------------------------------------------------------------------------
- inline FW_Boolean CDrawPart::IsAutoGridOn() const
- {
- return fAutoGrid;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPenSize
- //----------------------------------------------------------------------------------------
- inline FW_Fixed CDrawPart::GetPenSize() const
- {
- return fCurrentPenSize;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetRenderVerb
- //----------------------------------------------------------------------------------------
- inline unsigned short CDrawPart::GetRenderVerb() const
- {
- return fRenderVerb;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetTool
- //----------------------------------------------------------------------------------------
- inline unsigned short CDrawPart::GetTool() const
- {
- return fTool;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetMainPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetMainPresentation() const
- {
- return fMainPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPalettePresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetPalettePresentation() const
- {
- return fPalettePresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPatternPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetPatternPresentation() const
- {
- return fPatternPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetToolPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetToolPresentation() const
- {
- return fToolPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFillColor
- //----------------------------------------------------------------------------------------
- inline void CDrawPart::GetFillColor(FW_CColor& color) const
- {
- color = fFillColor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFrameColor
- //----------------------------------------------------------------------------------------
- inline void CDrawPart::GetFrameColor(FW_CColor& color) const
- {
- color = fFrameColor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFillPattern
- //----------------------------------------------------------------------------------------
- inline FW_CPattern CDrawPart::GetFillPattern() const
- {
- return fPatternTable[fFillPatIndex];
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFramePattern
- //----------------------------------------------------------------------------------------
- inline FW_CPattern CDrawPart::GetFramePattern() const
- {
- return fPatternTable[fFramePatIndex];
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPattern
- //----------------------------------------------------------------------------------------
- inline FW_CPattern CDrawPart::GetPattern(short patIndex) const
- {
- FW_ASSERT(patIndex>=0 && patIndex<12);
- return fPatternTable[patIndex];
- }
-
- #endif
-