Recent

Author Topic: How to make gap between lines in StringGrid  (Read 14673 times)

wp

  • Hero Member
  • *****
  • Posts: 13543
Re: How to make gap between lines in StringGrid
« Reply #30 on: January 21, 2016, 10:29:10 pm »
Thanks for the patch, I'll have a look at it afterwards.

You are approaching the real problems...

Since in the WorksheetGrid every character can have a different font, the text is drawn character by character, instead of in one piece with the Canvas.TextOut. Could you test the attached little program (BiDi TextOut) whether any text that you enter in the edit control at the bottom in RTL mode (checkbox marked) is drawn correctly in the 2nd paintbox? The top paintbox draws the text in one piece, the lower one character by character, similarly like fpspreadsheet does. In my system the upper text is always drawn in left-to-right direction, the lower one in right-to-left, but I think this is because the canvas on my system is always LTR. I must understand this. In your system both texts should be the same.

I am attaching another little project (fps-bidi) which compares a StringGrid with WorksheetGrid in LTR and RTL. At least in my system the screenshot shows that there is a LOT to be done...

Ah, and BTW: I suppose this BiDi discussion will take some time. I would appreciate if you could put this into a separate thread because nobody will find it under its current header.
« Last Edit: January 21, 2016, 10:30:46 pm by wp »

wp

  • Hero Member
  • *****
  • Posts: 13543
Re: How to make gap between lines in StringGrid
« Reply #31 on: January 22, 2016, 12:05:34 am »
I looked at your patch, thanks again. I had to debug it, though, because there was a clipping rectangle in DrawAllCells which was not adapted to RTL. And the selection rectangle is not drawn correctly: drag the mouse across several cells horizontally and see that the selection does not follow the mouse correctly as it does vertically or in LTR mode - I did not yet find the bug in there.

Anyway, I uploaded the new version to trunk. When you proceed, it will save time if you would always update your svn before beginning. Just in case you don't know...

I think your previous post already answered the question above: the character-by-character painting routine is the reason why your Arabian characters are reversed. There is a single painting procedure for all text output, InternalDrawRichText in fpsvisualutils. Don't be scared, it is huge, but the main painting operation occurs in the local procedure DrawLine, and there are also some coordinate calculations below in the sections commented by "2a)..." and "2b)..." Be careful that RTL must work also with rotated text; you can create a cell with rotated text by

Code: Pascal  [Select][+][-]
  1. Grid.Cells[1,1] := 'Text';
  2. Grid.TextRotation[1,1] := rt90DegreeClockwiseRotation;
  3.   // or rt90DegreeCounterClockwiseRotation
  4.   // or: rtStacked
  5.  

After that we should look at DrawRow, another "monster", sorry, but there is another clipping rectangle which prevents painting of the cells at the left in RTL mode. Your testing code should have ShowHeaders=true, otherwise you won't see this.

It looks that seeking for that ColRowToOffset is a good idea for finding the points which have to be modified.
« Last Edit: January 22, 2016, 12:08:51 am by wp »

shobits1

  • Sr. Member
  • ****
  • Posts: 271
  • .
Re: How to make gap between lines in StringGrid
« Reply #32 on: January 22, 2016, 04:28:48 am »
I have created new thread to continue discussion; hope the title is good (I really suck at this  :-[ )

Making fpSpreadsheetGrid RTL Compatible

 

TinyPortal © 2005-2018