The Technology

When the Arabic and Hebrew versions of Microsoft Windows 95 were localized, a mechanism known as "flipping" was used to provide the UI with a right-to-left look and feel. With flipping, items in a dialog box were repositioned within a dialog template so that UI elements would have a natural flow. However, this partial solution did not address layout problems for such items as title bars, tree views, or combo boxes. It merely repositioned these items within the flipped dialog box. To resolve the remaining issues that flipping was unable to address, the mirroring technology was introduced in the Arabic and Hebrew versions of Microsoft Windows 98. However, since Microsoft Windows 2000 and Microsoft Windows XP provide underlying support for layout, and since both operating systems are single binaries, mirroring is now available on all language versions of Windows 2000 and later. It is activated at the application level.

Figure 8.1 - An Arabic Windows XP desktop in which each UI element is mirrored.

The code modifications required to mirror UI windows, while not trivial, were less extensive than you might think. The Bidirectional (BiDi) Windows 98 development team first designed an architecture and programming interface to make most of the layout more or less automatic. The basis of this architecture is a simple coordinate transformation: the origin of a window changes from the upper-left corner to the upper-right corner, and the x scale factor changes such that x values increase from right to left, rather than from left to right. (See Figure 8-2.) Also, by mirroring a window, you can affect how text is rendered within that window. A mirrored window gets a caption that is rendered in RTL direction; the same applies to labels, button captions, and text on menus. Win32 application programming interfaces (APIs) hide implementation details, transparently allowing applications to take advantage of the same mirroring functionality that the system uses.

Figure 8.2 - The architecture for mirroring is based on a coordinate transformation.

When mirroring Win32 applications, you can either choose to enable mirroring in your resources or in your code. The following sections describe both of these methods and show the circumstances under which you would generally use each method. You will also see how to mirror property sheets, what to consider when mapping coordinates, how to handle direction-sensitive graphics, and how to work with image-list controls.