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.
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:
The embedded part is stored in your part's draft, but not within your part itself.
You store a reference to the frame somewhere in your part's content. The frame object itself is stored in your part's draft, but not in your 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.
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.
Calling ContentUpdated notifies your containing parts (and their containing parts, and so on) that your content has changed. The notification is necessary to enable all containing parts to update any link sources that they maintain.
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.