Overview | Using RichViewActions

Top  Previous  Next

Overview

All actions have Control property of TCustomRichViewEdit type. If this property is not assigned, actions work with the focused control (or DefaultControl of TRVAControlPanel 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, 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 linked image-list is 16x16, an action image will be added automatically.

Alternatively, you can use dmActions.pas unit. This is a datamodule containing a ready to use ActionList and ImageList. If you will not modify this unit, you can include it in your project directly. But it's highly recommended to create a copy of this unit (under a new name) and use it instead. Important: if you access actions in OnCreate event of some form, this form must be created after this 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 editor, assign RVRuler.RichViewEdit to this editor.

In TRVAControlPanel.OnMarginsChanged call RVRuler.UpdateRulerMargins.

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

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

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. If you use Addict 3-4, suggestions, "add to dictionary" and "ignore all" commands appear in the menu automatically. Otherwise, you need to process 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.

Bidirected text

Use these actions only if you really need this feature in your application (bidirected text is not completely supported in all versions of Windows).

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

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

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


RichView © Sergey Tkachenko