SpkToolbar: Prepare for RTL

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8953 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-10-12 21:43:33 +00:00
parent 6852677f7c
commit 9dc50e13f7
5 changed files with 54 additions and 0 deletions

View File

@ -385,6 +385,9 @@ type
{ Setter for visibility of Menu Button } { Setter for visibility of Menu Button }
procedure SetShowMenuButton(Value: Boolean); procedure SetShowMenuButton(Value: Boolean);
{ Setter for BiDiMode (left-to-right or right-to-left writing direction) }
procedure SetBiDiMode(Value: TBiDiMode); override;
{ Calculates the height of the entire toolbar } { Calculates the height of the entire toolbar }
function CalcToolbarHeight: Integer; function CalcToolbarHeight: Integer;
@ -2683,4 +2686,14 @@ begin
end; end;
end; end;
procedure TSpkToolbar.SetBiDiMode(Value: TBiDiMode);
begin
if BiDiMode = Value then exit;
inherited SetBiDiMode(Value);
FTabs.IsRightToLeft := IsRightToLeft;
SetMetricsInvalid;
if not (FInternalUpdating or FUpdating) then
Repaint;
end;
end. end.

View File

@ -126,6 +126,7 @@ type
{%H-}X, {%H-}Y: Integer); override; {%H-}X, {%H-}Y: Integer); override;
function GetRootComponent: TComponent; function GetRootComponent: TComponent;
function IsRightToLeft: Boolean;
property ActionLink: TSpkButtonActionLink read FActionLink; property ActionLink: TSpkButtonActionLink read FActionLink;
property Checked: Boolean read GetChecked write SetChecked default false; property Checked: Boolean read GetChecked write SetChecked default false;
@ -522,6 +523,11 @@ begin
result := tab.Collection.RootComponent; result := tab.Collection.RootComponent;
end; end;
function TSpkBaseButton.IsRightToLeft: Boolean;
begin
Result := (GetRootComponent as TControl).IsRightToLeft;
end;
procedure TSpkBaseButton.MouseDown(Button: TMouseButton; Shift: TShiftState; procedure TSpkBaseButton.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); X, Y: Integer);
begin begin

View File

@ -31,6 +31,7 @@ type
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
FImagesWidth: Integer; FImagesWidth: Integer;
FLargeImagesWidth: Integer; FLargeImagesWidth: Integer;
FIsRightToLeft: Boolean;
// *** Getters and setters *** // *** Getters and setters ***
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
@ -42,6 +43,7 @@ type
procedure SetDisabledLargeImages(const Value: TImageList); procedure SetDisabledLargeImages(const Value: TImageList);
procedure SetImagesWidth(const Value: Integer); procedure SetImagesWidth(const Value: Integer);
procedure SetLargeImagesWidth(const Value: Integer); procedure SetLargeImagesWidth(const Value: Integer);
procedure SetIsRightToLeft(const Value: Boolean);
public public
function AddLargeButton: TSpkLargeButton; function AddLargeButton: TSpkLargeButton;
@ -62,6 +64,7 @@ type
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth; property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth; property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
property IsRightToLeft: Boolean read FIsRightToLeft write SetIsRightToLeft;
end; end;
implementation implementation
@ -181,6 +184,12 @@ begin
Items[i].ImagesWidth := Value; Items[i].ImagesWidth := Value;
end; end;
procedure TSpkItems.SetIsRightToLeft(const Value: Boolean);
begin
if FIsRightToLeft = Value then exit;
FIsRightToLeft := Value;
end;
procedure TSpkItems.SetLargeImages(const Value: TImageList); procedure TSpkItems.SetLargeImages(const Value: TImageList);
var var
i: Integer; i: Integer;

View File

@ -144,6 +144,7 @@ type
TSpkPanes = class(TSpkCollection) TSpkPanes = class(TSpkCollection)
private private
FIsRightToLeft: Boolean;
protected protected
FToolbarDispatch: TSpkBaseToolbarDispatch; FToolbarDispatch: TSpkBaseToolbarDispatch;
FAppearance: TSpkToolbarAppearance; FAppearance: TSpkToolbarAppearance;
@ -164,6 +165,7 @@ type
procedure SetDisabledLargeImages(const Value: TImageList); procedure SetDisabledLargeImages(const Value: TImageList);
procedure SetImagesWidth(const Value: Integer); procedure SetImagesWidth(const Value: Integer);
procedure SetLargeImagesWidth(const Value: Integer); procedure SetLargeImagesWidth(const Value: Integer);
procedure SetIsRightToLeft(const Value: Boolean);
public public
// *** Adding and inserting elements *** // *** Adding and inserting elements ***
@ -182,6 +184,7 @@ type
property LargeImages: TImageList read FLargeImages write SetLargeImages; property LargeImages: TImageList read FLargeImages write SetLargeImages;
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth; property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property IsRightToLeft: Boolean read FIsRightToLeft write SetIsRightToLeft;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth; property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
end; end;
@ -1299,6 +1302,16 @@ begin
Items[i].ImagesWidth := Value; Items[i].ImagesWidth := Value;
end; end;
procedure TSpkPanes.SetIsRightToLeft(const Value: Boolean);
var
i: Integer;
begin
if FIsRightToLeft = Value then exit;
FIsRightToLeft := Value;
for i := 0 to Count-1 do
Items[i].Items.IsRightToLeft := Value;
end;
procedure TSpkPanes.SetLargeImages(const Value: TImageList); procedure TSpkPanes.SetLargeImages(const Value: TImageList);
var var
I: Integer; I: Integer;

View File

@ -148,6 +148,7 @@ type
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
FImagesWidth: Integer; FImagesWidth: Integer;
FLargeImagesWidth: Integer; FLargeImagesWidth: Integer;
FIsRightToLeft: Boolean;
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
function GetItems(AIndex: integer): TSpkTab; reintroduce; function GetItems(AIndex: integer): TSpkTab; reintroduce;
procedure SetAppearance(const Value: TSpkToolbarAppearance); procedure SetAppearance(const Value: TSpkToolbarAppearance);
@ -156,6 +157,7 @@ type
procedure SetLargeImages(const Value: TImageList); procedure SetLargeImages(const Value: TImageList);
procedure SetDisabledLargeImages(const Value: TImageList); procedure SetDisabledLargeImages(const Value: TImageList);
procedure SetImagesWidth(const Value: Integer); procedure SetImagesWidth(const Value: Integer);
procedure SetIsRightToLeft(const Value: Boolean);
procedure SetLargeImagesWidth(const Value: Integer); procedure SetLargeImagesWidth(const Value: Integer);
public public
function Add: TSpkTab; function Add: TSpkTab;
@ -172,6 +174,7 @@ type
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth; property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth; property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
property IsRightToLeft: boolean read FIsRightToLeft write SetIsRightToLeft;
end; end;
@ -736,6 +739,16 @@ begin
Items[i].ImagesWidth := Value; Items[i].ImagesWidth := Value;
end; end;
procedure TSpkTabs.SetIsRightToLeft(const Value: Boolean);
var
i: Integer;
begin
if FIsRightToLeft = Value then exit;
FIsRightToLeft := Value;
for i := 0 to Count-1 do
Items[i].Panes.IsRightToLeft := Value;
end;
procedure TSpkTabs.SetLargeImages(const Value: TImageList); procedure TSpkTabs.SetLargeImages(const Value: TImageList);
var var
i: Integer; i: Integer;