string underlined like in spelling
string underlined like in spelling
Hi.
I want to use some of the spelling code so I can underline some strings in ScaleRichView. This strings can contain any character.
I can't use the code as it is because:
1. It has to work for any "delimiters".
2. The spelling is not using Unicode.
I just want to find the (wide)strings in visible area and underline them.
I found TRVWordMisspellPainter.Draw in RVWordPaint.pas but I don't know how to use it.
Can you help me, please?
Thanks.
I want to use some of the spelling code so I can underline some strings in ScaleRichView. This strings can contain any character.
I can't use the code as it is because:
1. It has to work for any "delimiters".
2. The spelling is not using Unicode.
I just want to find the (wide)strings in visible area and underline them.
I found TRVWordMisspellPainter.Draw in RVWordPaint.pas but I don't know how to use it.
Can you help me, please?
Thanks.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
This functionality is not supported. You can try to implement it, but with not guarantees. I know some users tried to use it, even created their new word painters, using different drawing method (not wavy underlines).
Generally, it should work like this:
Adding underlines to the ItemNo-th item in RVData, between characters specified with StartOffs and Length:
Generally, it should work like this:
Code: Select all
function GetWordPaintList(RVData: TCustomRVFormattedData; ItemNo: Integer): TRVWordPainterList;
var
Item: TCustomRVItemInfo;
begin
Item := RVData.GetItem(ItemNo);
if not Assigned(Item.WordPaintList) then
Item.WordPaintList := TRVWordPainterList.Create;
Result := Item.WordPaintList;
end;
Code: Select all
GetWordPaintList(RVData, ItemNo).Add(TRVWordMisspellPainter.Create(StartOffs, Length))
I have 2 suggestions for a future version:
1. Ability to underline tab items as well;
2. In RVData.GetItem(ItemNo).WordPaintList to be able to set underline color for each item. I mention this because I use underline not just for spelling and I want, for example, to underline in the same time words with red and something else with orange.
And 2 bugs to report:
1. For a text in a table cell: when the last line is close to the down border cell then the underline is not visible.
2. In a ScaleRichView page if the last text line is right before the dot line then the underline is visible on the next page.
I hope you'll implement/fix these as soon as possible.
Thank you.
1. Ability to underline tab items as well;
2. In RVData.GetItem(ItemNo).WordPaintList to be able to set underline color for each item. I mention this because I use underline not just for spelling and I want, for example, to underline in the same time words with red and something else with orange.
And 2 bugs to report:
1. For a text in a table cell: when the last line is close to the down border cell then the underline is not visible.
2. In a ScaleRichView page if the last text line is right before the dot line then the underline is visible on the next page.
I hope you'll implement/fix these as soon as possible.
Thank you.
Sorry for the delayed reply; my internet connection was down for almost 2 days.
The text file is not a rvf; it's a rtf. It's created with WordXP and modified with Wordpad.
It's easy to make one. But if you stil want me to send you the file, I will send it...
Here is a link to a screen capture with both situations: with or without a new line between undelined text and border cell
http://img134.imageshack.us/my.php?image=capturens2.png
You can clearly notice that most of the red line is not visible. It's not easy for the user to see that is underlined.
The text file is not a rvf; it's a rtf. It's created with WordXP and modified with Wordpad.
It's easy to make one. But if you stil want me to send you the file, I will send it...
Here is a link to a screen capture with both situations: with or without a new line between undelined text and border cell
http://img134.imageshack.us/my.php?image=capturens2.png
You can clearly notice that most of the red line is not visible. It's not easy for the user to see that is underlined.
A problem with InvalidateDrawItem.
It's a RichViewEdit function, I know, but I think the problem may be connected with ScaleRichView also.
When I use it in a separate thread it doesn't always repaint the item (Spacing parameter is 3). But if I use Spacing 1000 (!) it works.
This happens sometimes only when I edit the item. Other methods of changing the text, like Paste, work fine.
For example if in a text line I have "Line2" (underlined) and I insert a space between "Line" and "2" then "Line" continues to be underlined.
But if I Insert a space using Paste then "Line" is not underlined anymore.
In both cases TCustomRVFormattedData(CurRVData.GetRVData).InvalidateDrawItem(ItemNo, 3) is executed exactly the same.
After the editing operation if I "force" a RePaint (for example if I minimize then restore the application) then the red underline is erased.
The thread is stopped in a safe place at OnChanging event, at OnItemTextEdit event RVData.GetItem(ItemNo).ItemState is set to [] and then at OnChange event the thread is restarted. After 200 ms it rescans the hole text line in which the modified item is and calls InvalidateDrawItem for each item (from the text line).
A similar problem is with the code from LiveSpelling.
In OnSpellingCheck event I wrote "if AWord = 'Misspelledtext' then Misspelled := True;". In a text line in editor I wrote "Misspelledtext". It's underlined.
I insert a space between "Misspelled" and "text". The underline is gone.
I remove the space using only Delete/Backspace. "Misspelledtext" is not underlined. Only if I move the text cursor or if I force a RePaint the underline is drawn.
Strange, if I select the space then I press Delete then the underline is drawn immediately.
Please help me solve the problem.
Thank you.
It's a RichViewEdit function, I know, but I think the problem may be connected with ScaleRichView also.
When I use it in a separate thread it doesn't always repaint the item (Spacing parameter is 3). But if I use Spacing 1000 (!) it works.
This happens sometimes only when I edit the item. Other methods of changing the text, like Paste, work fine.
For example if in a text line I have "Line2" (underlined) and I insert a space between "Line" and "2" then "Line" continues to be underlined.
But if I Insert a space using Paste then "Line" is not underlined anymore.
In both cases TCustomRVFormattedData(CurRVData.GetRVData).InvalidateDrawItem(ItemNo, 3) is executed exactly the same.
After the editing operation if I "force" a RePaint (for example if I minimize then restore the application) then the red underline is erased.
The thread is stopped in a safe place at OnChanging event, at OnItemTextEdit event RVData.GetItem(ItemNo).ItemState is set to [] and then at OnChange event the thread is restarted. After 200 ms it rescans the hole text line in which the modified item is and calls InvalidateDrawItem for each item (from the text line).
A similar problem is with the code from LiveSpelling.
In OnSpellingCheck event I wrote "if AWord = 'Misspelledtext' then Misspelled := True;". In a text line in editor I wrote "Misspelledtext". It's underlined.
I insert a space between "Misspelled" and "text". The underline is gone.
I remove the space using only Delete/Backspace. "Misspelledtext" is not underlined. Only if I move the text cursor or if I force a RePaint the underline is drawn.
Strange, if I select the space then I press Delete then the underline is drawn immediately.
Please help me solve the problem.
Thank you.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Strange, I cannot reproduce the problem with not updating live spelling underlines.
I added the following code in OnSpellingCheck:
Misspelled := Pos('a', AWord)<>0;
and played with it.
It worked as expected, when I added space and deleted it by backspace (both in 'aaabbb' and in 'bbbaaa').
Do you use the latest version of ScaleRichView?
I added the following code in OnSpellingCheck:
Misspelled := Pos('a', AWord)<>0;
and played with it.
It worked as expected, when I added space and deleted it by backspace (both in 'aaabbb' and in 'bbbaaa').
Do you use the latest version of ScaleRichView?
Yes, I'm using the latest version.
The problem is not from my code - I just now tried with ActionTest Demo.
I wrote "Misspelledtext" in a new line at the beginning in readme.rvf, I saved and then I closed the application.
I opened it again; "Misspelledtext" is not underlined. Only if I edit the file anywhere else then it's underlined.
Afterward is behaving exactly like I said: insert a space between "Misspelled" and "text" + delete it with backspace = "Misspelledtext" not underlined (until I move the text cursor).
I said in my previous post "This happens sometimes only when I edit the item".
This means that for some words in text it works, for others it doesn't.
If you want I will send you this modified version (even the exe file if you want to).
PS: the difference between my test and your test is that when you insert a space one of the two new words is underlined. In my case neither of them are underlined. This has an influence on how is underlined when the space is deleted with backspace.
The problem is not from my code - I just now tried with ActionTest Demo.
I wrote "Misspelledtext" in a new line at the beginning in readme.rvf, I saved and then I closed the application.
I opened it again; "Misspelledtext" is not underlined. Only if I edit the file anywhere else then it's underlined.
Afterward is behaving exactly like I said: insert a space between "Misspelled" and "text" + delete it with backspace = "Misspelledtext" not underlined (until I move the text cursor).
I said in my previous post "This happens sometimes only when I edit the item".
This means that for some words in text it works, for others it doesn't.
If you want I will send you this modified version (even the exe file if you want to).
PS: the difference between my test and your test is that when you insert a space one of the two new words is underlined. In my case neither of them are underlined. This has an influence on how is underlined when the space is deleted with backspace.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I understand. It is not underlined because this word is considered as being edited. Such words are not underlined until you move the caret.
MS Word works in the same way, even more strictly (the edited word is not underlined until you move the caret outside of it. In TRichViewEdit/TSRichViewEdit, any caret movement causes rechecking the edited word).
MS Word works in the same way, even more strictly (the edited word is not underlined until you move the caret outside of it. In TRichViewEdit/TSRichViewEdit, any caret movement causes rechecking the edited word).
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Yes, send the demo (as simple as possible, with TRichViewEdit) to svt@trichview.com