Opened 11 months ago

Closed 5 months ago

Last modified 5 months ago

#15797 closed defect (fixed)

wxPropertyGrid: Text mirrored with RTL languages (MSW)

Reported by: ghenne Owned by: AW
Priority: normal Milestone:
Component: wxPropertyGrid Version: 3.0.0
Keywords: rtl Cc:
Blocked By: Blocking:
Patch: no

Description

(Note: this brings over an old, old problem from sourceForge that I could not find in wxTrax: http://sourceforge.net/p/wxpropgrid/bugs/147/. Last comment from Jaakko Salli, 2010-10-03 was "Thanks for pointing this out (or rather reminding me of the issue...). I really should look into making wxPropertyGrid properly RTL-language compliant." It's a real issue now.)

Content is mirrored on Windows when system language is an RTL (right-to-left) language (e.g. Hebrew, Arabic and Farsi)
I guess this is because Windows mirrors every DC by default when system language is RTL.

When DC mirroring would be switched off in propgrid.cpp void wxPropertyGrid::DrawItems(...):
dc.SetLayoutDirection(wxLayout_LeftToRight);
then text would be at least not mirrored.

However, now the logic of the control would be left-to-right too (e.g. scrollbar on the right), instead of right-to-left, as other controls.
Also, there might be problems with word ordering, but I can't tell for sure as I don't know Hebrew at all.

Attachments (4)

rtl.png download (25.7 KB) - added by ghenne 11 months ago.
rtlMac.png download (18.6 KB) - added by ghenne 11 months ago.
0001-RTL.2.patch download (780 bytes) - added by ZaneUJi 7 months ago.
Patch
0001-RTL.patch download (780 bytes) - added by ZaneUJi 7 months ago.
Patch

Download all attachments as: .zip

Change History (18)

comment:1 Changed 11 months ago by vadz

  • Milestone 3.0.1 deleted
  • Priority changed from blocker to normal
  • Status changed from new to infoneeded_new

Sorry, why is it wrong to mirror text in wxPG when using the RTL language? Isn't this what we actually want?

IOW, what exactly is the problem currently?

comment:2 Changed 11 months ago by ghenne

  • Status changed from infoneeded_new to new


comment:3 Changed 11 months ago by vadz

  • Resolution set to wontfix
  • Status changed from new to closed

We don't support mixing LTR and RTL strings inside the same control... We'd need to add the new API to specify the layout direction of each cell to allow doing this and somehow find the information to call it with. How exactly do you imagine it would work?

Also, this is surely not wxPG-specific as the same problem would occur with wxGrid, wxDVC or probably even a humble wxListBox if you put Arabic and English strings into it: some of them will come wrongly.

So I don't see what else can we do other than saying that this is not supported.

comment:4 Changed 11 months ago by ghenne

Hmm... Did you notice that the Arabic characters are also mirrored?

How can anyone in an RTL country use these controls?

comment:5 Changed 11 months ago by ghenne

  • Resolution wontfix deleted
  • Status changed from closed to reopened

comment:6 Changed 11 months ago by vadz

  • Status changed from reopened to infoneeded_new

Err, no, I don't read Arabic and the screenshot resolution is very low anyhow so I'm not sure I would be able to see it even if I could.

Can anyone please confirm that Arabic is really rendered incorrectly here? I.e. is it different from putting the same string in wxStaticText?

Changed 11 months ago by ghenne

comment:7 Changed 11 months ago by ghenne

  • Status changed from infoneeded_new to new

Image updated with higher resolution. Some text, properly formatted, also appears now.

comment:8 Changed 11 months ago by vadz

I don't know what's going on here if it's really mirrored (sorry but I still can't tell, it would be helpful to have the same text outside and inside wxPG, otherwise I don't see how could you tell it without actually knowing the language).

In any case, there doesn't seem to be any explicit mirroring done anywhere in wxPG code, so this is pretty mysterious. Does this happen under all platforms?
Also, what if you put the same text in wxStaticText and wxGenericStaticText, does it show up correctly in the latter?

Changed 11 months ago by ghenne

comment:9 Changed 11 months ago by ghenne

Here's the same image when running on a Mac. In this case, everything is OK. There is not mirroring: both the English and Arabic text looks OK. Does this help?


comment:10 Changed 11 months ago by vadz

I must be blind but I don't understand which of the text in the grid corresponds to the text under "Form"?

Also, the Mac screenshot still seems wrong to me as Arabic text is not right-aligned and AFAIU it should be.

comment:11 Changed 11 months ago by ghenne

Sorry - the text under "Form" is not in the grid, but the box underneath it. Notice it is the right way around.

I checked with users in an Arabic country. They agree with you: the Mac version is wrong in that the text is not right aligned.

So, to summarize:

On Windows, the characters are mirrored, but justified correctly.

On Mac, the characters appear properly, but are not justified correctly.

Changed 7 months ago by ZaneUJi

Patch

Changed 7 months ago by ZaneUJi

Patch

comment:12 Changed 7 months ago by ZaneUJi

Please ignore 0001-RTL.2.patch. I have a network problem.

comment:13 Changed 5 months ago by AW

  • Owner set to AW
  • Resolution set to fixed
  • Status changed from new to closed

In 76931:

When drawing wxPG items (with double buffering) use the same layout direction as the window uses.

Memory DC used for double buffering purposes should inherit layout direction from the window DC to ensure that texts are rendered correctly.

Closes #15797.

comment:14 Changed 5 months ago by awi

@ZaneUJi,
Thanks for the patch!

Note: See TracTickets for help on using tickets.