Viewer vs Editor

<< Click to display table of contents >>

Viewer vs Editor

Methods of TRichView

TRichView has the following 3 groups of methods for modifying documents:

1.appending items to the end of the document (may be from file or stream);

2.modifying item with the given index;

3.loading files and streams.

Examples of the first group are: AddNL, AddPicture, LoadRTF.

Examples of the second group are SetPictureInfo, SetItemText.

Examples of the third group are: LoadRVF, LoadRTFFromStream.

All these methods have the following characteristics:

they do not require that the document is formatted (formatting is a preparing document for displaying)

even if the document was formatted before calling such method, it is not formatted after.

You need to call Format (or FormatTail) to display documents created or modified with such methods.

Table cells also have such methods.

These methods do not pause a live spelling thread, and it may lead to errors. Before calling these methods, make sure that live spelling is not running (by calling Clear or ClearLiveSpellingResults).

Methods of TRichViewEdit

TRichViewEdit has the following groups of methods for modifying documents:

1.all methods of TRichView;

2.methods for inserting items in the position of caret
(Insert*** methods, such as InsertText, InsertPicture);

3.methods for modifying the item at the position of caret
(SetCurrent*** methods, such as SetCurrentPictureInfo, SetCurrentItemText);

4.extended set of methods for modifying item with the given index
(Set***Ed methods, such as SetPictureInfoEd, SetItemTextEd).

Methods of the group 1 are referred as viewer-style methods, methods of the groups 2-4 are editor-style methods.

All these methods (except for the methods of the group 1, inherited from TRichView) have the following characteristics:

document must be formatted before calling such methods;

these methods automatically reformat the affected area of documents;

if the document is read-only they do nothing; they also respect protection of text and paragraphs;

they call OnChange event;

they can be safely called while a live spelling is running;

modifications can be undone and redone.

In an editor, the main application of the methods of the group 1 is generating new documents from scratch (after calling Clear).

The main application of other methods is performing user commands. They should not be used for generation of new document (because each such method updates documents, it can cause undesirable flicker, and they are much slower).

Important: You must not mix methods of group 1 and methods of groups 2-4! Methods inherited from TRichView do not update undo and redo buffers, and results of undo and redo commands will be unpredictable!

The only applications of methods of the group 1 is generating a new document, in the sequence:

1.Clear; (this method also clears undo and redo buffers);

2.One or several calls of methods of the group 1;

3.Format (after the document has been formatted, you can apply methods of the groups 2-4)

See also: Undo in tables