Modifying TRichView Items

<< Click to display table of contents >>

Modifying TRichView Items

There are several groups of methods for modifying content of RichView:

Set***Info methods, introduced in TRichView (viewer-style methods)

Set***InfoEd methods of RichViewEdit (editor-style methods)

SetCurrent***Info methods of RichViewEdit the same as Set***InfoEd but work with the "current" (in the caret position) item.

SetCurrent***Info methods are equivalent to Set***InfoEd(CurItemNo,...) But there is one important exception when using tables, SetCurrent***Info methods modify item at the position of caret regardless its location (in the root editor or in cell inplace editor).

You cannot change a type of item (except for conversion pictures to hot-pictures and vice versa)

First, you need to know a type of item. You can use RichView.GetItemStyle(ItemNo). Or you can use CurItemStyle property of RichViewEdit for the item at the position of caret.

Next, you usually need to get information about the given item.

Finally, you can modify it.

Set***Info methods

The arguments of these methods are similar to the arguments of Add*** methods.

For the specified items you can use

·SetBreakInfo, SetBulletInfo, SetHotspotInfo (call Invalidate to repaint RichView after them, reformatting is not necessary)

·SetPictureInfo, SetControlInfo return Boolean value: "reformatting is necessary?" (call Invalidate to repaint RichView after it, reformatting is not necessary if new picture or control has the same size).

You can also use:

SetItemTag method to change tags of items,

SetCheckpointInfo to change checkpoints of items,

SetItemExtraIntProperty to change values of additional integer properties,

SetItemExtraStrProperty to change values of additional string properties,

SetItemText to change item text (visible text for text items, names for non-text items).

Please read the topic about "tags" if you want to change tags of items.

The limitations of this version are:

you can't change ImageList of bullets and hotspots;

you can't replace control with the different one;

It is not recommended to use these methods in editor, see Viewer vs Editor

Set***InfoEd methods (editor)

The same set of methods as Set***Info methods, with the same arguments, but they are editor-style methods.

SetBreakInfoEd, SetBulletInfoEd, SetHotspotInfoEd, SetPictureInfoEd, SetControlInfoEd;

also SetItemTagEd, SetCheckpointInfoEd, SetItemTextEd, SetItemExtraIntPropertyEd, SetItemExtraStrPropertyEd

SetCurrent***Info methods (editor)

The same as Set***InfoEd methods, but they work with the current (at position of caret) item.

SetCurrentBreakInfo, SetCurrentBulletInfo, SetCurrentHotspotInfo, SetCurrentPictureInfo, SetCurrentControlInfo,

also SetCurrentTag, SetCurrentCheckpointInfo, SetCurrentItemText, SetCurrentItemExtraIntProperty, SetCurrentItemExtraStrProperty.

Additional methods for controls

There are some special methods for resizing inserted controls in editor.

procedure ResizeControl(ItemNo: Integer; NewWidth, NewHeight: TRVCoord);

procedure ResizeCurrentControl(NewWidth, NewHeight: TRVCoord);

This is the preferred way to change size of the control. These methods reformat the affected part of document and repaint it.

If your control can sometimes change its size or move itself, you need to call

procedure AdjustControlPlacement(ItemNo: Integer);

procedure AdjustControlPlacement2(Control: TControl);

after such actions. These methods restore the correct position of the control and make all necessary reformatting and repainting if the control was resized.