// $Revision: 1.13 $ // Copyright (C) 1994 Taligent, Inc. All rights reserved. #ifndef Taligent_CANVASGRAPHICMANIPULATION #define Taligent_CANVASGRAPHICMANIPULATION #ifndef Taligent_GRAFEDIT #include #endif #ifndef Taligent_GRAFEDITUTILITIES #include #endif #ifndef Taligent_CANVASINTERACTION #include #endif // Classes defined in this file: class TCanvasGraphicScalingInteractor; class TCanvasGraphicRotatingInteractor; class TCanvasGraphicTranslatingInteractor; class TSRTFeedbacker; class TSRTBoxFeedbacker; //================================================================================ // class TCanvasGraphicScalingInteractor // // description An interactor that scales canvas graphics in the target // selection. Graphics are scaled around the center of scale. // //================================================================================ class TCanvasGraphicScalingInteractor : public TCanvasDragInteractor { public: TCanvasGraphicScalingInteractor ( MCanvasSelection* adoptTarget, MToolHandler*, const TGPoint& centerOfScale, const TGrafMatrix& tform ); virtual ~TCanvasGraphicScalingInteractor (); //======================================== // Metadata //======================================== VersionDeclarationsMacro (TCanvasGraphicScalingInteractor); //======================================== // TCanvasInteractor Overrides //======================================== virtual void StartInteraction (); virtual void ContinueInteraction (); virtual void EndInteraction (); #ifndef NO_Internal private: void* fExtension; TGPoint fCenter; TGrafMatrix fTransform; TGPoint fLastVector; TDeleterFor fBinding; TScaleCanvasGraphicCmd* fCommand; MCanvasSelection* fSelection; #endif }; //================================================================================ // class TCanvasGraphicRotatingInteractor // // description An interactor that rotates canvas graphics in the target // selection. Graphics are rotated around the center of // rotation. // //================================================================================ class TCanvasGraphicRotatingInteractor : public TCanvasDragInteractor { public: TCanvasGraphicRotatingInteractor ( MCanvasSelection* adoptTarget, MToolHandler*, const TGPoint& centerOfRotate ); virtual ~TCanvasGraphicRotatingInteractor (); //======================================== // Metadata //======================================== VersionDeclarationsMacro (TCanvasGraphicRotatingInteractor); //======================================== // TCanvasInteractor Overrides //======================================== virtual void StartInteraction (); virtual void ContinueInteraction (); virtual void EndInteraction (); #ifndef NO_Internal private: void* fExtension; TGPoint fCenter; TGrafMatrix fTransform; TGPoint fLastVector; TDeleterFor fBinding; TRotateCanvasGraphicCmd* fCommand; MCanvasSelection* fSelection; #endif }; //================================================================================ // class TCanvasGraphicTranslatingInteractor // // description An interactor that moves canvas graphics in the target selection. // //================================================================================ class TCanvasGraphicTranslatingInteractor : public TCanvasDragInteractor { public: TCanvasGraphicTranslatingInteractor ( MCanvasSelection* adoptTarget, MToolHandler* ); virtual ~TCanvasGraphicTranslatingInteractor (); //======================================== // Metadata //======================================== VersionDeclarationsMacro (TCanvasGraphicTranslatingInteractor); //======================================== // TCanvasInteractor Overrides //======================================== virtual void StartInteraction (); virtual void ContinueInteraction (); virtual void EndInteraction (); #ifndef NO_Internal private: void* fExtension; TGPoint fPreviousPoint; TDeleterFor fBinding; TTranslateCanvasGraphicCmd* fCommand; MCanvasSelection* fSelection; #endif }; // ******************************************************************************** // class TSRTFeedbacker // // description An SRT feedbacker is a canvas graphic that depicts "hot" areas // for launching scale, rotate and translate operations on the // graphics in a canvas selection. // // An SRT feedbacker provides helper methods for creating the // scaling, rotating and translating interactors. Subclasses // determine the feedbacker visual appearance and determine which // areas result in producing which interactors. It is generally a // good idea to make these areas visually obvious in the appearance. // // ******************************************************************************** class TCanvasInteractor; class MCanvasSelection; class MToolHandler; class TSRTFeedbacker : public MCanvasGraphic { public: TSRTFeedbacker (); TSRTFeedbacker (const MCanvasGraphic& forThis); TSRTFeedbacker (const TSRTFeedbacker&); virtual ~TSRTFeedbacker(); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TSRTFeedbacker); DynamicCastDeclarationsMacro (); // NOTE: MCanvasGraphic subclasses need not implement IsEqual // or Hash since MCanvasGraphic provides implementations based // based on TCanvasGraphicIDs. TSRTFeedbacker& operator= (const TSRTFeedbacker& source); virtual TStream& operator>>= (TStream& toWhere) const; virtual TStream& operator<<= (TStream& fromWhere); //======================================== // MCanvasGraphic overrides //======================================== virtual TGRect HandleGetBounds () const; virtual bool HandleHit (const TGPoint&) const; virtual void HandleDraw (TGrafPort& port) const; // Note: Your TSRTFeedbacker subclasses should also override the following method // virtual TCanvasInteractor* HandleCreateInteractor (MCanvasSelection* adoptTarget, MToolHandler*, const TGPoint&) const; //======================================== //TSRTFeedbacker Helper Methods //======================================== // NOTE: Center points are in untransformed coordinates of feedbacker. virtual TCanvasInteractor* CreateScalingInteractor (MCanvasSelection* adoptTarget, MToolHandler*, const TGPoint& center) const; virtual TCanvasInteractor* CreateRotatingInteractor (MCanvasSelection* adoptTarget, MToolHandler*, const TGPoint& center) const; virtual TCanvasInteractor* CreateTranslatingInteractor (MCanvasSelection* adoptTarget, MToolHandler*) const; // The following methods adjust fBounds allowing you to reuse the same feedbacker for different graphics virtual void SetGraphic (const MCanvasGraphic* forThis); virtual void HandleSetBounds (const TGRect& size); #ifndef NO_Internal private: void* fExtension; TGRect fBounds; enum Version { kOriginalVersion }; #endif }; class TSRTBoxFeedbacker : public TSRTFeedbacker { public: TSRTBoxFeedbacker (); TSRTBoxFeedbacker (const MCanvasGraphic& forThis); TSRTBoxFeedbacker (const TSRTBoxFeedbacker&); virtual ~TSRTBoxFeedbacker(); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TSRTBoxFeedbacker); DynamicCastDeclarationsMacro (); // NOTE: MCanvasGraphic subclasses need not implement IsEqual // or Hash since MCanvasGraphic provides implementations based // based on TCanvasGraphicIDs. TSRTBoxFeedbacker& operator= (const TSRTBoxFeedbacker& source); virtual TStream& operator>>= (TStream& toWhere) const; virtual TStream& operator<<= (TStream& fromWhere); //======================================== // MCanvasGraphic/TSRTFeedbacker overrides //======================================== virtual void HandleDraw (TGrafPort& port) const; virtual TCanvasInteractor* HandleCreateInteractor (MCanvasSelection* adoptTarget, MToolHandler*, const TGPoint&) const; #ifndef NO_Internal private: void* fExtension; enum Version { kOriginalVersion }; #endif }; class TSRTHandleFeedbacker : public TSRTFeedbacker { // // Note: we need to consider some mechanism for determining what interaction is desired // when a user clicks on a handle corner. It could be a scale or a rotate. This could // conceivably be an option upon creating the feedbacker, or perhaps the interactor created // could be determined by the current state of the shift key. Unfortunately, I don't believe // we have that information (needs to originate from the event). // public: TSRTHandleFeedbacker (); TSRTHandleFeedbacker (const MCanvasGraphic& forThis); TSRTHandleFeedbacker (const TSRTHandleFeedbacker&); virtual ~TSRTHandleFeedbacker(); //======================================== // MCollectible Overrides //======================================== MCollectibleDeclarationsMacro (TSRTHandleFeedbacker); DynamicCastDeclarationsMacro (); // NOTE: MCanvasGraphic subclasses need not implement IsEqual // or Hash since MCanvasGraphic provides implementations based // based on TCanvasGraphicIDs. TSRTHandleFeedbacker& operator= (const TSRTHandleFeedbacker& source); virtual TStream& operator>>= (TStream& toWhere) const; virtual TStream& operator<<= (TStream& fromWhere); //======================================== // MCanvasGraphic/TSRTFeedbacker overrides //======================================== virtual void HandleDraw (TGrafPort& port) const; virtual TCanvasInteractor* HandleCreateInteractor (MCanvasSelection* adoptTarget, MToolHandler*, const TGPoint&) const; virtual void SetGraphic (const MCanvasGraphic* forThis); #ifndef NO_Internal private: void* fExtension; enum Version { kOriginalVersion }; #endif }; #endif // Taligent_CANVASGRAPHICMANIPULATION