// $Revision: 1.35 $ // Copyright (C) 1994 Taligent, Inc. All rights reserved. #ifndef Taligent_STANDARDGRAFEDIT #define Taligent_STANDARDGRAFEDIT #ifndef Taligent_BASICDOCUMENT #include #endif #ifndef Taligent_PRIMITIVECLASSES #include #endif #ifndef Taligent_BASICDOCUMENTCOMMAND #include #endif #ifndef Taligent_COMPOUNDDOCUMENT #include #endif #ifndef Taligent_COMPOUNDDOCUMENTSTORAGE #include #endif #ifndef Taligent_COMPOUNDDOCUMENTCOMMAND #include #endif #ifndef Taligent_GRAFEDIT #include #endif #ifndef Taligent_GRAFEDITUTILITIES #include #endif #ifndef Taligent_MOMENTARYCONTROLS #include #endif #ifndef Taligent_PRIMITIVECLASSES #include #endif #ifndef Taligent_GUICOMPOUNDDOCUMENTCOMMAND #include #endif #ifndef API_DIRT #ifndef Taligent_GUICOMPOUNDDOCUMENTTOOLSUPPORT #include #endif #endif // Classes defined in this file: class TStandardCanvasView; class TStandardCanvasModel; class TStandardCanvasModelSelection; class TGUIToolCommandBinding; // ******************************************************************************** // class TStandardCanvasView // // description A concrete canvas view that is based on a model to store // canvas graphics. // // ******************************************************************************** class TStandardCanvasView : public TCanvasView { public: TStandardCanvasView (TGUIBundle* theBundleToAlias); TStandardCanvasView (const TStandardCanvasView&); virtual ~TStandardCanvasView (); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TStandardCanvasView); #ifndef NO_Internal virtual bool IsEqual (const MCollectible*) const; #endif virtual long Hash() const; TStandardCanvasView& operator= (const TStandardCanvasView&); virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); //======================================== // MToolHandler Overrides //======================================== virtual void AdoptAndDo (TToolCommandBinding*); virtual void DoBegin (TToolCommandBinding&); virtual void DoIncrement (TToolCommandBinding&); virtual void AdoptAndDoEnd (TToolCommandBinding*); //======================================== // TCanvasView Overrides //======================================== virtual void EnumerateGraphics (TCanvasGraphicFilter&, TCanvasGraphicFunnel&) const; virtual void RegisterNotificationInterest (TRequestBasedMemberFunctionConnectionTo&); virtual MCanvasSelection* CreateEmptySelection () const; virtual MCanvasSelection* CopyCurrentSelection () const; virtual void SetCurrentSelection (const MCanvasSelection&); virtual void AdoptCurrentSelection (MCanvasSelection*); //======================================== // TModelBasedCanvasView Methods //======================================== const TStandardCanvasModel* LookupCanvasModelForReading (TDocumentComponentReadEntry&) const; /* const TStandardCanvasPresenterState* LookupCanvasPresenterStateForReading (TDocumentComponentReadEntry&) const; TStandardCanvasPresenterState* LookupCanvasPresenterStateForWriting (TDocumentComponentWriteEntry&); */ virtual void HandleGraphicsChanged (const TNotification&); virtual void HandleSelectionChanged (const TNotification&); virtual void HandleDrasticChange (const TNotification&); TPresenterStateReference GetPresenterStateReference () const; TModelReference GetModelReference () const; TGUIBundle* GetGUIBundle() const; protected: TStandardCanvasView (); #ifndef NO_Internal private: void* fExtension; TGUIToolCommandBinding* fCommandBinding; TGUIBundle* fGUIBundle; TGArea fPreviousSelectionArea; enum Version { kOriginalVersion }; #endif }; //======================================================================= // class TStandardCanvasModel // // description A default model for GrafEdit applications // //======================================================================== class TStandardCanvasModel : public TModel, public MCanvasRepresentation { public: TStandardCanvasModel (); TStandardCanvasModel (const TStandardCanvasModel&); virtual ~TStandardCanvasModel (); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TStandardCanvasModel); DynamicCastDeclarationsMacro (); TStandardCanvasModel& operator= (const TStandardCanvasModel&); virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); //======================================== // TModel Overrides //======================================== virtual TModelSelection* CreateSelection () const; //======================================== // TGrafEditModel Methods //======================================== TModelInterest GetGraphicsAddedInterest () const; TModelInterest GetGraphicsRemovedInterest () const; TModelInterest GetGraphicsChangedInterest () const; TModelInterest GetDrasticChangeInterest () const; TModelInterest GetEmbeddedGraphicAddedInterest () const; virtual void AdoptAtFront (MCanvasGraphic*); virtual void AdoptAtBack (MCanvasGraphic*); virtual void AdoptAfter (const TCanvasGraphicID& existing, MCanvasGraphic* toBeAdded); virtual void AdoptBefore (const TCanvasGraphicID& existing, MCanvasGraphic* toBeAdded); virtual void MoveToFront (const TCanvasGraphicID&); virtual void MoveToBack (const TCanvasGraphicID&); virtual bool MoveForward (const TCanvasGraphicID&); virtual bool MoveBackward (const TCanvasGraphicID&); virtual MCanvasGraphic* Orphan (const TCanvasGraphicID&); virtual MCanvasGraphic* Swap (const TCanvasGraphicID&, MCanvasGraphic* adopt); virtual void Delete (const TCanvasGraphicID&); virtual void DeleteAll (); virtual bool Member (const TCanvasGraphicID&) const; virtual TCanvasGraphicID FrontMost () const; virtual TCanvasGraphicID BackMost () const; virtual TCanvasGraphicID After (const TCanvasGraphicID&) const; virtual TCanvasGraphicID Before (const TCanvasGraphicID&) const; virtual long Count () const; virtual const MCanvasGraphic* Lookup (const TCanvasGraphicID&) const; virtual MCanvasGraphic* Lookup (const TCanvasGraphicID&); virtual TCanvasGraphicReadIterator* CreateReadIterator () const; virtual TCanvasGraphicWriteIterator* CreateWriteIterator (); // This routine is useful in the MDataExchange overrides in StandardCanvasModelSelection. // Basically MCanvasGraphics do not currently know enough to be able to "undo" themselves into // their original location in reference to the surrounding MCanvasGraphics. This would require // knowledge of the neighboring MCanvasGraphics canvas ids, which is otherwise unnecessary due // to the current deque based storage mechanism. Other storage mechanisms may obviate the need for this method. //TCanvasGraphicAssociationsWith* GetUndoRedoLocation (); TDequeOf* GetUndoRedoOrder (); #ifndef NO_Internal private: void* fExtension; TCanvasGraphicDeque fGraphicDeque; //TCanvasGraphicAssociationsWith* fUndoRedoLocations; TDequeOf* fUndoRedoOrder; enum Version { kOriginalVersion }; #endif }; //======================================================================= // class TStandardCanvasModelSelection // // description A GrafEdit selection that binds the canvas representation // to a model. It implements GetCanvasRepresentation... // methods to return the underlying TGrafEditModel, which // mixes in MCanvasRepresentation. //======================================================================== class TStandardCanvasModelSelection : public TModelSelection, public MCanvasSelection, public MDataExchanger { public: TStandardCanvasModelSelection (const TStandardCanvasModel&); TStandardCanvasModelSelection (const TStandardCanvasModelSelection&); virtual ~TStandardCanvasModelSelection (); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TStandardCanvasModelSelection); DynamicCastDeclarationsMacro (); #ifndef NO_Internal virtual bool IsEqual (const MCollectible*) const; #endif virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); TStandardCanvasModelSelection& operator= (const TStandardCanvasModelSelection&); //======================================== // TModelSelection Overrides //======================================== virtual void SelectWholeModel() ; //======================================== // MCanvasSelection Overrides //======================================== // Canvas graphic enumeration for read-only operations. // Used by DrawGraphics and Hit. virtual void EnumerateGraphics (TCanvasGraphicFilter&, TCanvasGraphicFunnel&) const; // This method acquires a read lock on the model before calling // the inherited SelectAllGraphics virtual void SelectAllGraphics (); // These return a TGrafEditModel, which mixes in MCanvasRepresentation virtual MCanvasRepresentation* GetCanvasRepresentationForReading () const; virtual MCanvasRepresentation* GetCanvasRepresentationForWriting (); virtual void Invalidate (const TGArea&); //------------------------------------------------------------ // Type negotiation virtual void CreateAvailableTypesList(TSequenceOf& theTypes) const; virtual void ChooseTypes(const TSequenceOf& theChoices, TSequenceOf& theChosenTypes) const; protected: TStandardCanvasModelSelection (); virtual TModel* HandleCopyData(const TTypeDescription& theType) const ; virtual void HandleCopyDataInto(TModel& theModel) const ; virtual TModel* HandleOrphanData() ; virtual TModel* HandleReplaceData(TModel* theData) ; #ifndef NO_Internal private: virtual MCanvasSelection* CopyCanvasSelection() const; void* fExtension; enum Version { kOriginalVersion }; #endif }; //======================================================================= // class TStandardCanvasSelectionNotification // // description Used to notify intersted parties of change to // a collection of canvas graphics in the model. //======================================================================== class TStandardCanvasSelectionNotification : public TSelectionNotification { public: TStandardCanvasSelectionNotification ( const TModelInterest&, const TStandardCanvasModelSelection&, const TGArea& ); TStandardCanvasSelectionNotification (const TStandardCanvasSelectionNotification&); virtual ~TStandardCanvasSelectionNotification (); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TStandardCanvasSelectionNotification); virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); virtual long Hash () const; #ifndef NO_Internal virtual bool IsEqual (const MCollectible*) const; #endif const TStandardCanvasSelectionNotification& operator= (const TStandardCanvasSelectionNotification&); //======================================== // TStandardCanvasSelectionNotification Methods //======================================== virtual const TStandardCanvasModelSelection* GetSelection() const; virtual TGArea GetArea () const; virtual void GetArea (TGArea&) const; protected: // for streaming and subclasses TStandardCanvasSelectionNotification (); #ifndef NO_Internal private: void* fExtension; TGArea fArea; enum Version { kOriginalVersion }; #endif }; //================================================================================ // class TStandardCanvasFillColorSelectionState // // description Sets the fill color of the current selection. //================================================================================ class TStandardCanvasFillColorSelectionState : public TCommandControlStateOn { public: TStandardCanvasFillColorSelectionState (const TStandardCanvasFillColorSelectionState&); TStandardCanvasFillColorSelectionState (const TColor&, TGUIBundleConnection* theBundleConnectionToAlias); virtual ~TStandardCanvasFillColorSelectionState (); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TStandardCanvasFillColorSelectionState); TStandardCanvasFillColorSelectionState& operator= (const TStandardCanvasFillColorSelectionState&); virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); //======================================= // TCommandControlStateOn Overrides //======================================= void HandleAddInterests( TSetOf &theInterests) const; protected: // For MCollectible cloning and subclasses TStandardCanvasFillColorSelectionState (); #ifndef NO_Internal private: void* fExtension; enum Version { kOriginalVersion }; #endif }; //================================================================================ // class TStandardCanvasFrameColorSelectionState // // description Sets the frame color of the current selection. //================================================================================ class TStandardCanvasFrameColorSelectionState : public TCommandControlStateOn { public: TStandardCanvasFrameColorSelectionState (const TStandardCanvasFrameColorSelectionState&); TStandardCanvasFrameColorSelectionState (const TColor&, TGUIBundleConnection* theBundleConnectionToAlias); virtual ~TStandardCanvasFrameColorSelectionState (); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TStandardCanvasFrameColorSelectionState); TStandardCanvasFrameColorSelectionState& operator= (const TStandardCanvasFrameColorSelectionState&); virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); //======================================= // TCommandControlStateOn Overrides //======================================= void HandleAddInterests( TSetOf &theInterests) const; protected: // For MCollectible cloning and subclasses TStandardCanvasFrameColorSelectionState (); #ifndef NO_Internal private: void* fExtension; enum Version { kOriginalVersion }; #endif }; //================================================================================ // class TStandardCanvasLineWidthSelectionState // // description Sets the line width of the current selection. //================================================================================ class TStandardCanvasLineWidthSelectionState : public TCommandControlStateOn { public: TStandardCanvasLineWidthSelectionState (const TStandardCanvasLineWidthSelectionState&); TStandardCanvasLineWidthSelectionState (GCoordinate, TGUIBundleConnection* theBundleConnectionToAlias); virtual ~TStandardCanvasLineWidthSelectionState (); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TCursorToolSelectionState); TStandardCanvasLineWidthSelectionState& operator= (const TStandardCanvasLineWidthSelectionState&); virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); //======================================= // TCommandControlStateOn Overrides //======================================= void HandleAddInterests( TSetOf &theInterests) const; protected: // For MCollectible cloning and subclasses TStandardCanvasLineWidthSelectionState (); #ifndef NO_Internal private: void* fExtension; enum Version { kOriginalVersion }; #endif }; #endif // Taligent_STANDARDGRAFEDIT