You've already forked lazarus-ccr
SpkToolbar: Support RTL in Tab and MenuButton layout of SpkToolbar
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8958 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1645,10 +1645,14 @@ procedure TSpkToolbar.ValidateBuffer;
|
||||
x, y: integer;
|
||||
TabRect: T2DIntRect;
|
||||
clr: TColor;
|
||||
ts: TTextStyle;
|
||||
begin
|
||||
TabRect := FTabRects[index];
|
||||
|
||||
FBuffer.canvas.font.Assign(AFont);
|
||||
FBuffer.Canvas.Font.Assign(AFont);
|
||||
ts := FBuffer.Canvas.TextStyle;
|
||||
ts.RightToLeft := IsRightToLeft;
|
||||
FBuffer.Canvas.TextStyle := ts;
|
||||
|
||||
if AOverrideTextColor <> clNone then
|
||||
clr := AOverrideTextColor else
|
||||
@ -1861,7 +1865,8 @@ procedure TSpkToolbar.ValidateBuffer;
|
||||
CurrentAppearance := FAppearance;
|
||||
|
||||
if CurrentAppearance.Tab.GradientType = bkSolid then
|
||||
delta := 0 else
|
||||
delta := 0
|
||||
else
|
||||
delta := 50;
|
||||
|
||||
//TabRect := FTabRects[i];
|
||||
@ -1951,7 +1956,6 @@ procedure TSpkToolbar.ValidateBuffer;
|
||||
FMenuButtonRect.Left + aCornerRadius - 1,
|
||||
FMenuButtonRect.Top + aCornerRadius,
|
||||
FMenuButtonRect.Right - aCornerRadius + 1 + 1,
|
||||
// FMenuButtonRect.Bottom + 1
|
||||
FMenuButtonRect.Bottom
|
||||
);
|
||||
|
||||
@ -1995,8 +1999,8 @@ procedure TSpkToolbar.ValidateBuffer;
|
||||
// Draw left vertical line of Menu Button
|
||||
if DrawRounded then
|
||||
TGuiTools.DrawVLine(FBuffer,
|
||||
FMenuButtonRect.left + aCornerRadius - 1,
|
||||
FMenuButtonRect.top + aCornerRadius,
|
||||
FMenuButtonRect.Left + aCornerRadius - 1,
|
||||
FMenuButtonRect.Top + aCornerRadius,
|
||||
FMenuButtonRect.Bottom - 1,
|
||||
BorderColor,
|
||||
FTabClipRect)
|
||||
@ -2083,15 +2087,15 @@ procedure TSpkToolbar.ValidateBuffer;
|
||||
Case FMenuButtonStyle of
|
||||
mbsCaption:
|
||||
begin
|
||||
x := FMenuButtonRect.left + (FMenuButtonRect.Width - FBuffer.Canvas.textwidth(
|
||||
x := FMenuButtonRect.Left + (FMenuButtonRect.Width - FBuffer.Canvas.textwidth(
|
||||
FMenuButtonCaption)) div 2;
|
||||
y := FMenuButtonRect.top + (FMenuButtonRect.Height - FBuffer.Canvas.Textheight('Wy')) div 2;
|
||||
y := FMenuButtonRect.Top + (FMenuButtonRect.Height - FBuffer.Canvas.Textheight('Wy')) div 2;
|
||||
end;
|
||||
mbsCaptionDropdown:
|
||||
begin
|
||||
x := FMenuButtonRect.left + (FMenuButtonRect.Width - FBuffer.Canvas.textwidth(
|
||||
x := FMenuButtonRect.Left + (FMenuButtonRect.Width - FBuffer.Canvas.textwidth(
|
||||
FMenuButtonCaption) - SmallButtonDropdownWidth) div 2;
|
||||
y := FMenuButtonRect.top + (FMenuButtonRect.Height - FBuffer.Canvas.Textheight('Wy')) div 2;
|
||||
y := FMenuButtonRect.Top + (FMenuButtonRect.Height - FBuffer.Canvas.Textheight('Wy')) div 2;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2233,6 +2237,8 @@ var
|
||||
AdditionalPadding: Boolean;
|
||||
MenuButtonTextWidth: Integer;
|
||||
ToolbarHeight: Integer;
|
||||
sgn: Integer;
|
||||
isRTL: Boolean;
|
||||
{$IFDEF LCLCocoa}
|
||||
scalefactor: Double;
|
||||
{$ENDIF}
|
||||
@ -2254,6 +2260,9 @@ begin
|
||||
{$ENDIF}
|
||||
SetBounds(Left, Top, FBuffer.Width, ToolbarHeight);
|
||||
|
||||
isRTL := IsRightToLeft;
|
||||
sgn := IfThen(isRTL, -1, +1);
|
||||
|
||||
// *** Tabs ***
|
||||
|
||||
TabAppearance := FAppearance;
|
||||
@ -2315,20 +2324,32 @@ begin
|
||||
end;
|
||||
|
||||
// Set Menu Button rect
|
||||
if isRTL then
|
||||
begin
|
||||
FMenuButtonRect.Right := Width;
|
||||
FMenuButtonRect.Left := Width - MenuButtonWidth;
|
||||
end else
|
||||
begin
|
||||
FMenuButtonRect.Left := 0;
|
||||
FMenuButtonRect.Top := 0;
|
||||
FMenuButtonRect.Right := MenuButtonWidth;
|
||||
end;
|
||||
FMenuButtonRect.Top := 0;
|
||||
FMenuButtonRect.Bottom := FAppearance.Tab.CalcCaptionHeight;
|
||||
|
||||
// Rects of tabs headings (containg top frame of component)
|
||||
Setlength(FTabRects, FTabs.Count);
|
||||
if FTabs.Count > 0 then
|
||||
begin
|
||||
if isRTL then
|
||||
x := Width
|
||||
else
|
||||
x := 0;
|
||||
|
||||
// Add left space for Menu Button before Tabs if FShowMenuButton = True
|
||||
if FShowMenuButton then
|
||||
x := ToolbarCornerRadius + (FMenuButtonRect.Right - FMenuButtonRect.Left) + 2
|
||||
inc(x, sgn * (ToolbarCornerRadius + (FMenuButtonRect.Right - FMenuButtonRect.Left) + 2))
|
||||
else
|
||||
x := ToolbarCornerRadius + 1;
|
||||
inc(x, sgn * (ToolbarCornerRadius + 1));
|
||||
for i := 0 to FTabs.Count - 1 do
|
||||
if FTabs[i].Visible then
|
||||
begin
|
||||
@ -2348,12 +2369,19 @@ begin
|
||||
FBuffer.Canvas.TextWidth(FTabs.Items[i].Caption));
|
||||
// Breadth of text
|
||||
|
||||
if isRTL then
|
||||
begin
|
||||
FTabRects[i].Right := x;
|
||||
FTabRects[i].Left := x - TabWidth + 1;
|
||||
x := FTabRects[i].Left - 1;
|
||||
end else
|
||||
begin
|
||||
FTabRects[i].Left := x;
|
||||
FTabRects[i].Right := x + TabWidth - 1;
|
||||
x := FTabRects[i].Right + 1;
|
||||
end;
|
||||
FTabRects[i].Top := 0;
|
||||
FTabRects[i].Bottom := TabAppearance.Tab.CalcCaptionHeight;
|
||||
|
||||
x := FTabRects[i].right + 1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
Reference in New Issue
Block a user