Saturday, October 14, 2006

Right-To-Left layout (RTL) support in wxWidgets

Here is some information about the support for locales with right-to-left (RTL) layout out in wxWidgets. As you probably know, RTL-support is required mostly of Hebrew, Arabic and Farsi. It has been decided that wxWidgets should follow mostly the Windows API and Windows approach for displaying RTL text and layout in applications. This approach is described in a document at MSDN here. In short, all coordinates for drawing and for window positioning are mirrored horizontally which means that (apart from bitmap mirroring) little has to be done at the user level. Also, the various native Win32 controls are modified to support RTL design.

This is different from what is done under GTK+, where no coordinates are mirrored. Instead, every app needs to mirror everything itself, even if the job of mirroring controls is mostly done within GTK+'s layout container automatically. As far as drawing within wxWidgets is concerned, coordinates are mirrored at the wxDC level in the GTK+ port. Some more information about GTK's RTL support can be found here.

I have added two screenshots from the popular FileZilla application running in the "ar_EG" (Egyptian variant of Arab) locale (screenshots in parts thanks to Tim Kosse). Since the tree control in the Linux screenshot is using generic wxWidgets code, this also demonstrates how drawing and scrolling is mirrored for user windows.

Below is a screenshot using wxWidgets and GTK 2.4.9.














Here is roughly the same screenshot using Windows 2000.

6 comments:

Anonymous said...

Letters aren't connected in the Linux version.. wonder why

Anonymous said...

Hey I can't get to the www.wxwidgets.org website... Is it down?

Ryan Norton said...

Evidently the vhost is down - see
http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi?8:mss:94497:200610:ldnpgpadohaenmhjkbkj

Ryan Norton said...

Robert, do you know if the native GTKTreeView/wxDataViewCtrl has built-in support for this as well? Good post BTW! :D

- said...

I just wanted to thank you for the great work on RTL support and hope that you continue the good work and also thank Tim for the great patches and even bothering himself with RTL support making Filezilla to be one(if not the only one) of the best RTL supported software out there and more importantly ... whoever is going to use wxWidgets from now on will have support for RTL .. right? ...

Anonymous said...

Is RTL support only available in the CVS version or in the 2.7.1 version as well?