Recent

Author Topic: TStringGrid with BiDiMode:= bdRightToLeft does not work.  (Read 9733 times)

Avishai

  • Hero Member
  • *****
  • Posts: 1021
TStringGrid with BiDiMode:= bdRightToLeft does not work.
« on: March 04, 2011, 06:03:21 pm »
TStringGrid with BiDiMode:= bdRightToLeft and SysLocale.MiddleEast:= True does not work. It is completely unusable.  Any help would be very much appreciated.
Lazarus Trunk / fpc 2.6.2 / Win32

ik

  • Jr. Member
  • **
  • Posts: 88
  • ik
    • LINESIP
Re: TStringGrid with BiDiMode:= bdRightToLeft does not work.
« Reply #1 on: March 08, 2011, 11:50:11 am »
SysLocale is ignored in Lazarus because it is not compatible with other operating systems.


I'm yet to understand what exactly are the problems you have, and why you keep on creating your own Bidi support. can you please upload an image and a proof of concept code of what you are trying to do ?

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: TStringGrid with BiDiMode:= bdRightToLeft does not work.
« Reply #2 on: March 08, 2011, 01:47:44 pm »
BiBiMode depends on SysLocale.  It's used by many objects in Delphi and in Lazarus to determine how to draw and respond to different Languages like Hebrew and Arabic that are not Left to Right languages.  In Hebrew we read and write from Right to Left except for numbers that go from Left to Right.  That's why it's called a Bi-Directional language.

If you set SysLocale.MiddleEast:= True and add a TStringGrid to a Form and set it's BiDiMode to bdRightToLeft, you will see that it mirrors the grid so that it is Right to Left, only it gets very flaky.  If you do the same with a TEdit, it will also mirror, only it works properly.  The image I have attached does not use a StringGrid because it is unusable at present.

SysLocale is declared in SysInth.inc as follows.

type
  TSysLocale = record
    { Delphi compat fields}
    DefaultLCID,
    PriLangID,
    SubLangID  : Integer;

    case byte of
      { win32 names }
      1 : (FarEast: boolean; MiddleEast: Boolean);
      { real meaning }
      2 : (MBCS : boolean; RightToLeft: Boolean);
  end;

var
  SysLocale : TSysLocale;
Lazarus Trunk / fpc 2.6.2 / Win32

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: TStringGrid with BiDiMode:= bdRightToLeft does not work.
« Reply #3 on: March 08, 2011, 01:59:26 pm »
It looks like you may be right.  SysLocale seems to have no effect on the BiDiMode.  That means I can delete a line from the code.
Lazarus Trunk / fpc 2.6.2 / Win32

ik

  • Jr. Member
  • **
  • Posts: 88
  • ik
    • LINESIP
Re: TStringGrid with BiDiMode:= bdRightToLeft does not work.
« Reply #4 on: March 08, 2011, 02:11:39 pm »
Avishai, I'm a native Hebrew speaker like yourself, and I research the Bidi issue for more then 11 years now, so I know a lot regarding Hebrew and other languages that require Bi-Directional support.

SysLocale record is initialized only in MS-Windows, so it's not a cross platform record.

Claiming that all middle east languages are right to left is wrong. some of them are written in Latin letters today, and latin is written from left to right, so only the RightToLeft field should be used, but as I said, it's very Windows oriented and Lazarus is a cross platform environment that is created in the mindset of writing more general code rather then specific environment specific code. That's why the LCL support so many widgets on many systems, and that's why we mostly recommend not to use specific API unless you must use it.

I still do not understand the problem/bug you have with BiDiMode, and what you are trying to do exactly that was not given to you. As I see, the Hebrew with the punctuation (ניקוד) are written properly from right to left,  and so does the grid seems to be from right to left.
« Last Edit: March 08, 2011, 02:15:32 pm by ik »

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: TStringGrid with BiDiMode:= bdRightToLeft does not work.
« Reply #5 on: March 08, 2011, 02:35:58 pm »
I'm Israeli and living in Tel Aviv, but I'm not a native Hebrew speaker :(  I wish I was.  I didn't claim that all Middle Eastern languages are Right To Left.  I gave examples of Hebrew and Arabic that are Bi-directional.  Also, I'm hoping that you won't be the only one reading my post and some of them might not be aware of Bi-directional languages and the difficulties we have dealing with them in the computer world.  In the mean time, I just noticed that TMenu doesn't seem to respond to BiDiMode, but I haven't looked into it yet.

The "Grid" you are seeing is NOT a TStringGrid.  It's a combination of Nested TPanels, Tedits, and TSplitters.  A horrible workaround.  If you try using a TStringGrid with BiDiMode:= bdRightToLeft, perhaps you will see what I'm talking about.  The Grid mirrors as it should, but editing cells has not worked out well for me.  I get text that is at different heights in the same cell, erratic cell movement, cell contents jumping to other cells...  I tried it on a new application where it was the only component and no code written by me and the behavior was the same.  I hope you are having better luck with it.
Lazarus Trunk / fpc 2.6.2 / Win32

ik

  • Jr. Member
  • **
  • Posts: 88
  • ik
    • LINESIP
Re: TStringGrid with BiDiMode:= bdRightToLeft does not work.
« Reply #6 on: March 08, 2011, 03:11:33 pm »
I'm a Linux user, and here is what I have in GTK2 on my Linux machine (KDE 4.6.1).

Can you please provide an image from your Windows so it will be easier for me to see the problem you are having ?

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: TStringGrid with BiDiMode:= bdRightToLeft does not work.
« Reply #7 on: March 08, 2011, 03:22:53 pm »
Thank you so much for taking the time to investigate this, but I don't see how a screen shot can show cell movement, disappearing cursor or text moving from Cell[2,4] to Cell[3,2] after exiting Cell[2,4].

I mentioned the Tmenu not responding to BiDiMode but that I hadn't looked it to it yet.  When I changed the first menu item to Hebrew, it mirrored just fine.
Lazarus Trunk / fpc 2.6.2 / Win32

Zaher

  • Hero Member
  • *****
  • Posts: 683
    • parmaja.org
Re: TStringGrid with BiDiMode:= bdRightToLeft does not work.
« Reply #8 on: March 08, 2011, 04:54:28 pm »
Grid not competed yet, i must look at it to complete it.
In Delphi it depend on flip/mirror the canvas, it is not found in Lazarus not good supported by the all platforms.
i made it by flip the drawing lines and cells, and need more work on it.

 

TinyPortal © 2005-2018