TRichView Item Types

<< Click to display table of contents >>

TRichView Item Types

Items

TRichView documents consist of items. Items are indexed from 0 to ItemCount-1. Some items may contain sub-documents which in their order contain items. Such items are:

tables (each cell is a sub-document displayed in the same TRichView control)

notes (endnotes, footnotes, sidenotes) and text boxes (their sub-documents are not displayed in TRichView controls; however, they are printed and displayed in ScaleRichView)

Items of subdocuments are not items of the main document, the are not included in the item range from 0 to ItemCount-1.

Item Types

A type (also called "style" in this manual) identifier of the given item is returned by the method GetItemStyle (in editor, a style of the item at the position of caret is returned by CurItemStyle).

If the returned value is 0 or positive, this is a text item. In this case, the returned value defines a style of this text: it is an index in the TextStyles collection of the the linked TRVStyle component.

If the returned value is negative, this is a constant identifying the item class.

The standard TRichView item types are:

text

tabulators

pictures

hot-pictures (pictures with hyperlink)

breaks (horizontal lines)

controls (any Delphi/C++Builder/Lazarus control)

bullets (images from image-list)

hotspots (bullets with hyperlink)

tables

list markers (paragraph bullets & numbering)

labels (non-text item looking like text)

numbered sequences

endnotes

footnotes

sidenotes

references to parent notes

text boxes

mathematical expressions

Below is the overview of properties which are common for all item types.

Text

Each item has associated text. For text items, this text is displayed. For non-text items, this text is not used by the component itself; you can store any information in it. Text must not contain characters: CR (#13), LF (#10), #0.

For text-items, text can be in traditional (ANSI) or in Unicode encoding. ANSI text must not contain characters (CR (#13), LF (#10),  #0, TAB (#9), FF (12).

See GetItemText, SetItemText methods of TRichView and related methods of TRichViewEdit.

Tag

Tag is an additional string value associated with each item (Unicode for Delphi/C++Builder 2009+, ANSI for older versions).

The default value of tags is '' (empty string) .

For example, you can use tags to store targets of hyperlinks.

See also: Tags in TRichView

Checkpoint

Checkpoint marks the item and can be used to find this item quickly. Checkpoints are exported in RTF and DocX as bookmarks, in HTML as anchors.

See also: Checkpoints in TRichView

Pagebreak-before Flag

If this flag is set, this item starts a new page when printing.

See PageBreaksBeforeItems.

Paragraph Attributes

Items are organized in paragraphs. Paragraph attributes are defined in the ParaStyles collection of the linked TRVStyle component.

GetItemPara returns an index of paragraph style for the given item. This method returns the same value for all items in the same paragraph.

IsParaStart returns True, if the given item starts a new paragraph.

IsFromNewLine returns True, if this item starts a new paragraph or a new line in this paragraph.

Vertical Alignment

These properties can be applied only to non-text item types which are positioned like a character of text. They cannot be applied to items occupying a full line (such as tables and breaks).

By default, bottom of item is aligned to the base line of text (items of some types can be aligned differently, see TRVVAlign).

You can move item up or down by the specified number of pixels/twips/EMU or percent. See the following extra item properties: rvepVShift, rvepVShiftAbs.

For text items, see VShift property of text style.

Spacing

You can define spacing around the item. See the following extra item properties: rvepSpacing

Coordinates

GetItemCoords returns coordinates of the top left corner of the given item relative to the beginning of the document.

GetItemClientCoords returns coordinates of the left top corner of the given item relative to the top left corner of RichView window.

Protection

Text have several option of protection, see Protection properties of text style.

You can protect non-text items from deletion. See the following extra item integer properties: rvepDeleteProtect.

Visibility

Items can be hidden. Hidden items are displayed only if rvoShowHiddenText is included in the Options property of TRichView control.

Text items are hidden, if rvteoHidden is included in the Options property of their style.

Non-text items are hidden, if a non-zero value is assigned to rvepHidden extra item integer property.

Popup Hints

The component can show a hint message when the mouse pointer is above the item.

See the following extra item string properties: rvespHint.

Hint message can be dynamically customized in OnItemHint event.

Events

OnItemAction occurs when item is inserted, deleted, moved to undo list, or when item text is modified.

OnSaveItemToFile occurs when saving item in HTML, RTF or text file or stream. This is a "low level" event. It allows you to change how the item is saved.