Reading Information about Items of TRichView

<< Click to display table of contents >>

Reading Information about Items of TRichView

There are two groups of methods that can be used to obtain information about items of RichView:

Get***Info methods, introduced in RichView, can be used to get information about any item;

GetCurrent***Info methods of RichViewEdit, return information about the "current" (at the caret position) item.

GetCurrent***Info methods  are equivalent to Get***Info(CurItemNo,...). But there is one important exception: when using tables, GetCurrent***Info methods return information about the item at the position of caret regardless its location (in root editor or in cell inplace editor).

Read-only property RichView.ItemCount returns the number of items.

 

function RichView.GetItemStyle(ItemNo: Integer): Integer;

This method returns style (type) of item with the specified index.

If the returned value>=0 then this is a text item and the returned value is an index in the collection of text styles (RichView.Style.TextStyles).

If the returned value <0 then this is a special item. Negative value could be equal to one of the following constants:

Constant

Value

Meaning

rvsBreak

-1

horizontal line

rvsPicture

-3

picture

rvsHotspot

-4

hotspot

rvsComponent

-5

Delphi control

rvsBullet

-6

bullet

rvsHotImage

-10

hot-picture

rvsListMarker

-11

list marker (bullet or numbering of paragraphs)

rvsTab

-12

tabulator

rvsTable

-60

table

See also: rvsXXX constants)

When you know a type of item you can get further information about it with the methods (Get***Info methods):

GetBreakInfo,GetBulletInfo, GetHotspotInfo, GetPictureInfo, GetControlInfo, GetTextInfo.

For item of any type your can get additional property: GetItemExtraIntProperty and GetItemExtraStrProperty.

For item of any type your can get "tag" (GetItemTag), "checkpoint" (GetItemCheckpoint)

For any item you can get information about its paragraph: (GetItemPara, IsParaStart, IsFromNewLine).

For any item you can get its text (text for text item, name for non-text item) (GetItemText)

For any item you can get object representing it in a document (GetItem, usually used for tables)

In editor you can use the methods above or GetCurrentBreakInfo, GetCurrentBulletInfo, GetCurrentHotspotInfo, GetCurrentPictureInfo, GetCurrentControlInfo, GetCurrentTextInfo (GetCurrent***Info methods), and GetCurrentTag, GetCurrentCheckpoint, GetCurrentItemText.

The arguments of these methods are similar to the arguments of Add***Tag methods for appending items.

It should be noted that these methods return references to pictures and controls owned by RichView, not to their copy. Please use them wisely. For example, you can draw something on the returned picture but you should not destroy it. The preferred way to modify items of RichView is using Set***Info (or Set***InfoEd for editor). Exception: items with rvepShared property.

A table at the position of the caret (or a top-level table containing the caret) can be obtained with the method GetCurrentItemEx.