View Issue Details

IDProjectCategoryView StatusLast Update
0025275LazarusLCLpublic2013-11-05 10:23
ReporterAvishai Assigned ToBart Broersma  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Summary0025275: THintWindow.CalcHintRect gives the wrong result.
DescriptionIn 'HintWindow.inc' the routine 'THintWindow.CalcHintRect' gives the wrong result IF the control.BiDiMode<>bdLeftToRight AND the text is Hebrew. This is probably true for all RightToLeft languages. The result is that the Top and Bottom of the Hint Text is chopped off. I think the Width is also short causing Text to wrap when it should not.

What puzzles me is that if BiDiMode:= bdLeftToRight and Hebrew Text, it gives good window size.

Here is some Hebrew Text for testing:

'אבישי אבישי אבישי'0000013#10'אבישי אבישי אבישי!'

For this to work, in Application.inc you must activate the line 'FHintWindow.BiDiMode := FHintControl.BiDiMode;' in 'procedure TApplication.ShowHintWindow'
TagsNo tags attached.
Fixed in Revisionr43367
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Avishai

2013-11-03 15:41

reporter   ~0071118

Last edited: 2013-11-03 17:05

View 2 revisions

I added this code at the end of THintWindow.CalcHintRect and it seems to give usable results.

[code]
if BiDiMode<>bdLeftToRight then inc(Result.Right, 1);

Avishai

2013-11-03 15:59

reporter   ~0071119

Last edited: 2013-11-03 16:33

View 2 revisions

See my *Solution* at http://forum.lazarus.freepascal.org/index.php/topic,22358.msg133065.html#new

This is related to issue 0022048

Bart Broersma

2013-11-03 17:54

developer   ~0071122

I can see it is not displayed correctly, but THintWindow.CalcHintRec produces the same rect in either case:
THintWindow.CalcHintRect (AHint[1]=Î) Result=l=0,t=0,r=118,b=38 BidiMode=bdLeftToRight
THintWindow.CalcHintRect (AHint[1]=Î) Result=l=0,t=0,r=118,b=38 BidiMode=bdRightToLeft

Bart Broersma

2013-11-03 17:56

developer  

hintwindow.ltr.png (3,507 bytes)   
hintwindow.ltr.png (3,507 bytes)   

Bart Broersma

2013-11-03 17:56

developer  

hintwindow.rtl.png (2,924 bytes)   
hintwindow.rtl.png (2,924 bytes)   

Bart Broersma

2013-11-03 17:59

developer   ~0071123

@Avishai: I uploaded two screenshots.
I guess the LTR version contains the full text (left to right) (I used the text from your example)?
Does it look the same for you?
This is with themes enabled. With themes disabled it looks even worse.

Avishai

2013-11-03 18:09

reporter   ~0071124

Thanks Bart :)

Yes it was the same before I made 2 small changes. But with the changes that I suggest everything seems to look as it should.

In File 'Application.inc' near line 0000840 in routine
'TApplication.ShowHintWindow' I activated this line that had been commented out.

Code:
FHintWindow.BiDiMode := FHintControl.BiDiMode;


Then in the File 'HintWindow.inc' I added this line as the last line in routine 'THintWindow.CalcHintRect' near line 0000276.

Code:
if BiDiMode<>bdLeftToRight then inc(Result.Right, 1);

Bart Broersma

2013-11-03 18:13

developer  

hintwindow.ltr.nothemes.png (2,088 bytes)   
hintwindow.ltr.nothemes.png (2,088 bytes)   

Bart Broersma

2013-11-03 18:13

developer  

hintwindow.rtl.nothemes.png (2,533 bytes)   
hintwindow.rtl.nothemes.png (2,533 bytes)   

Bart Broersma

2013-11-03 22:20

developer   ~0071127

I understand what you did, but I cannot see how it "works".

> In File 'Application.inc' near line 0000840 in routine
> 'TApplication.ShowHintWindow' I activated this line that had been commented out.

I already commited that to trunk (r43361).

For me CalcHintRec returns the same values independant from BidiMode.
How then can it be that only in one case it would be wrong?
Is "TextWidth" dependant on BidMode?

Also, would you mind answering my questions from note 0071123?

Avishai

2013-11-03 22:45

reporter   ~0071128

Last edited: 2013-11-03 22:55

View 3 revisions

This is my best guess. It looks to me that the spacing of the Text from the Left edge (L2R) it not the same as the spacing from the Right edge (R2L) which causes the line to wrap but does not change the height. I *think* I can even see a slight difference on screen, but maybe I'm only seeing what I want to see :)

Actually incrementing the width by 1 doesn't hurt anything for L2R so I'm not sure that the test for BiDiMode is even needed. It could do that for both R2L and L2R without problem.

Bart Broersma

2013-11-03 23:41

developer   ~0071131

Please Test and close if OK.

Avishai

2013-11-04 00:19

reporter   ~0071132

Last edited: 2013-11-04 10:53

View 2 revisions

Did you commit the changes? I ask because I just did SVN Update and I don't see any relevant changes in the code or in the wrong behavior of the Hints.

Bart Broersma

2013-11-04 18:24

developer   ~0071143

Yes, see: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/include/hintwindow.inc?root=lazarus&r1=43367&r2=43366&pathrev=43367

The fix is to use DT_RTLREADING in the call to DrawText.

Avishai

2013-11-05 10:23

reporter   ~0071149

Thanks Bart. :)

Issue History

Date Modified Username Field Change
2013-11-03 14:37 Avishai New Issue
2013-11-03 15:41 Avishai Note Added: 0071118
2013-11-03 15:59 Avishai Note Added: 0071119
2013-11-03 16:33 Avishai Note Edited: 0071119 View Revisions
2013-11-03 17:05 Avishai Note Edited: 0071118 View Revisions
2013-11-03 17:54 Bart Broersma Note Added: 0071122
2013-11-03 17:56 Bart Broersma File Added: hintwindow.ltr.png
2013-11-03 17:56 Bart Broersma File Added: hintwindow.rtl.png
2013-11-03 17:59 Bart Broersma Note Added: 0071123
2013-11-03 18:03 Bart Broersma LazTarget => -
2013-11-03 18:03 Bart Broersma Status new => feedback
2013-11-03 18:09 Avishai Note Added: 0071124
2013-11-03 18:09 Avishai Status feedback => new
2013-11-03 18:13 Bart Broersma File Added: hintwindow.ltr.nothemes.png
2013-11-03 18:13 Bart Broersma File Added: hintwindow.rtl.nothemes.png
2013-11-03 22:20 Bart Broersma Note Added: 0071127
2013-11-03 22:21 Bart Broersma Status new => feedback
2013-11-03 22:45 Avishai Note Added: 0071128
2013-11-03 22:45 Avishai Status feedback => new
2013-11-03 22:49 Avishai Note Edited: 0071128 View Revisions
2013-11-03 22:55 Avishai Note Edited: 0071128 View Revisions
2013-11-03 23:41 Bart Broersma Fixed in Revision => r43367
2013-11-03 23:41 Bart Broersma Note Added: 0071131
2013-11-03 23:41 Bart Broersma Status new => resolved
2013-11-03 23:41 Bart Broersma Resolution open => fixed
2013-11-03 23:41 Bart Broersma Assigned To => Bart Broersma
2013-11-04 00:19 Avishai Note Added: 0071132
2013-11-04 10:53 Avishai Note Edited: 0071132 View Revisions
2013-11-04 18:24 Bart Broersma Note Added: 0071143
2013-11-05 10:23 Avishai Note Added: 0071149
2013-11-05 10:23 Avishai Status resolved => closed