View Issue Details

IDProjectCategoryView StatusLast Update
0016516LazarusIDEpublic2010-05-31 08:50
ReporterIdo KannerAssigned ToMattias Gaertner 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version0.9.29 (SVN)Product Build 
Target VersionFixed in Version 
Summary0016516: A Patch to make the IDE display the interface from right to left, when the language require it
DescriptionI've created a first patch (there will be more in this subject) that makes the main IDE application to display things from Right To Left when the TApplication uses the proper language.

This patch also add support to TApplication and TCustomForm for auto detecting that information.

The TApplication is using the system language to detect the order.

The TCustomForm detects the TApplication direction and change itself to it's default.

The IDE decide the direction using the given language of environment.
Tagsbidi
Fixed in Revision
LazTarget-
Widgetset
Attached Files
  • bidi_ide1.patch (3,094 bytes)
    Index: ide/main.pp
    ===================================================================
    --- ide/main.pp	(revision 25511)
    +++ ide/main.pp	(working copy)
    @@ -1211,6 +1211,8 @@
           EnvironmentOptions.Lazarusdirectory:= Application.GetOptionValue('lazarusdir');
         end;
     
    +    Application.BidiMode := Application.Direction(EnvironmentOptions.LanguageID);
    +
         TranslateResourceStrings(EnvironmentOptions.LazarusDirectory,
                                  EnvironmentOptions.LanguageID);
     
    Index: lcl/forms.pp
    ===================================================================
    --- lcl/forms.pp	(revision 25511)
    +++ lcl/forms.pp	(working copy)
    @@ -1375,6 +1375,9 @@
         procedure IntfAppRestore;
         procedure IntfDropFiles(const FileNames: Array of String);
         procedure IntfThemeOptionChange(AThemeServices: TThemeServices; AOption: TThemeOption);
    +
    +    function IsRTLLang(ALang: String): Boolean;
    +    function Direction(ALang: String): TBiDiMode;
       public
         procedure DoArrowKey(AControl: TWinControl; var Key: Word;
           Shift: TShiftState);
    Index: lcl/include/customform.inc
    ===================================================================
    --- lcl/include/customform.inc	(revision 25511)
    +++ lcl/include/customform.inc	(working copy)
    @@ -1905,6 +1905,10 @@
       FloatingDockSiteClass := TWinControlClass(ClassType);
       Screen.AddForm(Self);
       FAllowDropFiles := False;
    +
    +  // Inherit by default the bidi mode of the application
    +  BiDiMode := Application.BidiMode;
    +
       // the EndFormUpdate is done in AfterConstruction
     end;
     
    Index: lcl/include/application.inc
    ===================================================================
    --- lcl/include/application.inc	(revision 25511)
    +++ lcl/include/application.inc	(working copy)
    @@ -85,15 +85,6 @@
            TApplication Constructor
     ------------------------------------------------------------------------------}
     constructor TApplication.Create(AOwner: TComponent);
    -const
    -  BidiModeMap: array[Boolean] of TBiDiMode = (bdLeftToRight, bdRightToLeft);
    -
    -  function IsRTLLang(ALang: String): Boolean;
    -  begin
    -    Result := (ALang = 'ar') or
    -              (ALang = 'he');
    -  end;
    -
     var
       LangDefault, LangFallback: String;
     begin
    @@ -128,9 +119,9 @@
       {$ifndef wince}// remove ifdef when gettext is fixed
       LCLGetLanguageIDs(LangDefault, LangFallback);
       if LangDefault <> '' then
    -    FBidiMode := BidiModeMap[IsRTLLang(LangDefault)]
    +    FBidiMode := Direction(LangDefault)
       else
    -    FBidiMode := BidiModeMap[IsRTLLang(LangFallback)];
    +    FBidiMode := Direction(LangFallback);
       {$else}
         FBidiMode := bdLeftToRight;
       {$endif}
    @@ -2228,3 +2219,17 @@
       Result := False;
       if Assigned(FOnActionUpdate) then FOnActionUpdate(TheAction, Result);
     end;
    +
    +function TApplication.IsRTLLang(ALang: String): Boolean;
    +begin
    +  Result := (LowerCase(ALang) = 'ar') or
    +            (LowerCase(ALang) = 'he');
    +end;
    +
    +function TApplication.Direction(ALang: String): TBiDiMode;
    +const
    +  BidiModeMap: array[Boolean] of TBiDiMode = (bdLeftToRight, bdRightToLeft);
    +begin
    +  Result := BidiModeMap[IsRTLLang(ALang)];
    +end;
    +
    
    bidi_ide1.patch (3,094 bytes)
  • lazarus-bidi.png (28,200 bytes)
    lazarus-bidi.png (28,200 bytes)
  • lazarus-nonbidi.png (30,092 bytes)
    lazarus-nonbidi.png (30,092 bytes)

Activities

2010-05-19 12:49

 

bidi_ide1.patch (3,094 bytes)
Index: ide/main.pp
===================================================================
--- ide/main.pp	(revision 25511)
+++ ide/main.pp	(working copy)
@@ -1211,6 +1211,8 @@
       EnvironmentOptions.Lazarusdirectory:= Application.GetOptionValue('lazarusdir');
     end;
 
+    Application.BidiMode := Application.Direction(EnvironmentOptions.LanguageID);
+
     TranslateResourceStrings(EnvironmentOptions.LazarusDirectory,
                              EnvironmentOptions.LanguageID);
 
Index: lcl/forms.pp
===================================================================
--- lcl/forms.pp	(revision 25511)
+++ lcl/forms.pp	(working copy)
@@ -1375,6 +1375,9 @@
     procedure IntfAppRestore;
     procedure IntfDropFiles(const FileNames: Array of String);
     procedure IntfThemeOptionChange(AThemeServices: TThemeServices; AOption: TThemeOption);
+
+    function IsRTLLang(ALang: String): Boolean;
+    function Direction(ALang: String): TBiDiMode;
   public
     procedure DoArrowKey(AControl: TWinControl; var Key: Word;
       Shift: TShiftState);
Index: lcl/include/customform.inc
===================================================================
--- lcl/include/customform.inc	(revision 25511)
+++ lcl/include/customform.inc	(working copy)
@@ -1905,6 +1905,10 @@
   FloatingDockSiteClass := TWinControlClass(ClassType);
   Screen.AddForm(Self);
   FAllowDropFiles := False;
+
+  // Inherit by default the bidi mode of the application
+  BiDiMode := Application.BidiMode;
+
   // the EndFormUpdate is done in AfterConstruction
 end;
 
Index: lcl/include/application.inc
===================================================================
--- lcl/include/application.inc	(revision 25511)
+++ lcl/include/application.inc	(working copy)
@@ -85,15 +85,6 @@
        TApplication Constructor
 ------------------------------------------------------------------------------}
 constructor TApplication.Create(AOwner: TComponent);
-const
-  BidiModeMap: array[Boolean] of TBiDiMode = (bdLeftToRight, bdRightToLeft);
-
-  function IsRTLLang(ALang: String): Boolean;
-  begin
-    Result := (ALang = 'ar') or
-              (ALang = 'he');
-  end;
-
 var
   LangDefault, LangFallback: String;
 begin
@@ -128,9 +119,9 @@
   {$ifndef wince}// remove ifdef when gettext is fixed
   LCLGetLanguageIDs(LangDefault, LangFallback);
   if LangDefault <> '' then
-    FBidiMode := BidiModeMap[IsRTLLang(LangDefault)]
+    FBidiMode := Direction(LangDefault)
   else
-    FBidiMode := BidiModeMap[IsRTLLang(LangFallback)];
+    FBidiMode := Direction(LangFallback);
   {$else}
     FBidiMode := bdLeftToRight;
   {$endif}
@@ -2228,3 +2219,17 @@
   Result := False;
   if Assigned(FOnActionUpdate) then FOnActionUpdate(TheAction, Result);
 end;
+
+function TApplication.IsRTLLang(ALang: String): Boolean;
+begin
+  Result := (LowerCase(ALang) = 'ar') or
+            (LowerCase(ALang) = 'he');
+end;
+
+function TApplication.Direction(ALang: String): TBiDiMode;
+const
+  BidiModeMap: array[Boolean] of TBiDiMode = (bdLeftToRight, bdRightToLeft);
+begin
+  Result := BidiModeMap[IsRTLLang(ALang)];
+end;
+
bidi_ide1.patch (3,094 bytes)

2010-05-19 12:53

 

lazarus-bidi.png (28,200 bytes)
lazarus-bidi.png (28,200 bytes)

2010-05-19 12:53

 

lazarus-nonbidi.png (30,092 bytes)
lazarus-nonbidi.png (30,092 bytes)

Mattias Gaertner

2010-05-19 13:12

manager   ~0037770

Thanks. Applied with small modification.

Issue History

Date Modified Username Field Change
2010-05-19 12:49 Ido Kanner New Issue
2010-05-19 12:49 Ido Kanner File Added: bidi_ide1.patch
2010-05-19 12:53 Ido Kanner File Added: lazarus-bidi.png
2010-05-19 12:53 Ido Kanner File Added: lazarus-nonbidi.png
2010-05-19 13:12 Mattias Gaertner LazTarget => -
2010-05-19 13:12 Mattias Gaertner Note Added: 0037770
2010-05-19 13:12 Mattias Gaertner Assigned To => Mattias Gaertner
2010-05-19 13:12 Mattias Gaertner Status new => resolved
2010-05-19 13:12 Mattias Gaertner Resolution open => fixed
2010-05-19 16:47 Zaher Dirkey Tag Attached: bidi
2010-05-31 08:50 Ido Kanner Status resolved => closed