rvico TRichView Reference | Overview

Paragraphs in TRichView

Top  Previous  Next

Paragraphs

TRichView documents are organized in paragraphs. Each paragraph has its attributes ("style") defined as an index in the collection of paragraph styles (RichView.Style.ParaStyles).

For the list of properties available for paragraphs, see TParaInfo class (TParaInfo is a class of item in the collection of paragraph styles).

Line breaks inside paragraphs

(Since version 1.2) You can move am item to the new line within the same paragraph (press  Shift + Enter  instead of  Enter ). Visually, such line breaks have the following differences from paragraph breaks:

FirstIndent is not applied to the first line after the break;

no additional spacing between this line and the previous line (SpaceBefore and SpaceAfter) is applied;

if the paragraph has border/background, this line will be inside the same border/background as the previous line.

Specifying paragraph attributes when generating document

All methods of RichView for appending items (except for the obsolete methods) have ParaNo parameter. It can be:

zero or positive value: index in the collection of paragraph styles, if this item will start a new paragraph;

-1, if this item will continue the paragraph (please do not add items with ParaNo=-1 after breaks or tables).

Breaks (horizontal lines) do not have paragraph style, so AddBreak*** methods do not have ParaNo parameter. But SpaceBefore and SpaceAfter values of the 0-th paragraph style are added to spacing of all breaks.

These methods are:

procedure AddNL(s, StyleNo, ParaNo);

procedure AddFmt(FormatStr, Args, StyleNo, ParaNo);

procedure AddTextNL(s, StyleNo, FirstParaNo, OtherParaNo);

procedure AddTextNLA(s, StyleNo, FirstParaNo, OtherParaNo);

procedure AddTextNLW(s: WideString; StyleNo, FirstParaNo, OtherParaNo,

  DefAsSingleParagraph);

procedure AddPictureEx(Name, gr, ParaNo, VAlign);

procedure AddHotspotEx(Name, ImageIndex, HotImageIndex,

  ImageList, ParaNo);

procedure AddBulletEx(Name, ImageIndex, ImageList, ParaNo);

procedure AddControlEx(Name, ctrl, ParaNo, VAlign);

procedure Add(s, StyleNo); // equivalent to AddNL(s, StyleNo, -1).

There are some obsolete methods that were developed when RichView had no paragraph styles. They still work, see compatibility.

See also: building a document, item types.

All the methods above have "tagged" analogs, see "tags".

See also methods of RichView:

function LoadText(FileName, StyleNo, ParaNo, AsSingleParagraph):Boolean;

function LoadTextW(FileName, StyleNo, ParaNo, DefAsSingleParagraph):Boolean;

function AppendRVFFromStream(Stream, ParaNo):Boolean;

function IsParaStart(ItemNo): Boolean;

function IsFromNewLine(ItemNo): Boolean;

function GetItemPara(ItemNo): Integer;

Text flow around left- and right-aligned items

Some items (for example, pictures) can be aligned to the left or the right side (see TRVVAlign). For such items, an invisible placeholder is left in the place of their insertion; the item itself is placed at the specified side. If the item is at the beginning of the line, this item is placed on the same level; otherwise, it is placed below this line.

Paragraphs flow around side-aligned images. You can disallow flowing around left- and/or right-aligned items using ClearLeft and/or ClearRight properties.

Editing

RichViewEdit has a group of Insert*** methods inserting new item(s) in the position of caret, using the current paragraph style. Usually, if you implement RichViewEdit-based editor, you need to provide interface for displaying and changing the current paragraph style. You can do it using ComboBox with style names, toolbar buttons or/and keyboard shortcuts.

property CurParaStyleNo: Integer;

– index of the current (in the position of caret) paragraph style;

When the user moves the caret to paragraph with different style, OnCurParaStyleChanged event is generated, so you can select another item in ComboBox of styles or check toolbar buttons.

Assigning to CurParaStyleNo property is possible, but will not create a desired effect. To apply style to the paragraph at the position of the caret (and all selected paragraphs) use

procedure ApplyParaStyle(ParaStyleNo: Integer);

ApplyParaStyle applies only one paragraph style to all selected paragraphs. This method does not allow to implement more complex commands, such as "increase indents", "align to the right", etc. For implementing these commands, use

procedure ApplyParaStyleConversion(UserData: Integer);

See also...

Borders and Background of Paragraphs


TRichView © trichview.com