OnRVFPictureNeeded ItemNo

General TRichView support forum. Please post your questions here
Post Reply
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

OnRVFPictureNeeded ItemNo

Post by Jim Knopf »

Hi,

how can I get the item number inside this event, e.g. for getting information via GetItemExtraStrProperty?

Thank you
Martin
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Sergey Tkachenko »

It's not possible, because this event is called before insertion.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Jim Knopf »

hm ... so I get a serious problem. I need to find a solution to add captions to images. I can add a white bar to the bottom of the graphics. But then I need a way to write the subtitle on this border. At which OnPaint event can I insert this and how to do it?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Sergey Tkachenko »

There is no OnPaint event for images.
One of possible solutions is using OnItemAction event. Check for the parameter ItemAction = rviaInserted.
This event does not have ItemNo parameter, but it has the item object, so you can access its properties, such as Item.Tag.

Note that this event is called not only after the initial insertion, but when moving items from cell to inplace editor and back. So you need to set some property to prevent modifying the image multiple times.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Jim Knopf »

Thanks for the quick reply.

How can I draw the tag of the item on the bar at the bottom ...? Unfortunately, the problem is not only inserting a graphic, but I also need to react when the width of the image or the page format changes.

For example, one image is 1500 px wide but only 600 in the text, the other is displayed as wide as it is.

I tried to create a second graphic at RVFPictureNeeded (RVFOptions rvfoSavePictureBody = False), which is a bit higher, so it has a white border. Depending on the relative width of the graphic to the width of the text, the font is enlarged so that it appears the same size for all images.

But this solution is just not clean if the font is scaled down when really displayed (see image, the bottom graphic).

I also tried TRVLabelItemInfo, but of course that can't be positioned appropriately.

If I can't find a solution, a larger order will be lost.

Edit: sorry, couldn't post the image, it is too large.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Jim Knopf »

Image
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Sergey Tkachenko »

Do you need to add text on all images, or only on certain images?
If the latter, a possible solution is creating a new item type, inherited from TRVGraphicItemInfo, with overridden Paint (and maybe also PrintToBitmap) methods.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Jim Knopf »

For this company, we always need it with all images, because they also need a list of illustrations in a separate chapter. They do training material in a team, several people do their part, and then everything is put together into one project (=document).

Would there be a simpler method for all images - and especially one where you don't have to write in the graphic, because by scaling naturally a loss of quality happens?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Sergey Tkachenko »

Ok, I'll add OnAfterDrawImage and OnAfterPrintImage events in TRichView/TRVPrint.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Jim Knopf »

Thanks, but maybe this is not necessary at all. It would even have a small disadvantage, because the graphic has to be enlarged at the bottom to make space for the text.

If you could give me a hint as to where and how I would need to hook in a derived class, I think that would do it. Then I could create the thumbnail image there including the border - if I understood correctly - and also label it right away. After all, I have the image name available in this class - correct, right? - so I can read the necessary information from an external file and complete it there.

However ... should you want to make the derived class as an example, then this could perhaps be very practical for many users of TRichViewEdit. So you can then read the title and figure number from a table based on the image name (xyz.jpg) and subsequently also simply create a list of figures further back in the document. This would provide a functional solution for captions without the need for major changes.

If you could give this derived object FontName, FontSize, FontStyle, HorzAlignment and subtitle on an event 'OnCaption' for example, then the whole problem would be elegantly solved.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Sergey Tkachenko »

These events are already added in TRichView 19.3.1.

As for the derived item, look at the example <TRichView Dir>\Demos\Addins\BlendBitmap\
It shows how to subclass an item for images to add transparency.

Briefly:

- create a class inherited from TRVGraphicItemInfo (in this example, TRVGraphicItemInfo)
- assign an unique negative value to its StyleNo property (in this example, rvsBlendBitmap = -50). The list of item identifiers that are already used: https://www.trichview.com/help/idh_const_rvsxxx.html
- call RegisterRichViewItemClass
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Re: OnRVFPictureNeeded ItemNo

Post by Jim Knopf »

Thanks, I will try it that way.
Post Reply