DelphiDelphiVCLPythonPython GUIWindows

What Are Bi-Directional Properties In DelphiVCL Applications?

What Are Bi Directional Properties In DelphiVCL Applications

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

StandardAdditionalWin32Data ControlsOther classes
TButton
TCheckBox
TComboBox
TEdit
TGroupBox
TLabel
TListBox
TMainMenu
TMemo
TPanel
TPopupMenu
TRadioButton
TRadioGroup
TScrollBar
TActionMainMenuBar
TActionToolBar
TBitBtn
TCheckListBox
TColorBox
TDrawGrid
TLabeledEdit
TMaskEdit
TScrollBox
TSpeedButton
TStaticLabel
TStaticText
TStringGrid
TValueListEditor
TComboBoxEx
TDateTimePicker
THeaderControl
THotKeyTListView
TMonthCalendar
TPageControl
TRichEdit
TStatusBar
TTabControl
TTreeView
TDBCheckBox
TDBComboBox
TDBEdit
TDBGrid
TDBListBox
TDBLookupComboBox
TDBLookupListBox
TDBMemo
TDBRadioGroup
TDBRichEdit
TDBText
TApplication (has no ParentBiDiMode)
TBoundLabelTControl (has no ParentBiDiMode)
TCustomHeaderControl (has no ParentBiDiMode)
TFormTFrameTHeaderSectionTHintWindow (has no ParentBiDiMode)
Menu
TStatusPanel

Note: THintWindow picks up the BiDiMode of the control that activated the hint.

 

BiDiMode Property

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:

What Are Bi Directional Properties In DelphiVCL Applications Table of BiDi types

 

ParentBiDiMode Property

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.

 

FlipChildren Method

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

MethodDescription
OkToChangeFieldAlignmentUsed with database controls. Checks to see if the alignment of a control can be changed.
DBUseRightToLeftAlignmentA wrapper for database controls for checking alignment.
ChangeBiDiModeAlignmentChanges 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.
IsRightToLeftReturns True if any of the right to left options are selected. If it returns False the control is in left to right mode.
UseRightToLeftReadingReturns True if the control is using right to left reading.
UseRightToLeftAlignmentReturns True if the control is using right to left alignment. It can be overridden for customization.
UseRightToLeftScrollBarReturns True if the control is using a left scroll bar.
DrawTextBiDiModeFlagsReturns the correct draw text flags for the BiDiMode of the control.
DrawTextBiDiModeFlagsReadingOnlyReturns the DT_RTLREADING flag or 0, depending on the value returned from the UseRightToLeftReading method.
AddBiDiModeExStyleAdds 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.

Related posts
CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And NumPy Library?

CodeIDEProjectsPythonWindows

Unlock the Power of Python for Deep Learning with Generative Adversarial Networks (GANs) - The Engine behind DALL-E

CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And Matplotlib Library?

CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And Pillow Library?

Leave a Reply

Your email address will not be published. Required fields are marked *