|
Paragraphs in TRichView |
Top Previous Next |
|
TRichView documents are organized in paragraphs. Each paragraph has its 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 item to the new line within the same paragraph (press Shift + Enter instead of Enter ). FirstIndent will be applied to this item, but
All methods of RichView for appending items (except for the obsolete methods) have ParaNo parameter. It can be
Breaks (horizontal lines) do not have paragraph style, so AddBreakXXX 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 AddTextBlockNL(s, StyleNo, ParaNo); 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, having developed when RichView had no paragraph styles. They are still work, see compatibility. See also: building a document, item types. All 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: Integer): Boolean; function IsFromNewLine(ItemNo: Integer): Boolean; function GetItemPara(ItemNo: Integer): Integer; RichViewEdit has a group of InsertXXX methods which insert 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 current (in the position of caret) paragraph style; When user moves 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 in position of 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... |