Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-12

Looking for help: Trying to add better RightToLeft support to Lazarus.

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Avishai

Looking for help: Trying to add better RightToLeft support to Lazarus.

I only work with Windows so any help with other OS's would be very good.

For Windows ONLY:

Ideally, RightToLeft should happen at Design-Time so that there is no difference working RightToLeft or LeftToRight. So far I have not been able to make that work so I am forced to Design 'LeftToRight' and see it RightToLeft Windows Vista, BiDiMode is obsolete and should not be used. Windows Vista introduced RightToLeftLayout and NoInheritLayout that control the Origin and Direction of TWinControl.Canvas effectively mirroring the Control and controlling Text Direction.

One problem seems to be with Themes. If Themes are active mirroring controls does not work properly and can not be used. Solution 1. Go to 'Project/Project Options' and uncheck 'Use manifest...'. Solution
2. This is a hack and should not be used unless you ONLY do RightToLeft. In Themes.pas you can disable Themes in Procedure TThemeServices.UpdateThemes;

Most TWinControl descendants work well but not all of them. Examples of things that don't work well: TMenuItem images, TSpeedButton images, TBitBtn text.

I am attaching a Zip File with modifications that I have made to core Lazarus source files. It also has a small demonstration project. If you want to try this, I highly recommend that you use a second installation of Lazarus.

Shalom, Avishai ????? ???? -------------- next part -------------- A non-text attachment was scrubbed... Name: LazRTLtest.zip Type: application/zip Size: 130031 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121220/1dd98fbb/attachment-0001.zip>

Reply by email

Junior
to Avishai

Windows only? and for Linux?

:(

Avishai wrote 39 lines
Looking for help: Trying to add better RightToLeft support to Lazarus. I only work with Windows so any help with other OS's would be very good. For Windows ONLY: Ideally, RightToLeft should happen at Design-Time so that there is no difference working RightToLeft or LeftToRight. So far I have not been able to make that work so I am forced to Design 'LeftToRight' and see it RightToLeft only at Run-Time. Since Windows Vista, BiDiMode is obsolete and should not be used. Windows Vista introduced RightToLeftLayout and NoInheritLayout that control the Origin and Direction of TWinControl.Canvas effectively mirroring the Control and controlling Text Direction. One problem seems to be with Themes. If Themes are active mirroring controls does not work properly and can not be used. Solution 1. Go to 'Project/Project Options' and uncheck 'Use manifest...'. Solution 2. This is a hack and should not be used unless you ONLY do RightToLeft. In Themes.pas you can disable Themes in Procedure TThemeServices.UpdateThemes; Most TWinControl descendants work well but not all of them. Examples of things that don't work well: TMenuItem images, TSpeedButton images, TBitBtn text. I am attaching a Zip File with modifications that I have made to core Lazarus source files. It also has a small demonstration project. If you want to try this, I highly recommend that you use a second installation of Lazarus. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121220/be1b91b4/attachment.html>

Reply by email

Avishai
to Junior

Sorry, I don't have Linux. I'm hoping to get input from others for other OS's and maybe write some wrappers so that Lazarus calls will work multi-platform. I am also hoping to find fixes for all platforms that support RightToLeft. If you have anything, maybe we can share.

Junior wrote 55 lines
Windows only? and for Linux? :( Em 20-12-2012 06:30, Avishai escreveu: Looking for help: Trying to add better RightToLeft support to Lazarus. I only work with Windows so any help with other OS's would be very good. For Windows ONLY: Ideally, RightToLeft should happen at Design-Time so that there is no difference working RightToLeft or LeftToRight. So far I have not been able to make that work so I am forced to Design 'LeftToRight' and see it RightToLeft only at Run-Time. Since Windows Vista, BiDiMode is obsolete and should not be used. Windows Vista introduced RightToLeftLayout and NoInheritLayout that control the Origin and Direction of TWinControl.Canvas effectively mirroring the Control and controlling Text Direction. One problem seems to be with Themes. If Themes are active mirroring controls does not work properly and can not be used. Solution 1. Go to 'Project/Project Options' and uncheck 'Use manifest...'. Solution 2. This is a hack and should not be used unless you ONLY do RightToLeft. In Themes.pas you can disable Themes in Procedure TThemeServices.UpdateThemes; Most TWinControl descendants work well but not all of them. Examples of things that don't work well: TMenuItem images, TSpeedButton images, TBitBtn text. I am attaching a Zip File with modifications that I have made to core Lazarus source files. It also has a small demonstration project. If you want to try this, I highly recommend that you use a second installation of Lazarus. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Shalom, Avishai ????? ????

Reply by email

Avishai
to Mattias Gaertner

Hi Mattias, good to hear from you. The problems vary from one control to the next. Example: TMenuItem and TSpeedButton Images disappear when pressed. Also TBitBtn Caption is written backward. TComboBox sometimes throws a size Error on Startup.

Mattias Gaertner wrote 16 lines
Avishai hat am 20. Dezember 2012 um 10:30 geschrieben: >[...] > Most TWinControl descendants work well but not all of them. Examples > of things that don't work well: TMenuItem images, TSpeedButton > images, TBitBtn text. What's the problem with each control, what do you expect? Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Shalom, Avishai ????? ????

Reply by email

Avishai
to Avishai

I can make TForm RightToLeft as Design-Time, but when I do, any control that is placed on it can not be selected by clicking on it or moved with the mouse. The only way is to select it in the Object Inspector. Then to move it, I have to change the 'Left' and/or 'Top' properties. Also, even if I drop it on a container, it's parent is always TForm.

Avishai wrote 31 lines
Hi Mattias, good to hear from you. The problems vary from one control to the next. Example: TMenuItem and TSpeedButton Images disappear when pressed. Also TBitBtn Caption is written backward. TComboBox sometimes throws a size Error on Startup. On Thu, Dec 20, 2012 at 4:18 PM, Mattias Gaertner wrote: > > Avishai hat am 20. Dezember 2012 um 10:30 geschrieben: >>[...] >> Most TWinControl descendants work well but not all of them. Examples >> of things that don't work well: TMenuItem images, TSpeedButton >> images, TBitBtn text. > > What's the problem with each control, what do you expect? > > Mattias > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- Shalom, Avishai ????? ????
Shalom, Avishai ????? ????

Reply by email

Avishai
to Avishai

If you haven't already seen this, it's a good place to start. http://msdn.microsoft.com/en-us/goglobal/bb688119.aspx

Avishai wrote 47 lines
I can make TForm RightToLeft as Design-Time, but when I do, any control that is placed on it can not be selected by clicking on it or moved with the mouse. The only way is to select it in the Object Inspector. Then to move it, I have to change the 'Left' and/or 'Top' properties. Also, even if I drop it on a container, it's parent is always TForm. On Thu, Dec 20, 2012 at 4:33 PM, Avishai wrote: > Hi Mattias, good to hear from you. The problems vary from one control > to the next. Example: TMenuItem and TSpeedButton Images disappear > when pressed. Also TBitBtn Caption is written backward. TComboBox > sometimes throws a size Error on Startup. > > On Thu, Dec 20, 2012 at 4:18 PM, Mattias Gaertner > wrote: >> >> Avishai hat am 20. Dezember 2012 um 10:30 geschrieben: >>>[...] >>> Most TWinControl descendants work well but not all of them. Examples >>> of things that don't work well: TMenuItem images, TSpeedButton >>> images, TBitBtn text. >> >> What's the problem with each control, what do you expect? >> >> Mattias >> >> -- >> _______________________________________________ >> Lazarus mailing list >> >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > > > > -- > Shalom, > Avishai > > ????? ???? -- Shalom, Avishai ????? ????
Shalom, Avishai ????? ????

Reply by email

Avishai
to Avishai

If anyone wants to experiment with RightToLeft, this should get you started. But you must disable Themes for it to work. Otherwise all TWinControl.Canvas gets corrupted and can not be used. The TWinControl.Canvas issue is the biggest obstacle to making RightToLeft Forms in Lazarus. Delphi does not have this problem.

Start a new project and drop a TPageControl on the Form. Add 2 Tabs to the TPageControl. Then add the CreateParams code.
--------

unit Unit1;
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, Forms, Controls, LclType, ComCtrls;
type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
  public
    procedure CreateParams(var Params : TCreateParams); override;
  end;
var
  Form1: TForm1;
implementation
{$R *.lfm}
uses AviUtils, Windows;
procedure TForm1.CreateParams(var Params : TCreateParams);
begin
  inherited CreateParams(Params);
  {$IFDEF WINDOWS}
  if SysLocale.MiddleEast then
    Params.ExStyle:= Params.ExStyle or WS_EX_LAYOUTRTL; // or
WS_EX_NOINHERITLAYOUT;
  {$ENDIF}
end;
end.

Reply by email