SpkToolbar: Support RTL layout of panes within tab

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8957 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-10-13 09:44:46 +00:00
parent 2ff41ccea4
commit 130a06d6dd

View File

@ -21,7 +21,7 @@ unit spkt_Tab;
interface
uses
Graphics, Controls, Classes, SysUtils,
Graphics, Controls, Classes, SysUtils, Math,
SpkMath,
spkt_Appearance, spkt_Const, spkt_Dispatch, spkt_Exceptions,
spkt_Pane, spkt_Types;
@ -78,6 +78,9 @@ type
procedure DefineProperties(Filer: TFiler); override;
procedure Loaded; override;
function GetRootComponent: TComponent;
function IsRightToLeft: Boolean;
// *** Getters and setters ***
procedure SetCaption(const Value: string);
procedure SetCustomAppearance(const Value: TSpkToolbarAppearance);
@ -252,21 +255,32 @@ var
x, i: integer;
tw: integer;
tmpRect: T2DIntRect;
isRTL: Boolean;
begin
isRTL := IsRightToLeft;
FRect := ARect;
if AtLeastOnePaneVisible then
begin
x := ARect.left;
x := IfThen(isRTL, ARect.Right, ARect.Left);
for i := 0 to FPanes.Count - 1 do
if FPanes[i].Visible then
begin
tw := FPanes[i].GetWidth;
tmpRect.Left := x;
if isRTL then
begin
tmpRect.Right := x;
tmpRect.Left := x - tw + 1;
x := x - tw - TabPaneHSpacing;
end else
begin
tmpRect.Left := x;
tmpRect.Right := x + tw - 1;
x := x + tw + TabPaneHSpacing;
end;
tmpRect.Top := ARect.Top;
tmpRect.Right := x + tw - 1;
tmpRect.Bottom := ARect.bottom;
FPanes[i].Rect := tmpRect;
x := x + tw + TabPaneHSpacing;
end
else
begin
@ -347,6 +361,20 @@ begin
Proc(FPanes.Items[i]);
end;
function TSpkTab.GetRootComponent: TComponent;
begin
Result := nil;
if Collection <> nil then
Result := Collection.RootComponent
else
Result := nil;
end;
function TSpkTab.IsRightToLeft: Boolean;
begin
Result := (GetRootComponent as TControl).IsRightToLeft;
end;
procedure TSpkTab.Loaded;
begin
inherited;