<< Click to display table of contents >> Paragraphs in TRichView |
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).
(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.
All methods of TRichView for appending items 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 method does 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, Tag);
procedure AddFmt(FormatStr, Args, StyleNo, ParaNo);
procedure AddTextNL(s, StyleNo, FirstParaNo, OtherParaNo,
DefAsSingleParagraph, Tag);
procedure AddPicture(Name, gr, ParaNo, VAlign, Tag);
procedure AddHotspot(Name, ImageIndex, HotImageIndex,
ImageList, ParaNo, VAlign, Tag);
procedure AddBullet(Name, ImageIndex, ImageList, ParaNo, VAlign, Tag);
procedure AddControl(Name, ctrl, ParaNo, VAlign, Tag);
procedure Add(s, StyleNo); // equivalent to AddNL(s, StyleNo, -1).
See also: building a document, item types.
See also methods of TRichView:
function LoadText(FileName, StyleNo, ParaNo, AsSingleParagraph,
CodePage):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;
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.
TRichViewEdit has a group of Insert*** methods inserting new item(s) at 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 (at 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);