PresFrmwkText

PresFrmwkText illustrates how to use TTextModel and TTextPresenterState with the Compound Document and Presentation frameworks to provide more features than are available with simple text. It subclasses TDocumentComponentStationery to provide a stationery class that uses TTextModel and a custom subclass of TTextPresenterState. A script that invokes RunDocument is provided as well.

You might want to review the Compound Document and Presentation frameworks documentaiton, and information on RunDocument, in order to better understand this sample.

Running the sample

Execute PresFrmwkTextSApp. A window and menu appears. The text area within the window is different from the default in the SimpleTextAndMenus sample. Note also that there are the standard Presentation framework menus that support multiple undo and redo editing operations.

Files and classes

TSampleTextPresenter, in SampleTextPresentation.h and SampleTextPresentation.C, derives from TTextPresenter and overrides HandleCreateContentClippingView to return NIL. This way, when the window is resized, it resizes the text view, causing the text to rewrap to the new width. Otherwise, the view would appear in a standard clipping view, and be clipped instead of resized.

TSampleTextPresenterState, in SampleTextPresentation.h and SampleTextPresentation.C, derives from TTextPresenterState and overrides HandleCreatepresenter to instantiate a TSampleTextPresenter. It also sets some defaults for the presentation size and colors.

TSampleTextStationery, in SampleTextPresentation.h and SampleTextPresentation.C, derives from TDocumentComponentStationery, and overrides CreateModel and CreateModelPresenterState to instantiate a TTextModel and TSampleTextPresenterState.

PresFrmwkTextSApp is a script which invokes RunDocument to launch a document using the TSampleTextStationery.

Notes:

If you want to support embedding of other components in the text, implement TDocumentComponentStationery::CreateModel to instantiate TEmbedderTextModel (see EmbedderText.h) instead of a simple TTextModel.

This example provides additional classes beyond TSampleTextStationery only to illustrate how to customize the presentation. A simple text application would require only TSampleTextStationery.


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