Skip to content

Commit

Permalink
Added files
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Oct 6, 2011
0 parents commit 238b774
Show file tree
Hide file tree
Showing 275 changed files with 91,272 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
c.bat
compilesettings.bat
1 change: 1 addition & 0 deletions Components/.gitignore
@@ -0,0 +1 @@
*.dcu
126 changes: 126 additions & 0 deletions Components/BidiCtrls.pas
@@ -0,0 +1,126 @@
unit BidiCtrls;

{
Inno Setup
Copyright (C) 1997-2007 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
RTL-capable versions of standard controls
$jrsoftware: issrc/Components/BidiCtrls.pas,v 1.2 2007/11/27 04:52:53 jr Exp $
}

interface

uses
Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TNewEdit = class(TEdit)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

TNewMemo = class(TMemo)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

TNewComboBox = class(TComboBox)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

TNewListBox = class(TListBox)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

TNewButton = class(TButton)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

TNewCheckBox = class(TCheckBox)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

TNewRadioButton = class(TRadioButton)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

procedure Register;

implementation

uses
BidiUtils;

procedure Register;
begin
RegisterComponents('JR', [TNewEdit, TNewMemo, TNewComboBox, TNewListBox,
TNewButton, TNewCheckBox, TNewRadioButton]);
end;

{ TNewEdit }

procedure TNewEdit.CreateParams(var Params: TCreateParams);
begin
inherited;
SetBiDiStyles(Self, Params);
end;

{ TNewMemo }

procedure TNewMemo.CreateParams(var Params: TCreateParams);
begin
inherited;
SetBiDiStyles(Self, Params);
end;

{ TNewComboBox }

procedure TNewComboBox.CreateParams(var Params: TCreateParams);
begin
inherited;
SetBiDiStyles(Self, Params);
end;

{ TNewListBox }

procedure TNewListBox.CreateParams(var Params: TCreateParams);
begin
inherited;
SetBiDiStyles(Self, Params);
end;

{ TNewButton }

procedure TNewButton.CreateParams(var Params: TCreateParams);
begin
inherited;
SetBiDiStyles(Self, Params);
Params.ExStyle := Params.ExStyle and not WS_EX_RIGHT;
end;

{ TNewCheckBox }

procedure TNewCheckBox.CreateParams(var Params: TCreateParams);
begin
inherited;
SetBiDiStyles(Self, Params);
end;

{ TNewRadioButton }

procedure TNewRadioButton.CreateParams(var Params: TCreateParams);
begin
inherited;
SetBiDiStyles(Self, Params);
end;

end.
88 changes: 88 additions & 0 deletions Components/BidiUtils.pas
@@ -0,0 +1,88 @@
unit BidiUtils;

{
Inno Setup
Copyright (C) 1997-2007 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Bidi utility functions
$jrsoftware: issrc/Components/BidiUtils.pas,v 1.2 2007/11/27 04:52:53 jr Exp $
}

interface

uses
Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

procedure FlipControls(const AParentCtl: TWinControl);
procedure FlipRect(var Rect: TRect; const ParentRect: TRect; const UseRightToLeft: Boolean);
function IsParentFlipped(const AControl: TControl): Boolean;
function IsParentRightToLeft(const AControl: TControl): Boolean;
function SetBiDiStyles(const AControl: TControl; var AParams: TCreateParams): Boolean;

var
{ These are set by the SetupForm unit: }
IsParentFlippedFunc: function(AControl: TControl): Boolean;
IsParentRightToLeftFunc: function(AControl: TControl): Boolean;

implementation

procedure FlipRect(var Rect: TRect; const ParentRect: TRect; const UseRightToLeft: Boolean);
var
W: Integer;
begin
if UseRightToLeft then begin
W := Rect.Right - Rect.Left;
Rect.Left := ParentRect.Right - (Rect.Left - ParentRect.Left) - W;
Rect.Right := Rect.Left + W;
end;
end;

function IsParentFlipped(const AControl: TControl): Boolean;
begin
if Assigned(IsParentFlippedFunc) then
Result := IsParentFlippedFunc(AControl)
else
Result := False;
end;

function IsParentRightToLeft(const AControl: TControl): Boolean;
begin
if Assigned(IsParentRightToLeftFunc) then
Result := IsParentRightToLeftFunc(AControl)
else
Result := False;
end;

function SetBiDiStyles(const AControl: TControl; var AParams: TCreateParams): Boolean;
begin
Result := IsParentRightToLeft(AControl);
if Result then
AParams.ExStyle := AParams.ExStyle or (WS_EX_RTLREADING or WS_EX_LEFTSCROLLBAR or WS_EX_RIGHT);
end;

procedure FlipControls(const AParentCtl: TWinControl);
var
ParentWidth, I: Integer;
Ctl: TControl;
begin
if AParentCtl.ControlCount = 0 then
Exit;
AParentCtl.DisableAlign;
try
ParentWidth := AParentCtl.ClientWidth;
for I := 0 to AParentCtl.ControlCount-1 do begin
Ctl := AParentCtl.Controls[I];
Ctl.Left := ParentWidth - Ctl.Width - Ctl.Left;
end;
finally
AParentCtl.EnableAlign;
end;
for I := 0 to AParentCtl.ControlCount-1 do
if AParentCtl.Controls[I] is TWinControl then
FlipControls(TWinControl(AParentCtl.Controls[I]));
end;

end.

0 comments on commit 238b774

Please sign in to comment.