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
This commit is contained in:
wp_xxyyzz
2023-10-13 11:17:57 +00:00
parent ba931c14b4
commit a36b768a64

View File

@ -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
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 - ABuffer.Canvas.TextWidth(FCaption)) div 2;
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;