// $Revision: 1.2 $ // Copyright (C) 1994, 1995 Taligent, Inc. All rights reserved. // TilesSelections.h #ifndef TaligentSample_TILESSELECTIONS #define TaligentSample_TILESSELECTIONS // Include for embedder classes #ifndef Taligent_GUICOMPOUNDDOCUMENTEMBEDDER #include #endif #ifndef TaligentSample_TILESMODEL #include "TilesModel.h" #endif // TTilesSelection is the selection return by TTilesModel::CreateSelection(). // The TTilesSelection can be on an individual TTile, on the whole model or // on none of the model. TTilesSelection inherits from the template class // TGUIEmbedderModelSelectionFor in order to support cut/copy/paste, // embedding and embeddability. Three TGUIEmbedderModelSelectionFor methods must // be overridden to provide this support: CopyDataIntoModelSubclass, MoveDataOutofModelSubclass // and MoveDataIntoModelSubclass class TTilesSelection : public TGUIEmbedderModelSelectionFor { public: // The following macro must be called within class declarations in order to use Taligent // Type Extensions.The macro defines a set of Taligent Type Extension utility functions. // This macro call matches a macro call to TaligentTypeExtensionMacro in TilesSelections.C TaligentTypeExtensionDeclarationsMacro (TTilesSelection) // The following macro must be called when dynamic type casting is required. // The macro defines a set of dynamic casting utility functions. // This macro call matches a macro call to DynamicCastDefinitionsMacro in TilesSelections.C DynamicCastDeclarationsMacro (); // The constructor takes a TModelReference& which it uses to // initialize its TGUIModelSelectionFor base class. TTilesSelection (const TModelReference& theModel); virtual ~TTilesSelection (); // Taligent Type Extensions require copy constructors defined as well // as assignment and streaming operators. TTilesSelection (const TTilesSelection& copy); virtual TStream& operator>>= ( TStream& towhere ) const; virtual TStream& operator<<= ( TStream& fromwhere ); // Provides access to the TTiles to which the selection refers to TileIndex GetLowBound () const; TileIndex GetHighBound () const; TTile* GetTile (); // TGUIModelSelectionFor overrides. Support for selection of // the whole model, none of the model or an undefined selection. virtual void DeselectAll (); virtual void SelectWholeModel (); virtual void SetUndefined (); // Support for selection of one TTile. void SelectTile (TileIndex); // Return true if the selection contains a specific TileIndex. This is used // by the view to provide current selection feedback by drawing a frame around // each tile in the selection. bool ContainsTile (TileIndex) const; // The next three functions are TGUIEmbedderModelSelectionFor overrides. // Copy the source model data specified by this selection into the destination model // specified in the passed parameter. The destination model is assumed to be empty. // Called by the Presentation Framework to copy the selection to the clipboard when // the user chooses Copy. virtual void CopyDataIntoModelSubclass (TTilesModel& theDestModel ) const; // Move (copy and delete) the source model data specified by this selection into the // destination model specified in the passed parameter. The destination model is assumed // to be empty. Called by the Presentation Framework to copy the selection to the clipboard // when the user chooses Cut or before a paste over the selection occurs to support undo // after a paste. This function should set this selection to the new insertion point after // the move and should be the inverse of MoveDataOutofModelSubclass so that undo/redo will work. virtual void MoveDataIntoModelSubclass (TTilesModel& theDestModel ); // Copy the data from the source model specified by the parameter over the data in the // destination model selected by this selection. The data in the source model should completely // replace whatever data is specified by this selection at the start. Called by the Presentation // during a paste operation. After the move, this function should set this selection to the // new data moved in (the selection range may increase or decrease after the move) and should // be the inverse of MoveDataIntoModelSubclass so that undo/redo will work. virtual void MoveDataOutofModelSubclass (TTilesModel& theSrcModel ); // The selection provides support for modifying the color of // the selected TTiles. SetColorAll modifies all the TTiles // in the selection whether it is one Tile or the whole model. void SetColor (TileIndex, const TRGBColor&); void SetColorAll (const TRGBColor&); TRGBColor GetColor (TileIndex whichTile) const; // Used by TMoveCommand to change and get the position of a TTile. Assumes // that only one TTile is selected. void SetPosition (const TGPoint&); TGPoint GetPosition (); protected: // TaligentTypeExtension also requires a true default (void) constructor. But I // don't want it called by clients so I make it protected. TTilesSelection (); private: // Used for versioning during streaming. enum {kOriginalVersion}; // The TilesSelection can't actually contain a pointer to a TTile because // then it could not be flattened. Instead fLowBound and fHighBound, used in // conjunction with the inherited TModelReference will specify the TTile(s) // to which this selection refers. All selections should contain an // address space independent specification on the model. TileIndex fLowBound; TileIndex fHighBound; // Place operator= in private section to prevent it from being called. TTilesSelection& operator= (const TTilesSelection& copy) {return *this;} }; #endif // TaligentSample_TILESSELECTIONS