Overview | Using RichViewActions

<< Click to display table of contents >>

Overview | Using RichViewActions

Overview

All actions have Control property of TCustomRVControl type. If this property is not assigned, actions work with the focused control (or GetControlPanel.DefaultControl component).

All actions have Disabled property (Boolean). If it is True, all actions are disabled. If it is False (default), actions update their Enabled property automatically.

TRVAControlPanel component has a set of properties affecting all (or many) actions.

TRVAPopupMenu is a popup menu for TCustomRichViewEdit that maintains items itself. Set its ActionList property to the action list containing RichViewActions. Assign this component to the editor’s PopupMenu. Do not add items in this menu manually – they all will be cleared (you can add them on each call of OnPopup, though). The menu supports live spelling, see below.

Preparing for the actions

Right-click RichViewEdit in Delphi/C++Builder/Lazarus, choose "Settings" in the context menu, select “Allow adding styles dynamically”, check options for saving and loading background and layout.

Include rvoCtrlJumps in RichViewEdit.EditorOptions.

How to use

Put an ActionList component on the form. Link it with some image list. Double click the ActionList. Click "New Standard Actions" on the component editor toolbar. Select the action and click OK. If the linked image-list is 16x16, an action image will be added automatically. However, we recommend to use high-quality images instead of default images.

Alternatively, you can use existing datamodules:

dmActions.pas contains an ActionList and an ImageList, with simple 16-color images;

dmActionImages1.pas contains ImageLists with high-quality toolbar images, set #1, both normal and disabled versions (for Delphi/C++Builder 2009 and newer);

dmActionImages2.pas the same, set #2;

dmactionimageslaz1.pas the same, set #1 (for Lazarus)

dmactionimageslaz2.pas the same, set #2 (for Lazarus)

For newer versions of Delphi and Lazarus, there are datamodules containing multi-resolution ImageLists:

dmActionsVirtualImageLists.pas contains a virtual ImageList (for Delphi/C++Builder 10.3+), the actual images are in dmActionsImageCollection1.pas (set #1) and dmActionsImageCollection2.pas (set #2)

dmactionsimagesmultireslaz1.pas the same, set #1 (for Lazarus 2+)

dmactionsimagesmultireslaz2.pas the same, set #2 (for Lazarus 2+)

If you will not modify these units, you can include them in your project directly. But it's highly recommended to create a copy of them (under new names) and use the copies instead. Important: if you access actions in OnCreate event of some form, this form must be created after the datamodule (the form creation order may be specified in the project options).

Localization

Several languages are available for translations of user interface. Some operations must be performed even if you use only one language. See Localization of RichViewActions.

Ruler

RichViewActions include TRuler component by Pieter Zijlstra and TRVRuler component inherited from it.

Create a TRVRuler component, place on the form above the editor, assign RVRuler.RichViewEdit to this editor.

In TRVAControlPanel.OnMarginsChanged call RVRuler.UpdateRulerMargins.

The ruler supports units: inches, centimeters, millimeters, picas, pixels and points.

If you want to remove support for tab stops, set ruler's MaxTabs property to 0.

Actions requiring a special attention

It's recommended to assign Control property for the following actions:

TrvActionStyleInspector;

TrvActionEditNote.

Otherwise, it will be assigned automatically when the action is executed for the first time.

Some additional code may be required to implement UI for a note editor of TrvActionEditNote.

Files

File-related actions (TrvActionNew, TrvActionOpen, TrvActionSave, TrvActionSaveAs) are linked together. The most of them cannot work without others. These actions keep track of all opened files and can be used even for multiple RichViewEdits (for example, in MDI application) without any additional effort from the programmer. These actions cannot be used for TDBRichViewEdit.

TrvActionExport, TrvActionInsertFile are independent – they are not linked with other actions, they just allow to export/insert a file.

Printing

TRVAControlPanel has RVPrint: TRVPrint property. All printing actions (TrvActionPrintPreview, TrvActionQuickPrint, TrvActionPrint) use it.

It is recommended to assign it to some TRVPrint component.

If this property is not assigned, these actions search TRVPrint component on the same form as the target editor. If it is not found, they create a temporal TRVPrint component.

Besides, these actions use another property of TRVAControlPanelShowSoftPageBreaks: Boolean. If True (default), soft page breaks are shown when possible (after print preview or printing – until the next change in the document).

TrvActionPageSetup is a special printing action. It does not require RichViewEdit, but requires RVPrint assigned to TRVAControlPanel.

Color

All the main coloring actions (TrvActionFontColor, TrvActionFontBackColor, TrvActionParaColor, TrvActionColor) can work in three modes, depending on UserInterface property:

rvacAdvanced (default) – on execution, a special non-modal color dialog pops up; it pops up at the position calculated by the coordinates of control that caused this action to execute (ActionComponent – button, for example) or by mouse coordinates;

rvacColorDialog – on execution, a color is chosen with standard color dialog;

rvacNone – no user interface, action just applies Color property.

This property gives you an ability to implement a color combo (you need two actions – one for applying the last chosen color (UserInterface = rvacNone) and one for displaying a color dialog). Or you can implement your own interface for choosing colors.

All coloring actions have OnShowColorPicker and OnHideColorPicker events helping to implement a custom color combo.

Formatting

TrvActionFontGrow and TrvActionFontShink change the size of selected font by the given number of percents (Percent property). If you change its value, do not forget to update hints for the actions.

TrvActionFontGrow, TrvActionFontGrowOnePoint have MaxSize property, TrvActionFontShrink TrvActionFontShrinkOnePoint have MinSize property.

TrvActionParagraph can work in two modes, depending on UserInterface: Boolean property:

True (default) – the action gets values of its properties from RichViewEdit, displays a dialog for modifying them, then apply them to the selection;

False – the action applies its properties to the selection, without displaying a dialog.

TrvActionFontEx is similar to TrvActionParagraph, it can also work in two modes.

Live spelling check

TRVAPopupMenu supports live spelling.

You have the following options:

assign a spelling checker interface component to TRVAControlPanel.SpellInterface property, and all commands (suggestions, "add to dictionary" and "ignore all", etc.) will be added in the menu automatically;

use the menu events: OnLiveSpellGetSuggestions, OnLiveSpellIgnoreAll, OnLiveSpellAdd; if your spellchecker can store a user choice to generate better suggestions in future, you can also process OnLiveSpellWordReplace.

RichViewActions do not process OnSpellingCheck event, you still need to do it yourself, see the commented code in Unit3.pas.

Bidirectional text

TrvActionParaLTR, TrvActionParaRTL – set default bidi mode for the selected paragraphs.

TrvActionTextLTR, TrvActionTextRTL – set bidi mode for the selected text.

Before using these actions set RichViewEdit.BiDiMode either to rvbdLeftToRight or rvbdRightToLeft (do not use for BiDiMode=rvbdUnspecified!)

Providing help files

RichViewActions do not include help files for users. However, if you create help files for RichViewActions dialogs, RichViewActions can use them.

To enable using help files, assign RVAControlPanel.UseHelpFiles = True.

Each UI language can have its own help file, you can specify in in RVA_SetHelpFile procedure.

If these help files are not defined, RichViewActions may use the application default help file (Application.HelpFile), if RVAControlPanel.UseDefaultHelpFile = True.

You can use either HelpContext or HelpKeyword of RichViewActions forms, see RVAControlPanel.HelpType.

The list of HelpContexts and HelpKeywords is in the topic about RVAControlPanel.HelpType. The default HelpKeywords are in English. If you want to modify them, use RVSetHelpKeyword procedure.