Recent

Author Topic: Add support "Bidi Mode"/"Right to left"  (Read 25250 times)

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
Add support "Bidi Mode"/"Right to left"
« on: May 09, 2007, 12:15:47 pm »
Hi, i started to make a arabic Win32 project, and need to add some patches to Lazarus source for support "Bidi Mode"/"Right to left"
I know it not easy to trust my code, i am still new with you, but i will try make small peaces of the patches to make you under stand it.

Now, what the strategy of lazarus

- Make it full compatible with Delphi
- Nop, just make it more flexible and logical

To understand me

1 - From Delphi 4, Delphi make a property in TControl

   TBiDiMode = (bdLeftToRight, bdRightToLeft, bdRightToLeftNoAlign, bdRightToLeftReadingOnly);

But after more than 10 years with many projects i am used only (bdLeftToRight, bdRightToLeft) and i use Alignment property instead of other values of BidiMode

2 - If we look at VC or VB from Microsoft we will find

RightToLeft:Boolean

3 - in HTML/CSS thay are useing Direction = ["rtl"|"ltr"|""]

When i asked my friends/co workers thay all prefer as HTML/CSS way, that add property to TControl named "Direction" and it declare as

TDirection = (dirDefault, dirLeftToRight, dirRightToLeft);

dirDefault: to remove ParentBidiMode/ParentDirection property and it is mean in HTML/CSS (inherite the value from the parent).

---------
I will choose the Third way to add Right To Left support, but before i start, i need to your acceptation.

Thanks

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Add support "Bidi Mode"/"Right to left&qu
« Reply #1 on: May 09, 2007, 03:17:32 pm »
Quote from: "zaher"
Now, what the strategy of lazarus

- Make it full compatible with Delphi
- Nop, just make it more flexible and logical


It's both. Lot's of people want it as compatible as possible to write software that can be compiled with both.

On the other hand we have already broken compatibility on some large parts. Our help system for example, is a new creation, and thus completely incompatible.

And we are also moving (slowly) to UTF-8 support, which will also be incompatible.

I would say that the guidelines are: Be compatible whenever possible. Only break compatibility if the delphi system is really unsuitable for us.

About your proposal, well the Delphi type does look a little wierd.

Maybe we could have a hybrid solution. Keeping the names similar and partially compatible, but modifying to make it better.

Something like:

   TBiDiMode = (dbDefault, bdLeftToRight, bdRightToLeft);

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #2 on: May 09, 2007, 05:18:54 pm »
The help integration is not something directly bound to the VCL so that we do things different there, is not a problem.

In all cases we try to keep the LCL as compatible as possible to the VCL.
This means that will be TBiDiMode = (bdLeftToRight, bdRightToLeft, bdRightToLeftNoAlign, bdRightToLeftReadingOnly);
We are not going to invent incompatible properties here.

As a start, you can implement bdLeftToRight, bdRightToLeft
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #3 on: May 11, 2007, 12:52:12 pm »
I take the idea, i will use

TBiDiMode = (bdDefault, bdLeftToRight, bdRightToLeft);

bdDefault is a default value and bdLeftToRight is the default value in Delphi so it is compatible because the both of value not loaded, but if we convert a RTL application that thay use bdRightToLeft, that still compatible in both project.

I will start with TEdit, TButton to understand the Widgets, becuase not all platforms support RTL, and there is a TLabel it is a simple Graphic control.

You can look to "Bidi Inno setup" as sample how i am worked
http://www.parmaja.com/projects/innosetup/

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #4 on: May 14, 2007, 03:25:08 pm »
please, don't change enums. Keep the same names and the same order.  This will break hard and is difficult to trace.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #5 on: May 14, 2007, 04:54:20 pm »
Yes Marc, that was i am thinking about it today when i am surfing the source, and i still need some discusses.
Because there is some old BidiMode properties commented.

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #6 on: May 15, 2007, 10:57:56 am »
1 - There is already TBiDiMode

  TBiDiMode = (bdLeftToRight,bdRightToLeft,bdRightToLeftNoAlign,bdRightToLeftReadingOnly);

in file
\fpcsource\rtl\objpas\classes\classesh.inc

Is that the right place? or i must ignore it.
i think TBiDiMode a (GUI or visual control) must be in Controls.pas

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #7 on: May 15, 2007, 11:36:04 am »
if there is one already defined in fpc, there is no need to redefine it.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #8 on: May 20, 2007, 12:51:47 am »
Hi again, i need some advices
- Is i must make patch file and send it to tracker.
- or just put my code lines here and you take it after reviewing it.

I worked with svn about 2 years at my work, but without making patches, so i am not sure about it

Where i can put the road map for my work, i will post it temporary here (i will move it to where you say)


EDIT:
   http://wiki.lazarus.freepascal.org/BidiMode

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #9 on: May 20, 2007, 12:57:43 am »
Forgive me if i make myself as silly student :P but i believe any of touch the code will make it unstable.

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #10 on: May 21, 2007, 03:21:49 am »
1. You can use wiki to create new page with your roadmap.
2. If you are using tortoise svn, just look at menu Create Patch.

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #11 on: May 27, 2007, 12:17:08 pm »
Hi, I created the page but i am not good writer (especially in English), and created the patch (Tortoise svn).
My ask can i apply the my patch for new updated lazarus source? i want to keep update with it.

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #12 on: May 28, 2007, 11:16:35 am »
I applied your patch with changes. Look at TWSWinControl.SetBiDiMode and SetBiDiMode in TWin32WSButton and TWin32WSCustomEdit classes.

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #13 on: May 30, 2007, 12:40:18 pm »
Thank to add TWSWinControl.SetBiDiMode;

I replaced RecreateWnd with SetWindowLong

For example
Code: [Select]

class procedure TWin32WSButton.SetBiDiMode(const AWinControl: TWinControl;
  const ABiDiMode: TBiDiMode);
begin
  RecreateWnd(AWinControl);
end;


to

Code: [Select]

class procedure TWin32WSButton.SetBiDiMode(const AWinControl: TWinControl;
  const ABiDiMode: TBiDiMode);
var
  FlagsEx: dword;
begin
  if not WSCheckHandleAllocated(AWinControl, 'SetBidiMode') then Exit;

  FlagsEx := GetWindowLong(AWinControl.Handle, GWL_EXSTYLE) and not (WS_EX_RTLREADING);
  if AWinControl.UseRightToLeftReading then
    FlagsEx := FlagsEx or WS_EX_RTLREADING;
  SetWindowLong(AWinControl.Handle, GWL_EXSTYLE, FlagsEx);
end;


Next weekend (Friday in my country) i will to make patch for Menus and other std controls

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
RE: Re: Add support "Bidi Mode"/"Right to lef
« Reply #14 on: May 30, 2007, 01:06:47 pm »
Ok, then add it to bug tracker as patch after.

 

TinyPortal © 2005-2018