Creating custom items

General TRichView support forum. Please post your questions here
Post Reply
gacek999
Posts: 7
Joined: Tue Dec 06, 2005 10:05 pm

Creating custom items

Post by gacek999 »

Hi Sergey,

How could I create custom items and store my custom data
within it? I know I must derive class from TCustomRVItemInfo.
(TRVNonTextItemInfo in my case because I want invisible items)
I saw SaveRVF method, but what about loading?

Simply I need to do emoticons (not same-sized) and I cannot
store them in ImageList's. I plan to insert invisible item with emoticon
name in document, and replace it with bullet when loading.
Btw. I need it also to store files/streams inside RVF.

best regards
Piotr
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If document contains no other images, you can use standard image items. Exclude rvfoSavePicturesBody from RichView.RVFOptions.
Images will not be saved in RVF, but requested when RVF is loaded (in OnRVFPictureNeeded event)
gacek999
Posts: 7
Joined: Tue Dec 06, 2005 10:05 pm

Post by gacek999 »

Thanks, but it dont cover my problem :( I need to save pictures body
also (for external images), and explicitly for emoticons (and files).
I'm writing chat program and these data would go through sockets.

//edit:

I tried to use controls and stream them to RVF but
streaming custom items is bandwidth cheaper. I don't
need all control's properties in RVF.
gacek999
Posts: 7
Joined: Tue Dec 06, 2005 10:05 pm

Post by gacek999 »

Hi Sergey,

I tried to figure out creating custom types myself from RVItem.pas.
(Help says that "Detailed description of classes for item types is beyond
the scope of this help file."). I check out two methods to override:
SaveRVF and ReadRVFLine but there are many more methods.
Could you write some simple how-to showing creation of custom items?
I made sending messages with formatted text and pictures already,
now only things I need are custom items.

Thanks in advance.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Look in Demos\Addins\ for examples of custom item types.
The most interesting is LabelItem (other two make higher level modification - they only modify drawing/printing methods of existing types). LabelItem is inherited from a basic class for non-text items: TRVRectItemInfo.

Let's see which methods it overrides.

First, Paint and Print. They are absolutely necessary.
Next, GetBoolValue and GetBoolValueEx. They return values of some boolean item properties.
Next, Assign method.
Next, methods for exporting in different formats: SaveRTF, SaveToHTML, AsText.
Next, methods related to the text style associated with this item. I think you do not need it for your items, so ignore MarkStylesInUse, UpdateStyles, ApplyStyleConversion, GetAssociatedTextStyleNo, SetAssociatedTextStyleNo.
Next, RVF-related methods. SaveRVF saves item to RVF, including the item header and all subsequent lines. Search the help file index for "RVF Specification".
When reading RVF, the item header line is read not by the item, but by the RVF reading procedure itself. The end of the item header line may contain additional information, but I do not recommend to use it - use subsequent lines to store additional information.
RVF info is read line by line, ReadRVFLine is called for each line, index of the read line is specified in LineNo parameter. The item info may contain one block of binary data. It it exists, it is counted as one line and it must be the last line. More info is in the help file, "RVF Specification".
There are many other methods which may be overriden, but they are not necessary.
Post Reply