A subclass of dialog
intended for use with
rich-edit
controls. Currently the only functional differences between a dialog
and a rich-edit-dialog are:
(1) Creating a rich-edit-dialog form will automatically place the usual set of rich-edit controls and menu-bar onto the form;
(2) Making a close gesture on a rich-edit-dialog will prompt the end user to save any unsaved files in any rich-edit controls on the dialog, and avoid closing if not the user does not confirm the close.
To create a rich-edit-dialog interactively, invoke the
File | New Form menu-bar command and select
rich-edit-dialog from the list of choices. This will make a
rich-edit-dialog form and will automatically add a rich-edit control
and an associated rich-edit-ruler
just above it to
the form, and also add auxiliary widgets in a toolbar for use with
the rich-edit control.
{bmc zrtf-dia.bmp}
This dialog will act as a complete WordPad(tm)-like application. If
you would like to add additional controls to the form or toolbar, you
can do so. (You may need to first delete the initial rich-edit control
and rich-edit-ruler
if it is not
possible to get a hold of their sizing handles, since they fill the
entire form.) The rich-edit controls appear at the right end of the
component toolbar. Note that if multiple rich-edit controls are added
to a single form, the single set of rich-edit helper controls works
for all of the rich-edit controls on the same parent window,
reflecting the rich-edit that most recently had the keyboard focus.
Try running the initial rich-edit form (with that form selected, click on Run | Run Form), then clicking the Open button in the toolbar and selecting the file cg\rich-edit-sample.rtf (in the cg subdirectory of the main Allegro directory). This should show some sample rich text.
Building Rich Edit Forms from Scratch
To test making your own rich edit dialog from scratch, invoke the File | New Form command, and select dialog from the list of window classes that you can create. Double click the interior of the new form to inspect it.
If you would like to start the menu-bar off with the special rich-edit commands, then go to the menu property of the form in the inspector and enter #.(rich-edit-menubar) in the inspector line for the menu property. (The #. reader macro is a trick to evaluate the expression typed directly into a line of the inspector.) This should add the standard rich-edit menu-bar to the form, and you can further edit this menu as you like.
Back on the inspector, toggle the toolbar property on to give the form
a toolbar. Also toggle the status-bar property to give the
form a status-bar for messages. Next, click on the Rich-Edit button of
the Component Toolbar (the one with a big green "R"), and then click
in the main interior of your form to create a rich-edit control. You
may want to size the rich-edit control larger, since the default size
is rather small. Now click on each of the next three rich-edit
"helper" controls on the Component Toolbar and instantiate those
widgets from left to right on the toolbar of your new form. (The
helper controls consist of the rich-edit-multipic
, the font-face-combo-box
,
and the font-size-combo-box
. Finally, click
on the Ruler button on the Component Toolbar, position it just above
the rich-edit control, and then drag it or stretch it partly over the
rich-edit as needed to make it snap into place along the top.
Having done this, you now have a dialog that is functionally similar to the one created by using the rich-edit-dialog class. You can customize either however you like by adding additional controls and editing the initial rich-edit menubar. Note that only a rich-edit-dialog has the built-in feature of prompting the user to save any unsaved rich-edit controls when a closing gesture is made.
Special Features
While the rich edit functionality basically allows for custom WordPad--like applications, there are a couple of features that are somewhat unique:
Multiple editor panes. The rich-edit helper controls will automatically keep track of which rich-edit control most recently had the keyboard focus, and apply any editing commands to that rich-edit. Also, as the focus moves from one rich-edit to another, the rich edit helper controls will update themselves to reflect the current rich-edit, just as they update to reflect the currently selected text within a single rich-edit.
Copying formating. The Edit menu (on the rich-edit-dialog) has a couple of items called Copy Format and Paste Format that allow you to easily copy character formating rather than text. Just select some text (or position the text cursor), invoke Edit | Copy Format, then select some other text, and invoke Edit | Paste Format (again, these commands are on the Edit menu on the rich-edit-dialog, not on the Allegro CL Edit menu) The second text range will now have the character formating of the first text range.
See About Rich Text Editing in Common Graphics in cgide.htm.
Common Graphics and IDE documentation is described in About Common Graphics and IDE documentation in cgide.htm.
The documentation is described in introduction.htm and the index is in index.htm.
Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.
Created 2000.10.5.