|
Building RichView Document |
Top Previous Next |
|
Creating a New Document You can build document by:
Therefore, a general structure of document generation procedure is: MyRichView.Clear;
Note: all methods introduced in RichView (except for the formatting methods) do not reformat document, do not redraw RichView and do not call OnChange event (RichView does not have OnChange event, it is introduced in TRichViewEdit) ( A group of methods for adding items is the largest group of methods (and contains a large number of methods for backward compatibility). Appending Text Items Important: Do not pass string with cr, lf or cr+lf, tab and page break characters in the functions below, except for AddText*** methods! Some text items can be hypertext. Hypertext items are added by the same methods as regular text items. Methods working with String parameter These methods add text specified in a String parameter. This parameter is Unicode for Delphi/C++Builder 2009, and ANSI for the older versions of Delphi/C++Builder.
Methods working with ANSI/Unicode explicitly Notes for former users of freeware version: In older versions of RichView you was not able to add empty strings, which are useful as empty paragraphs. Now there is no such limitation. In older versions, there was no special processing of tab characters: they were displayed as special characters. Now Add*** methods replace tab characters with spaces or insert them as tabulators (RichView.Style.SpacesInTab space characters per one tab; changing SpacesInTab will not change already created document). Appending Images You can add picture of any Delphi format – TBitmap, TIcon, TMetafile, TJpegImage or third party graphic format. You should create a picture and TRichView will destroy it itself when necessary (for example, when you call RichView.Clear).
Appending Hot Images Appending Delphi Controls You can add any Delphi control in RichView, and it will work as usual. You should create the control and RichView will destroy it itself when necessary (for example, when you call RichView.Clear). The methods for adding controls assign RichView to control.Parent.
This version of TRichView, like old ones, uses Tag properties of inserted components for internal needs (do not confuse with RichView items tags). Appending Bullets – Images from ImageLists
Appending Hotspots – Hypertext Images from ImageLists Hotspots are just like bullets, but can have two images ("normal" and "hot") and can be used as hypertext link.
Appending Breaks – Horizontal Lines Adding Paragraphs' Bullets and Numbering (list markers) List markers can be added using SetListMarkerInfo method. Unlike the methods above, this method can insert list markers not only to the end of document, but set them for existing paragraphs. Adding Other Items Tables, labels, numbered sequences, endnotes, footnotes, references to parent footnotes and endnotes, custom item types do not have special methods for adding them to documents. All of them are added by AddItem method. Appending Checkpoints Checkpoints are not items of RichView, but methods for adding checkpoints are similar to methods for adding items. The main methods for appending checkpoints are AddNamedCheckpointEx, AddNamedCheckpointExTag. See "checkpoints". Adding Page Breaks Page break is an item property ("this item starts a new page" flag). Only items that start a new paragraph can start a new page. Example: var ItemNo: Integer;
MyRichView.AddNLATag('First page', 0, 0, 0); ItemNo := MyRichView.ItemCount; MyRichView.AddNLATag('Second page', 0, 0, 0); MyRichView.PageBreaksBeforeItems[ItemNo] := True; Appending and Inserting RVF You can append RVF data by the methods:
This method can insert RVF. The first item of RVF will have the specified Index. For example, if you want to append items from RVF, write: MyRichView.InsertRVFFromStream(MyStream, MyRichView.ItemCount); InsertRVFFromStream is the only method of RichView (not RichViewEdit) for inserting items.
This method is similar to InsertRVFFromStream (if it used for appending RVF), but it ignores paragraph style of the first item in RVF and uses ParaNo instead of it. ParaNo is an index in the collection of paragraph styles (RichView.Style.ParaStyles) (if item will start a paragraph) or -1 (if the item will continue paragraph). Appending Content of Another RichView
This is the most efficient method to copy contents of one RichView to another one. Both the source and the target RichViews must have the same "tag" mode (rvoTagsArePChars in Options) and must be linked to the same RVStyle. Inserted controls and tables are not copied with this method (just ignored). Loading Methods for loading (Load***) belong to this group of methods as well. Additional Notes There is an important change in version 1.2: you can add items from new line without starting a new paragraph. There are no new methods for generating documents (it is added in v1.3: AddTextNLW), but there is a method that affects their behavior: TRichView.SetAddParagraphMode. Some custom item types (such as tables) do not have special methods for appending them. They can be appended by general method AddItem. |