How to create a new TextStyle property for underline color?

General TRichView support forum. Please post your questions here
Post Reply
csterg
Posts: 306
Joined: Fri Nov 25, 2005 9:09 pm

How to create a new TextStyle property for underline color?

Post by csterg »

Hello,
i have succesfully implemented different underline schemes (e.g. double, dotted, colored, wave, etc). What i don't know is the best way to create a new style and have these data as properties.
For example, a new TFontInfo class could have 2 more properties:
- UnderlineColor
- UnderlineScheme (set of predefined values).

Then, i can use the custom drawing event to correctly paint the proper underline based on the above properties. Also, methods such as FindSuchStyle can also work.

Another question:
when i have an underline scheme that needs more than 1 pixel (e.g. a wave underline needs 4 pixels), and i use the rvsDefDrawTextBack to draw it, i cannot draw anything AFTER the default painting occurs. The problem is that if the text has a background color, then the only part i can draw to is below the line height: but in order to draw there, i need to set the LineSpacing to 3+ pixels which is not nice.
Checking at MSWord and similar apps, it seems that such multi-pixel underlines are painted within the line height and not below it. But this is not possible in that case if there is a color background because i cannot perform my custom painting after richview's painting.
Proposal: maybe there should be a way for the OnDefDrawTextBack event to be called AFTER the default painting to allow such things (or even better, be called twice with a parameter that says if it is before or after the default painting and allow for both cases)

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

Post by Sergey Tkachenko »

You can create a new component inherited from TRVStyle having text styles with additional properties.

Create a new class inherited from TFontInfo having new properties.
In you new RVStyle component, override GetTextStyleClass method to return your FontInfo class instead of TFontInfo.

Example: http://www.trichview.com/support/files/neweffects.zip

I am afraid, postpainting is not possible in the current version. You need to draw the whole item text yourself instead.
csterg
Posts: 306
Joined: Fri Nov 25, 2005 9:09 pm

Post by csterg »

Sergey Tkachenko wrote: I am afraid, postpainting is not possible in the current version. You need to draw the whole item text yourself instead.
Thanks for the example, it is exactly what i need.
Do you think it would be possible to add postpainting for a future version?
Costas
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I'll add it in to-do list when I return from vacations
Post Reply