From 130a06d6ddb0079da84121e6afe9250c5d5bfee2 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 13 Oct 2023 09:44:46 +0000 Subject: [PATCH] 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 --- components/spktoolbar/SpkToolbar/spkt_Tab.pas | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/components/spktoolbar/SpkToolbar/spkt_Tab.pas b/components/spktoolbar/SpkToolbar/spkt_Tab.pas index 36ef7ddb9..265b187a3 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Tab.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Tab.pas @@ -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;