Table of Contents
What is Bi-Directional (BiDi)?
Some languages do not follow the left to right reading order commonly found in Western languages, but rather use the right to left reading order for words and the left to right reading order for numbers. These languages are termed bi-directional (BiDi) because of this separation. The most common bi-directional languages are Arabic and Hebrew, although other Middle East languages are also bi-directional.
The VCL supports bi-directional localization through the BiDiMode and ParentBiDiMode properties. TApplication has two properties, BiDiKeyboard and NonBiDiKeyboard, that allow you to specify the keyboard layout in the IDE software.
VCL Objects that Support BiDi
|Standard||Additional||Win32||Data Controls||Other classes|
|TApplication (has no ParentBiDiMode)|
TBoundLabelTControl (has no ParentBiDiMode)
TCustomHeaderControl (has no ParentBiDiMode)
TFormTFrameTHeaderSectionTHintWindow (has no ParentBiDiMode)
Note: THintWindow picks up the BiDiMode of the control that activated the hint.
The BiDiMode property controls the reading order for the text, the placement of the vertical scrollbar, and whether the alignment is changed. Controls that have a text property, such as Name, display the BiDiMode property on the Object Inspector.
The BiDiMode property belongs to the TBiDiMode enumerated type. TBiDiMode has four states: bdLeftToRight, bdRightToLeft, bdRightToLeftNoAlign, and bdRightToLeftReadingOnly:
ParentBiDiMode is a Boolean property. When True (the default) the control looks to its parent to determine what BiDiMode to use. If the control is a TForm object, the form uses the BiDiMode setting from Application. If all the ParentBiDiMode properties are True, when you change Application’s BiDiMode property, all forms and controls in the project are updated with the new setting.
The FlipChildren method allows you to flip the position of a container control’s children. Container controls are controls that can contain other controls. Container controls are such as TForm, TPanel, and TGroupBox. FlipChildren has a single boolean parameter AllLevels. When AllLevels is False, only the immediate children of the container control are flipped. When AllLevels is True, children of all levels in the container control are flipped.
Delphi flips the controls by changing the Left property and the alignment of the control. If a control’s left side is five pixels from the left edge of its parent control, after it is flipped the edit control’s right side is five pixels from the right edge of the parent control. If the edit control is left-aligned, calling FlipChildren will make the control right-aligned.
To flip a control at design-time select Edit > Flip Children and select either All or Selected, depending on whether you want to flip all the controls or just the children of the selected control. You can also flip controls in a container control by selecting the container control on the form, right-clicking, and selecting Flip Children from the context menu.
Note: Selecting an edit control and issuing a Flip Children > Selected command does nothing. This is because edit controls are not containers.
Other Methods useful for Bi-Directional Functionality
There are several other methods useful for developing applications for bi-directional users.
VCL Methods Supporting BiDi
|OkToChangeFieldAlignment||Used with database controls. Checks to see if the alignment of a control can be changed.|
|DBUseRightToLeftAlignment||A wrapper for database controls for checking alignment.|
|ChangeBiDiModeAlignment||Changes the alignment parameter passed to it. No check is done for the BiDiMode setting, it just converts left alignment into right alignment and vice versa.|
|IsRightToLeft||Returns True if any of the right to left options are selected. If it returns False the control is in left to right mode.|
|UseRightToLeftReading||Returns True if the control is using right to left reading.|
|UseRightToLeftAlignment||Returns True if the control is using right to left alignment. It can be overridden for customization.|
|UseRightToLeftScrollBar||Returns True if the control is using a left scroll bar.|
|DrawTextBiDiModeFlags||Returns the correct draw text flags for the BiDiMode of the control.|
|DrawTextBiDiModeFlagsReadingOnly||Returns the DT_RTLREADING flag or 0, depending on the value returned from the UseRightToLeftReading method.|
|AddBiDiModeExStyle||Adds the appropriate ExStyle flags to the control that is being created.|
Check out DelphiVCL which easily allows you to build GUIs for Windows using Python.