// $Revision: 1.22 $ // $Revision: 1.22 $ // Copyright (C) 1994-1995 Taligent, Inc. All rights reserved. #ifndef Taligent_GUICOMPOUNDDOCUMENTEMBEDDER #define Taligent_GUICOMPOUNDDOCUMENTEMBEDDER # ifndef Taligent_TEXTCLASSES # include # endif # ifndef Taligent_COLLECTIONS # include # endif # ifndef Taligent_COMPOUNDDOCUMENT # include # endif # ifndef Taligent_COMPOUNDDOCUMENTCOMMAND # include # endif # ifndef Taligent_AREAGEOMETRY # include # endif # ifndef Taligent_PRIMITIVECLASSES # include # endif # ifndef Taligent_TOKENS # include # endif # ifndef Taligent_GUICOMPOUNDDOCUMENT # include # endif class TGPoint; class TGRect; class MCollectible; class MGraphic; class TModelAnchor; class TModel; class TCompoundDocument; class TModelSelection; class TStream; class TStandardText; class TText; class TToken; class TTypeDescription; //////////////////////////////////////////////////////////////////////// // // The TGUIEmbedderModel family of classes support a Standard model // that embeddeds components, managing a 2D layout for the components // // The classes in the TModel family that are provided by the GUI Compound // Document Framework subsystem are: // TComponentArea : The model maintains an ordered list of // these. They wrap an embedded component // providing layout data. // TGUIEmbedderModel : The standard embedder model is an ordered list // of document components with layout info. // //////////////////////////////////////////////////////////////////////// class TComponentArea { public: TComponentArea(); TComponentArea( TDocumentComponent* componentToAdopt); TComponentArea( TDocumentComponent* componentToAdopt, const TGArea& theArea ); TComponentArea( const TComponentArea& ); ~TComponentArea(); TGArea GetArea() const; void SetArea( const TGArea& theArea ); TDocumentComponent* GetComponent(); const TDocumentComponent* GetComponent() const; TDocumentComponent* OrphanComponent(); HashResult Hash() const; TComponentArea& operator=( const TComponentArea& ); bool operator==( const TComponentArea& ) const; bool operator!=( const TComponentArea& ) const; TStream& operator>>= ( TStream& towhere ) const; TStream& operator<<= ( TStream& fromwhere ); VersionDeclarationsMacro(TComponentArea); private: TGArea fArea; TDocumentComponent* fComponent; enum Version { kOriginalVersion }; }; class TGUIEmbedderModel : public TModel { public: TGUIEmbedderModel(); TGUIEmbedderModel( const TGUIEmbedderModel&); virtual ~TGUIEmbedderModel(); // TModel overrides virtual TModelSelection* CreateSelection() const; // Data Access virtual void DeleteAll(); virtual void Adopt(TComponentArea*); virtual TComponentArea* Orphan(TComponentArea&); virtual TComponentArea* LookupComponent( const TDocumentComponentReference& ); virtual const TComponentArea* LookupComponent( const TDocumentComponentReference& ) const; virtual TIteratorOver* CreateComponentIterator() const; virtual void SetComponentArea( const TDocumentComponentReference&, const TGArea& ); // Notifications TModelInterest GetAddedComponentInterest() const; TModelInterest GetRemovedComponentInterest() const; TModelInterest GetComponentAreaChangedInterest() const; TGUIEmbedderModel& operator=(const TGUIEmbedderModel&); virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); ModelDeclarationsMacro(TGUIEmbedderModel); #ifndef NO_Internal private: TDequeOf fComponents; enum Version { kOriginalVersion }; #endif }; /////////////////////////////////////////////////////////////////////// // // The TSelection family provides an interface and implementation of // selections for the GUI Compound Document Framework. // // The classes in the TModelSelection family that are provided by the // GUI Compound Document Framework subsystem are: // MEmbeddedComponentAccessor : This selection mixin is used // by the TComponentAreaRectControlState // to automatically handle selection // feedback and to issue commands // to update the model's position. // TGUIEmbedderModelSelection : The base selection class for // selections on TGUIEmbedderModel // subclasses. // TGUIEmbedderModelSelectionFor: The class template that generates // template selection classes to be // used as a base class for selections // on TGUIEmbedderModel subclasses. ///////////////////////////////////////////////////////////////////////// class MEmbeddedComponentAccessor { public: virtual ~MEmbeddedComponentAccessor(); virtual long GetSelectedComponentCount() const = 0; virtual bool IsSelected( const TDocumentComponentReference& ) const=0; virtual void AddInterests(TSetOf &set); virtual void GetSelectedComponents( TCollectionOf& ) const = 0; virtual void GetComponentArea( const TDocumentComponentReference&, TGArea& ) const = 0; virtual void SetComponentArea( const TDocumentComponentReference&, const TGArea& ) = 0; MEmbeddedComponentAccessor& operator=(const MEmbeddedComponentAccessor&); virtual TStream& operator>>= (TStream&) const; virtual TStream& operator<<= (TStream&); VersionDeclarationsMacro(MEmbeddedComponentAccessor); DynamicCastDeclarationsMacro(); protected: MEmbeddedComponentAccessor(); MEmbeddedComponentAccessor( const MEmbeddedComponentAccessor&); #ifndef NO_Internal private: enum Version { kOriginalVersion }; #endif }; class TGUIEmbedderModelSelection : public TModelSelection, public MDataExchanger, public MEmbeddedComponentAccessor { public: TGUIEmbedderModelSelection( const TModelReference& theModelRef); TGUIEmbedderModelSelection( const TGUIEmbedderModel& theModel); TGUIEmbedderModelSelection( const TGUIEmbedderModelSelection&); virtual ~TGUIEmbedderModelSelection(); // Component selection virtual void SelectComponent( const TDocumentComponentReference&); virtual void DeselectComponent( const TDocumentComponentReference&); virtual void DeselectAllComponents(); // MEmbeddedComponentAccessor Overrides virtual long GetSelectedComponentCount() const; virtual bool IsSelected( const TDocumentComponentReference& ) const; virtual void GetSelectedComponents( TCollectionOf& ) const; virtual void GetComponentArea( const TDocumentComponentReference&, TGArea& ) const; virtual void SetComponentArea( const TDocumentComponentReference&, const TGArea& ); virtual void AddInterests(TSetOf &set); // TModelSelection Overrides bool IsEmpty() const; virtual void DeselectAll(); virtual void SelectWholeModel(); // MDataExchanger Overrides virtual void CreateAvailableTypesList( TSequenceOf& theTypes) const; virtual void ChooseTypes(const TSequenceOf& theChoices, TSequenceOf& theChosenTypes) const; const TGUIEmbedderModel* GetModelForReading() const; TGUIEmbedderModel* GetModelForWriting() const; // Standard operators and MCollectible Overrides TGUIEmbedderModelSelection& operator=( const TGUIEmbedderModelSelection& ); #ifndef NO_Internal virtual bool IsEqual( const MCollectible* ) const; #endif virtual TStream& operator>>=( TStream& towhere ) const; virtual TStream& operator<<=( TStream& fromwhere ); TaligentTypeExtensionDeclarationsMacro(TGUIEmbedderModelSelection) protected: TGUIEmbedderModelSelection(); // MDataExchanger overrides virtual TModel* HandleCopyData(const TTypeDescription&) const; virtual void HandleCopyDataInto(TModel&) const; virtual TModel* HandleReplaceData(TModel* theData); virtual TModel* HandleOrphanData(); virtual TIteratorOver* CreateSelectedComponentIterator() const; // These provide implementations for moving data into // and out of embedder models and GUI embedder models virtual void CopyDataIntoEmbedderModel( TEmbedderModel&) const; virtual void CopyDataIntoGUIEmbedderModel( TGUIEmbedderModel&) const; virtual void MoveDataIntoGUIEmbedderModel( TGUIEmbedderModel&); virtual void MoveDataOutofEmbedderModel( TEmbedderModel&); virtual void MoveDataOutofGUIEmbedderModel( TGUIEmbedderModel&); virtual TModel* HandleCreateModel( const TTypeDescription&) const; #ifndef NO_Internal private: TSetOf fComponents; enum Version { kOriginalVersion }; #endif }; // The AModel class must be a concrete class with an empty constructor. // i.e. the AModel() constructor will be called by the HandleCreateModel() // member function. template class TGUIEmbedderModelSelectionFor : public TGUIEmbedderModelSelection { public: TGUIEmbedderModelSelectionFor(); TGUIEmbedderModelSelectionFor( const TModelReference& ); TGUIEmbedderModelSelectionFor( const AModel& theModel); TGUIEmbedderModelSelectionFor( const TGUIEmbedderModelSelectionFor& ); ~TGUIEmbedderModelSelectionFor(); const AModel* GetModelForReading() const; AModel* GetModelForWriting() const; virtual void CreateAvailableTypesList( TSequenceOf& theTypes) const; virtual void ChooseTypes(const TSequenceOf& theChoices, TSequenceOf& theChosenTypes) const; TemplateVersionDeclarationsMacro(TGUIEmbedderModelSelectionFor,AModel,0); TemplateDynamicCastDeclarationsMacro(); protected: virtual TModel* HandleCreateModel( const TTypeDescription&) const; virtual void HandleCopyDataInto( TModel&) const; virtual TModel* HandleReplaceData(TModel* theData); virtual TModel* HandleOrphanData(); // Override these !! virtual void CopyDataIntoModelSubclass( AModel& theDestModel ) const = 0; virtual void MoveDataOutofModelSubclass( AModel& theDestModel ) = 0; virtual void MoveDataIntoModelSubclass( AModel& theDestModel ) = 0; #ifndef NO_Internal private: enum Version { kOriginalVersion }; #endif }; //////////////////////////////////////////////////////////////////////////// // // The additional classes in the TNotification family that are provided by // the TGUIEmbedderModel to receive component specific notification // TDocumentComponentNotification : // //////////////////////////////////////////////////////////////////////////// class TDocumentComponentNotification : public TNotification { public: TDocumentComponentNotification( const TModelInterest& theInterest, const TDocumentComponentReference&); TDocumentComponentNotification( const TDocumentComponentNotification&); virtual ~TDocumentComponentNotification(); TDocumentComponentNotification& operator=(const TDocumentComponentNotification&); TDocumentComponentReference GetComponentReference() const; virtual long Hash() const; #ifndef NO_Internal virtual bool IsEqual(const MCollectible*) const; #endif virtual TStream& operator>>=(TStream& towhere) const; virtual TStream& operator<<=(TStream& towhere); MCollectibleDeclarationsMacro(TDocumentComponentNotification); protected: TDocumentComponentNotification(); #ifndef NO_Internal private: TDocumentComponentReference fComponent; enum Version { kOriginalVersion }; #endif }; /////////////////////////////////////////////////////////////////////// // // The TView family of classes support presenting the model and presenter // state information in a TView. // // The classes in the TView family that are provided by this header in the // GUI Compound Document subsystem are: // TComponentAreaFrameView : A simple view for use with embedded // document components. It gets the component // from the TComponentArea and uses the // area to size and position the view. // TGUIEmbedderModelView : A simple content view that can be // used to build a view on TGUIEmbedderModels. // It connects for notification on all // the notifications generated by the // TGUIEmbedderModel. For Add/Remove // Component Notifications, it will // automatically add/remove // TComponentAreaFrameViews on the // embedded components. // /////////////////////////////////////////////////////////////////////// class TComponentAreaFrameView : public TFrameView { public: TComponentAreaFrameView( const TComponentArea&, const TGUIBundle& theParentBundle); TComponentAreaFrameView( const TComponentArea&, const TGUIBundle& theParentBundle, TRectControlState* theControlStateToAdopt); TComponentAreaFrameView(); TComponentAreaFrameView( const TComponentAreaFrameView&); virtual ~TComponentAreaFrameView(); MCollectibleDeclarationsMacro(TComponentAreaFrameView); protected: #ifndef NO_Internal private: enum { kOriginalVersion }; #endif }; class TGUIEmbedderModelView : public TDocumentComponentView, public MMouseEventHandler { public: TGUIEmbedderModelView( TGUIBundle* theBundleToAlias ); virtual ~TGUIEmbedderModelView(); void CreateComponentAreaView( const TComponentArea& theComp); void DeleteComponentAreaView( const TDocumentComponentReference&); void UpdateComponentAreaView( const TComponentArea& theComp); virtual TStream& operator>>= (TStream& toWhere) const; virtual TStream& operator<<= (TStream& fromWhere); MCollectibleDeclarationsMacro(TGUIEmbedderModelView); protected: TGUIEmbedderModelView(); TGUIEmbedderModelView( const TGUIEmbedderModelView& ); virtual void HandleAfterConnectionToViewRoot(); virtual void HandleBeforeDisconnectionFromViewRoot(); virtual void HandleActivate(); virtual void HandleDeactivate(); virtual void DrawContents( TGrafPort& port ) const; virtual void HandleAddedComponent(const TNotification&); virtual void HandleRemovedComponent( const TNotification&); virtual void HandleComponentAreaChanged( const TNotification&); virtual TIteratorOver >* CreateFrameIterator() const; virtual bool MouseDown(TMouseDownEvent&); virtual void HandleSelectionDragStart( const TGPoint& start); virtual void HandleSelectionDragChange( const TGRect& theOldDragBounds, const TGRect& theNewDragBounds ); virtual void HandleSelectionDragEnd( const TGRect& theDragBounds ); void SelectComponentsIntersecting( const TGRect& theRect, TGUIEmbedderModelSelection& ); // Derived classes override these to specialize handling of frame views. virtual TFrameView* HandleCreateComponentAreaView( const TComponentArea& theComp); virtual void HandleDeleteComponentAreaView( const TDocumentComponentReference&, TFrameView* theEmbeddedComponentView ); virtual void HandleUpdateComponentAreaView( const TComponentArea& theComp, TFrameView& theEmbeddedComponentView ); #ifndef NO_Internal private: friend class TGUIEmbedderModelSelectionInteractor; TGUIEmbedderModelView& operator=( const TGUIEmbedderModelView& ); TRequestBasedMemberFunctionConnectionTo fConnection; TDictionaryOf fEmbeddedViews; static const TRGBColor fgNormalColor; static const TRGBColor fgSelectedColor; static const TRGBColor fgActiveSelectedColor; enum Version { kOriginalVersion }; #endif }; /////////////////////////////////////////////////////////////////////// // // The TControlState family of classes support connecting the user interface // elements such as controls or frames back into the presenter or model. // // The classes in the TControlState family that are provided by the // GUI Compound Document subsystem are: // // TComponentAreaRectControlState : A simple rect control state that // works with component areas and the // MEmbeddedComponentAccessor. When a // component area frame is resized/moved // it selects the component and uses the // MEmbeddedComponentAccessor to move the // embedded component. // /////////////////////////////////////////////////////////////////////// class TComponentAreaRectControlStateImplementation; class TComponentAreaRectControlState : public TRectControlState { public: TComponentAreaRectControlState(); TComponentAreaRectControlState( const TDocumentComponentReference&, TGUIBundle* theBundleToAlias ); TComponentAreaRectControlState( const TComponentAreaRectControlState&); ~TComponentAreaRectControlState(); TGUIBundle* GetGUIBundle() const; void SetGUIBundle( TGUIBundle* theBundleToAlias ); TDocumentComponentReference GetDocumentComponentReference() const; void SetDocumentComponentReference( const TDocumentComponentReference& ); virtual bool IsSelected() const; virtual TGRect GetRect() const; virtual void IntermediateSetRect( const TGRect& ); virtual void FinalSetRect( const TGRect& ); virtual void Update(const TInterest&); virtual void AddInterests(TSetOf &set); // Standard operators and MCollectible overrides TComponentAreaRectControlState& operator =( const TComponentAreaRectControlState&); virtual TStream& operator >>=(TStream& ) const; virtual TStream& operator <<=(TStream& ); virtual long Hash() const; #ifndef NO_Internal virtual bool IsEqual(const MCollectible*) const; #endif MCollectibleDeclarationsMacro(TComponentAreaRectControlState); #ifndef NO_Internal private: TComponentAreaRectControlStateImplementation* fImp; enum Version { kOriginalVersion }; #endif }; #ifndef Taligent_GUICOMPOUNDDOCUMENTEMBEDDERIMP #include #endif #endif