Programming Guide


Changing Your Part's Content

Users can change the content of your part through a variety of standard editing actions involving keyboard input, menu commands, scripting, and so on. How you can support those tasks is described throughout this book, with additional information and other programming texts.

This section summarizes the content-changing tasks of adding and removing embedded parts, and it notes the ways in which you must keep OpenDoc and other parts informed when you make content changes of any kind.

Adding an Embedded Part

Embedding is a process that can combine elements of storage, layout, data transfer, menu handling, and control manipulation. This section summarizes the embedding process; the summary is presented in this chapter because embedding involves such a fundamental change to a part's storage configuration.

In terms of the stored persistent objects involved, embedding breaks down to these basic alternatives:

You create a new embedded frame by calling your draft's CreateFrame method; you embed a preexisting frame by calling your draft's AcquireFrame method. In situations where you must explicitly instantiate the part object to embed, you create a new part by calling your draft's CreatePart method, or you obtain an existing part by calling your draft's AcquirePart method.

Detailed procedures for embedding a part within your part are described in detail in "Pasting from the Clipboard", "Dropping", and "Using a Tool Palette to Embed Parts". See those sections for more information. In summary, however, you perform these tasks when you embed:

  1. You decide, based on your own part's content model and on information accompanying the transferred data, what area is to be given to the embedded part for display:

  2. For each of the embedded part's frames that are to show the embedded part, you create or retrieve a part object (if necessary), and then you create or retrieve an embedded frame object.

  3. If the embedded part's frame is presently visible, you create a new facet (or facets) to display the embedded part.

  4. As necessary or appropriate, you perform other tasks related to embedding, such as those described in "Working with Embedded Frames and Facets". Finally, you notify OpenDoc and your own containing part that you have changed your part's content.

Removing an Embedded Part

     

To remove an embedded part from your part, you must remove all the facets of the embedded part's display frame, release or remove the embedded part's frame, and redisplay your own part's content. Follow the instructions in "Removing an Embedded Frame".

This procedure illustrates the fact that your part is not actually concerned with removing embedded parts themselves. Under user instruction or for other reasons, your part may have reason to remove one or more embedded frames; once the last display frame of a given embedded part is removed from your part, that part is no longer embedded in your part.

Making Content Changes Known

Whenever you make any significant change to your part's content, whether it involves adding, deleting, moving, or otherwise modifying your intrinsic content or your embedded frames, you must make those changes known to OpenDoc and to all containing parts of your part.

You should call these methods as soon as is appropriate after making any content changes. You may not have to make the calls immediately after every single change; it may be more efficient to wait for a pause in user input, for example, or until the active frame changes. In addition to sending these notifications, you must of course also update your part's display if appropriate; this may involve adding or removing facets, adjusting intrinsic content, and invalidating areas that need to be redrawn.


[ Top | Previous | Next | Contents | Index | Documentation Homepage ]