richview TRichView

Properties   Methods   Events

<< Click to display table of contents >>

richview TRichView

Properties   Methods   Events

TRichView is a control for displaying documents with pictures, tables, Delphi controls, hyperlinks, footnotes and endnotes, etc.

Unit [VCL/FMX] RichView / fmxRichView.

Syntax

TCustomRichView = class(TRVScroller)

TRichView = class(TCustomRichView)

TRichView does not display its content if it is not linked to TRVStyle component via Style property.

The most important property settings can be done in the component editor for TRichView. In Delphi (C++Builder) IDE, right click the RichView object on the form, choose "Settings" in the context menu.

Hierarchy

hmtoggle_arrow1Hierarchy (VCL and LCL)

hmtoggle_arrow1Hierarchy (FireMonkey)

List of properties, events and methods

grouped in several categories (some entries can be in several groups)

DOWN General

DOWN Background

DOWN Appending Items

DOWN Hypertext

DOWN Style templates

DOWN Scrolling, margins, sizes

DOWN Selection and Clipboard

DOWN Saving and loading as RVF

DOWN Other methods for saving and loading

DOWN LiveBindings and DB

DOWN Information about items

DOWN Modifying items

DOWN Checkpoints

DOWN Mouse events

DOWN Live spelling check

DOWN Picture animation

DOWN Working in palette mode

DOWN Custom Drawing

DOWN Other properties, methods and events

General properties

Style link to RVStyle component defining a lot of properties which can be used in several RichViews;

Options some important options;

ItemCount number of items in the document.

Properties defining background

BackgroundBitmap;

BackgroundStyle;

Color.

Appending items (Add*** methods)

Main methods for appending items:

AddNL adds one text item;

AddBreak adds break (horizontal line);

AddBullet adds bullet (image from ImageList);

AddHotspot adds hotspot (image from ImageList - hypertext link);

AddPicture adds picture;

AddHotPicture adds picture - hypertext link;

AddControl adds Delphi/C++Builder control;

AddTab adds tabulator;

AddItem general method for appending items (usually used for tables);

also AddCheckpoint adds checkpoint which will be associated with next added item.

Additional methods for appending items:

Add adds one text item in last paragraph;

AddFmt adds one formatted string assembled from a Pascal format string and an array arguments;

AddTextNL, -A -W add several text items from text, separated by CR+LF characters;

Also

AppendFrom copies content from another RichView;

InsertRVFFromStream,

AppendRVFFromStream.

See also

Clear clears document;

SetAddParagraphMode;

Format, FormatTail format the document;

Reformat reformats the document.

Hypertext

event OnJump occurs when user clicks hyperlink;

event OnRVMouseMove occurs when mouse pointer moves over hyperlink;

events OnWriteHyperlink and OnReadHyperlink occur when document is saved or loaded as RTF, DocX or HTML.

property FirstJumpNo use to set hypertext id for the first hypertext item;

GetJumpPointLocation should be used instead of GetJumpPointItemNo in applications working with tables;

GetJumpPointY returns Y coordinate of item with the specified hypertext id.

Style templates

Properties:

UseStyleTemplates allows or disallows using Style.StyleTemplates.

StyleTemplateInsertMode specifies how style templates are used when inserting RTF or RVF content.

Events:

OnStyleTemplatesChange occurs then the collection of style templates has been modified.

Scrolling, margins and sizes

Properties:

LeftMargin, RightMargin, TopMargin, BottomMargin margins;

MaxTextWidth maximal width for word wrapping;

MinTextWidth minimal width for word wrapping (minimal width of scrollable area, not including margins);

DocumentHeight height of document (height of scrollable area);

VAlign vertical alignment of document;

VScrollVisible hides/shows vertical scrollbar;

HScrollVisible hides/shows horizontal scrollbar;

VSmallStep number of pixels in one step of vertical scrollbar;

FirstItemVisible the first visible item;

LastItemVisible the last visible item;

MaxLength maximal count of characters per line;

WordWrap allows to disable word wrapping;

Tracking whether RichView repaints while its scrollbar thumb tab is dragged with the mouse.

Methods:

ClientToDocument converts client coordinates to document coordinates

Events:

OnVScrolled occurs when document is scrolled vertically

OnHScrolled occurs when document is scrolled horizontally

Also:

property CPEventKind

event OnCheckPointVisible

method GetItemCoords

Methods for working with selection and the Clipboard

SelectionExists returns "is something selected?"l

 

Copy copies selection to the Clipboard in all available formatsl

CopyDef copies selection to the Clipboard using formats specified in Options;

CopyImage copies selected image to the Clipboard;

CopyTextA copies selection as text to the Clipboard;

CopyTextW copies selection to the Clipboard as Unicode text;

CopyRVF copies selection as RVF to the Clipboard;

CopyRTF copies selection as RTF (Rich Text Format);

 

GetSelectedImage returns selected image

GetSelText returns selection as text

GetSelTextW returns selection as Unicode string;

 

GetOffsBeforeItem, GetOffsAfterItem return offset before/after the given item; useful with SetSelectionBounds;

 

SelectAll selects the whole document for copying to the Clipboard;

SetSelectionBounds selects the specified items;

SelectWordAt selects the word at (X,Y);

SelectControl selects a visual control;

Deselect clears selection (not contents, but bounds);

 

GetSelectionBounds returns bounds of selection;

event OnSelect occurs when selection bounds are changed;

event OnCopy allows to copy selection to the Clipboard in custom formats;

property SelectionHandlesVisible shows or hides selection handles for a touch screen.

Properties, methods and events for loading and saving RVF

Properties:

RVFOptions – options for saving and loading RVF;

RVFWarnings describes warnings or errors occurred during the last reading of RVF.

Events:

OnRVFControlNeeded requests inserted control when reading RVF, if RVF was saved without controls' "bodies";

OnRVFImageListNeeded requests ImageList when reading bullet or hotspotfrom RVF;

OnRVFPictureNeeded requests image when reading RVF, if RVF was saved without images' "bodies".

Methods:

SaveRVF saves document or selection as RVF to the file;

SaveRVFToStream saves document or selection as RVF to the stream;

LoadRVF loads RVF from the file;

LoadRVFFromStream loads RVF from the stream;

CopyRVF copies selection as RVF to the Clipboard;

InsertRVFFromStream inserts RVF from the stream;

AppendRVFFromStream appends RVF from the stream using the specified paragraph style for the first RVF item.

Also:

methods Copy, CopyDef.

Other saving and loading

Methods:

SetHeader, SetFooter specify documents for using as headers and footers; they are used to load and save headers and footers to files (RVF, RTF, DocX)

LoadFromStream, LoadFromStreamEx load document in RVF, RTF, HTML, DocX, Markdown or text format (format detection) from a stream;

LoadFromFile, LoadFromFileEx  load document in RVF, RTF, HTML, DocX, Markdown or text format (format detection) from a file;

LoadHTML, LoadHTMLFromStream appends a file or a stream in HTML format;

LoadText appends text form a file;

LoadTextW appends text from a file in Unicode (UTF-16) encoding;

LoadRTF, LoadRTFFromStream appends a file or a stream in RTF (Rich Text Format);

LoadMarkdown, LoadMarkdownFromStream appends a file or a stream in Markdown format;

SaveHTML, SaveHTMLToStream save the document in an HTML file/stream;

SaveText, SaveTextToStream save the document in a file/stream as ANSI text;

SaveTextW, SaveTextToStreamW save the document in a file/stream as a Unicode text;

SaveDocX, SaveDocXToStream save the document (or selection) in a file/stream as DocX (Microsoft Word format);

SaveRTF, SaveRTFToStream save the document (or selection) in a file/stream as RTF.

SaveMarkdown, SaveMarkdownToStream save the document (or selection) in a file/stream as Markdown.

Properties:

RTFOptions options for DocX and RTF export.

RTFReadProperties properties for DocX and RTF import.

HTMLReadProperties properties for HTML import.

HTMLSaveProperties properties for HTML export.

MarkdownProperties properties for Markdown import and export.

Events:

OnSaveComponentToFile allows to save inserted controls in DocX, RTF, Markdown, HTML, and text files;

OnWriteHyperlink, OnReadHyperlink allow to customize saving/loading of hypertext links in HTML, Markdown, RTF and DocX files;

OnWriteObjectProperties allows saving additional properties of non-text objects in HTML, RTF and DocX files;

OnReadMergeField allow importing merge fields from RTF;

OnHTMLSaveImage, OnSaveImage2 allow to save images with HTML in custom formats and with custom file names;

OnSaveItemToFile allows to save any item in RTF, DocX, Markdown, HTML or text files in your own format;

OnImportPicture allows custom processing of external images when importing RTF, DocX, Markdown, HTML;

OnImportFile allows custom processing of external files when importing HTML;

OnAssignImageFileName allows changing file names assigned to inserted images when importing RTF, DocX or Markdown.

LiveBindings and Databases

Properties:

Document allows linking this TRichView control to TBlobField field of DB (in Delphi XE2+)

Events:

OnNewDocument occurs when creating or before loading a document from a DB field

OnLoadDocument occurs after loading a document from a DB field

OnLoadCustomFormat allows loading documents from a DB field in custom formats

Information about items (Get***Info methods)

GetItemStyle returns a type of item;

 

GetTextInfo information about text item;

GetBreakInfo about "break";

GetBulletInfo about "bullet";

GetHotspotInfo about "hotspot";

GetPictureInfo about picture or "hot-picture";

GetControlInfo about inserted control;

GetItemExtraIntProperty[Ex],
GetItemExtraStrProperty[Ex] return value of extra item property;

GetItem general method for obtaining items (usually used for tables);

 

GetItemCheckpoint about item's "checkpoint";

GetItemVAlign about item's position relative to line;

GetItemTag about item's "tag";

GetItemText about text/name of item;

IsParaStart returns "is this item a first item in paragraph?";

IsFromNewLine returns "is this item a first item in paragraph?";

GetItemPara returns an index of paragraph containing a specified item;

GetItemNo returns item index for object representing item (usually used for tables);

GetItemCoords returns coordinates of item relative to document area, GetItemClientCoords returns coordinates of item relative to client area of RichView window;

properties PageBreaksBeforeItems, ClearLeft, ClearRight.

Modifying items  (Set***Info methods)

SetBreakInfo changes break;

SetBulletInfo changes bullet;

SetHotspotInfo changes hotspot;

SetPictureInfo changes picture or hot-picture;

SetControlInfo changes inserted control;
also

SetItemTag changes item's "tag";

SetItemVAlign – change the item position relative to the line;

SetItemText changes text/name of item;

SetItemExtraIntProperty[Ex],
SetItemExtraStrProperty[Ex] sets value of extra item property;

SetCheckpointInfo sets or changes item's "checkpoint";

RemoveCheckpoint removes item's "checkpoint";

see also properties PageBreaksBeforeItems, ClearLeft, ClearRight.

Working with checkpoints

Obtaining checkpoint data:

GetFirstCheckpoint, GetNextCheckpoint allow to receive full list of checkpoints;

GetLastCheckpoint, GetPrevCheckpoint – the same in backward direction;

GetCheckPointByNo returns a checkpoint with the specified index;

GetItemCheckpoint returns the item's checkpoint;

event OnCheckPointVisible occurs when checkpoint (or "section", marked by this checkpoint) becomes visible as a result of vertical scrolling;

FindCheckPointByName searches for checkpoint with the specified name;

FindCheckPointByTag searches for checkpoint with the specified tag.

Extracting properties from checkpoint data:

GetCheckpointInfo returns main properties of the checkpoint;

GetCheckpointItemNo returns an index of item which owns the checkpoint;

GetCheckpointNo returns an index of the checkpoint;

GetCheckpointYEx, GetCheckpointXY returns coordinates of the checkpoint.

Also:

GetCheckPointY returns Y coordinate of checkpoint by its index.

See also methods for obtaining information about items and for modifying document.

Mouse events

OnRVDblClick occurs on double click;

OnRVMouseDown occurs when user presses mouse button;

OnRVMouseUp occurs when user releases mouse button;

OnRVRightClick occurs on right click.

OnItemHint allows customizing hints displayed when the mouse pointer moves above an item.

OnGetItemCursor allows customizing cursors displayed when the mouse pointer moves above an item.

See also hypertext events.

Live spelling check

StartLiveSpelling starts a live spelling thread;

ClearLiveSpellingResults clears all live spelling underlines and stops the thread;

LiveSpellingValidateWord removes live spelling underlines from the specified word;

OnSpellingCheck event – the place to check word spelling.

Picture animation

Properties:

AnimationMode specifies when image animation starts.

Methods:

StartAnimation starts all animations;

StopAnimation stops all animations;

ResetAnimation rewinds all animations to the first frame.

Working in palette mode

property DoInPaletteMode;

method UpdatePaletteInfo.

Custom drawing

Events:

OnPaint – painting on top of content;

OnAfterDrawImage – painting on top of images.

Others

Properties:

RVData object representing document;

Cursor cursor;

Delimiters characters not belonging to words;

TabNavigation sets mode for navigation through hypertext links and controls;

DocObjects additional object information for saving in RVF;

DocProperties additional text information for saving in RVF;

DocParameters store document page parameters;

NoteText text for references to parent notes;

UseVCLThemes [VCL] allows using colors of VCL themes (in Delphi XE2+);

UseFMXThemes [FMX] allows using text color of FMX style

DocumentPixelsPerInch [VCL,LCL] / ZoomPercent [FMX] allows zooming.

Methods:

DeleteUnusedStyles deletes unused text, paragraph and list styles from TRVStyle;

MarkStylesInUse, DeleteMarkedStyles – advanced methods for deleting unused styles;

SearchText, -A, -W search for the text string; OnTextFound event occurs when a text if found;

StoreSearchResult allows storing a position of a search result (to continue search from this position);

GetWordAt returns a word at the specified point;

DeleteItems, DeleteSection delete the specified range of items from document;

DeleteParas deletes the specified range of paragraphs, updates the document;

FindControlItemNo returns index of item which owns the specified inserted control;

GetFocusedItem returns the item in the focus;

GetLineNo returns line number in the specified position;

BeginOleDrag starts drag&drop.

Events:

OnItemAction;

OnControlAction.