Supporting embedding

To support embedding, the major components of your program should derive from the Presentation framework classes that provide the protocol for embedding:

If you derive your model, view, and selection from these classes, the Presentation framework provides the following automatic support:

In this step, the classes representing the major components of the Tiles program--model, view, and selection--are modified to derive from the three embedder classes described above. With the exception of TTilesSelection, this change doesn't require any additional or changed functions (the GUI embedder classes derive from the same classes that the Tiles classes were originally derived from).

This figure shows the new class hierarchy for the Tiles program:


TTilesSelection needs to override the three functions that support data exchange for a TTilesModel:

    The Presentation framework calls this function to copy selected data to the clipboard when a user chooses the Copy feature, as shown in this figure:



    The Presentation framework calls this function to copy selected data to the clipboard when a user chooses the Cut feature, as shown in this figure:


    The Presentation framework also calls MoveDataIntoModelSubclass just before doing a Paste function over selected data, saving the data so the Paste operation can be undone.
    The Presentation framework calls this function to move data from the clipboard into the selected range of a model when a user chooses the Paste feature, as shown in this figure:


NOTE MoveDataIntoModelSubclass and MoveDataOutofModelSubclass must be inverse operations to support undo and redo. Because the selection is responsible for moving selected data in or out during a Paste or Cut operation, you need to make sure the selection is updated to indicate the position where the inverse operation (Undo) should be performed.

You need to implement these functions only to support data exchange between your model and selection classes. The Presentation framework calls these functions as appropriate during cut, copy, and paste operations within a document component based on your model. Data is cut or copied into an embedded model of the same type on the clipboard. When the data is pasted into another model of the same type, the data in the embedded clipboard is added to the source model's data.

When a user tries to cut, copy, and paste data between document components based on different models, data is still cut or copied into an embedded model on the clipboard. However, the Presentation framework creates a new embedded model in the source document, and then pastes the data from the embedded model on the clipboard into that model instead of adding the data to the source model's data.

This table describes the behavior provided by the Presentation framework during cut, copy, and paste operations between a Tiles document and a Scribbler document. All newly created embedded models, whether on the clipboard or within a document, are created by the Presentation framework.


User Action Source Model Destination Model Function called by Framework

Copy in the Tiles window
TTilesModel in the Tiles document
A newly created TTilesModel embedded in the Clipboard document
CopyDataIntoModelSubclass

Cut in the Tiles window
TTilesModel in the Tiles document
A newly created TTilesModel embedded in the Clipboard document
MoveDataIntoModelSubclass

Paste in the Tiles window
Previously cut/copied TTilesModel embedded in the Clipboard document
TTilesModel in the Tiles document
MoveDataOutofModelSubclass

Undo after Cut in the Tiles window
Previously cut/copied TTilesModel embedded in the Clipboard document
TTilesModel in the Tiles document
MoveDataOutofModelSubclass

Undo after Paste in the Tiles window
TTilesModel in the Tiles document
A newly created TTilesModel embedded in the Clipboard
MoveDataIntoModelSubclass

Paste in a Scribbler window after a cut/copy in the Tiles window
Previously cut/copied TTilesModel embedded in the Clipboard document
A newly created TTilesModel embedded in the Scribbler document
MoveDataOutofModelSubclass

Paste in the Tiles window after a cut/copy in Scribbler window
Previously cut/copied Scribbler model embedded in the Clipboard document
A newly created Scribbler model embedded in the Tiles document
MoveDataOutofModelSubclass


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker