Creating an editable text document component

The framework provides a set of concrete classes, derived from abstract Text Editing framework classes and from Desktop framework classes, designed specifically to implement an editable text document component:

This figure shows how these classes work together to form editable text document components, along with the associated interactors:


You can customize the behavior of an editable text document component, or extend the functionality, by deriving from these classes. To help you determine what classes you need to extend to provide a particular kind of functionality, the following information describes how instances of these classes work together.

Creating and opening a document

To create an editable text document component, you need to launch a document with an instance of TTextModel (or TEmbedderTextModel) and an instance of TTextPresenterState, either directly or by using the RunDocument utility with the convenience class TTextStationery, as described in "Getting started: Creating a text document component" on page 86. You can also create text documents within the Workspace--for example, by double-clicking a text stationery icon. The Workspace will provide the primary interface for users to create documents in future releases.

To create the presentation on the document, the framework calls TTextPresenterState::HandleCreatePresenter. This function creates an instance of TTextPresenter, which is responsible for creating the objects specific to a presentation on an editable text document component:

The presenter also creates the TGUIBundle that the document uses to manage all its associated objects and the initial selection on the document. To create the initial selection, the presenter calls TTextModel::CreateSelection, which returns a TDocumentTextSelection.

Some of the necessary interactors are also created when an editable text document component is opened. The view is responsible for creating the interactors and handling the input events. The editable text document component uses three different interactors to handle input:

Creating selections

The view for an editable text component uses a
TSelectTextInteractor to handle selecting text in the document. The view creates a new selection interactor whenever it receives a mouse-down event; the Input system adopts the interactor and assumes ownership for it.

The selection interactor receives mouse events and uses their positions to compute a new selection area, using the TTextView function CoordinateToInsertionOffset to convert the mouse event positions into offsets within the encapsulated text. If the user simply clicks the mouse, the interactor creates an insertion point selection; if the user clicks and drags the mouse, the interactor creates a selected range.

The interactor computes the area of the final selection, using the simple class TTextArea to encapsulate the selected range, and passes it back to the view by calling TTextView::SetCurrentSelection. The view uses this area to reset the current selection and draw selection feedback.

TSelectTextInteractor can also handle these interactions:

Handling typing input

The view uses a
TDocumentTypingInteractor to handle typing input for the document. The view instantiates a typing interactor whenever it is activated, and maintains that interactor until the view is deactivated.

When the typing interactor is started, it:

  1. Gets the typing styles for the current insertion point from the text representation object.
  2. Uses the language style to determine what typing configuration to use.
  3. Processes the typing input incrementally, modifying the text representation object as the user enters text. The text representation notifies the view of changes and the view draws the updated text.
  4. The interactor stops when the view receives a mouse event or when the view is deactivated.
NOTE The typing and selection interactors are described in more detail in "Text Editing framework interactors" on page 127.


[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