From a36b768a64ddea301e7e7c8229b4401ba9b0e95a Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 13 Oct 2023 11:17:57 +0000 Subject: [PATCH] SpkToolbar: RTL support for the "More options" button. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8961 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../spktoolbar/SpkToolbar/spkt_Pane.pas | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/components/spktoolbar/SpkToolbar/spkt_Pane.pas b/components/spktoolbar/SpkToolbar/spkt_Pane.pas index 1741beb98..57b442b4f 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Pane.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Pane.pas @@ -241,19 +241,29 @@ procedure TSpkPane.SetRect(ARect: T2DIntRect); var Pt: T2DIntPoint; i: integer; + x1, x2: Integer; Layout: TSpkPaneItemsLayout; begin FRect := ARect; // Set 'More options' button rect + if IsRightToLeft then + begin + x1 := FRect.Left + PaneBorderHalfSize + 2; + x2 := FRect.Left + PaneBorderHalfSize + PaneMoreOptionsButtonWidth; + end else + begin + x1 := FRect.Right - PaneBorderHalfSize - PaneMoreOptionsButtonWidth; + x2 := FRect.Right - PaneBorderHalfSize - 2; + end; {$IFDEF EnhancedRecordSupport} FMoreOptionsButtonRect := T2DIntRect.Create( {$ELSE} FMoreOptionsButtonRect := Create2DIntRect( {$ENDIF} - FRect.Right - PaneBorderHalfSize - PaneMoreOptionsButtonWidth, + x1, FRect.Bottom - PaneCaptionHeight - PaneBorderHalfSize, - FRect.Right - PaneBorderHalfSize - 2, + x2, FRect.Bottom - PaneBorderHalfSize - 2 ); @@ -298,6 +308,9 @@ var i: Integer; R: T2DIntRect; delta: Integer; + w: Integer; + isRTL: Boolean; + ts: TTextStyle; begin // Under some conditions, we are not able to draw:: // * No dispatcher @@ -308,6 +321,11 @@ begin if FAppearance = nil then exit; + isRTL := IsRightToLeft; + ts := ABuffer.Canvas.TextStyle; + ts.RightToLeft := IsRightToLeft; + ABuffer.Canvas.TextStyle := ts; + if FPaneState = psIdle then begin // psIdle @@ -383,9 +401,19 @@ begin // Handle visibility of 'More options' button to set Pane label pos if FShowMoreOptionsButton then - x := FRect.Left + (FRect.Width - PaneMoreOptionsButtonWidth - ABuffer.Canvas.TextWidth(FCaption)) div 2 - else - x := FRect.Left + (FRect.Width - ABuffer.Canvas.TextWidth(FCaption)) div 2; + begin + w := ABuffer.Canvas.TextWidth(FCaption); + if isRTL then + x := FRect.Right - (FRect.Width - PaneMoreOptionsButtonWidth - w) div 2 - w + else + x := FRect.Left + (FRect.Width - PaneMoreOptionsButtonWidth - w) div 2; + end else + begin + if isRTL then + x := FRect.Right - (FRect.Width - w) div 2 - w + else + x := FRect.Left + (FRect.Width - w) div 2; + end; y := FRect.Bottom - PaneBorderSize - PaneCaptionHeight + 1 + (PaneCaptionHeight - ABuffer.Canvas.TextHeight('Wy')) div 2;