Page 1 of 1

Colours in dbrichviewedit text

Posted: Thu Sep 25, 2014 11:15 am
by jota
Hi

What is the easiest way to know how many colors there are in the text of a dbrichviewedit?

For example:

"This is the text in a dbdrichviewedit]" -> The result is three (black, red and blue)

Thanks in advance

Posted: Thu Sep 25, 2014 11:30 am
by Sergey Tkachenko
For each RVStyle.TextStyles[], check Color property.

Also, list markers may have colors.
For each RVStyle.ListStyles[].Levels[], if UsesFont returns True, check Font.Color.

Posted: Mon Sep 29, 2014 11:35 am
by jota
hi

I doubt

I need to know the different colors actually in the written text in tdbrichviewedit.

RVStyle.TextStyles gives me the information I need?

Or only contains information about colors and other styles possibilities. if so how can I get information that i want?

Thanks

Posted: Mon Sep 29, 2014 12:39 pm
by Sergey Tkachenko
TextStyles actually represent formatting of text, not real styles (real styles are called StyleTemplates, and they are optional).

TextStyles contain information about attributes of all text. There can be only one problem: some styles may be unused (no text item uses them).
For DBRichViewEdit, it is HIGHLY recommended to set AutoDeleteUnusedStyles=True, so that unused styles are deleted when a new document is created.

You can call DeleteUnusedStyles(True, True, True) before enumerating colors, it will delete unused styles. However, this method clears undo buffer as well.
Another problem: DeleteUnusedStyles does not delete styles having property Standard=True. To solve this problem, delete at design time all RVStyle.TextStyles and RVStyle.ParaStyles, except the first item in the collection.