You've already forked lazarus-ccr
SpkToolbar: Implement RTL for TSpkSmallButton.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8954 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -756,6 +756,10 @@ begin
|
||||
if Assigned(FDropdownMenu) then
|
||||
begin
|
||||
DropPoint := FToolbarDispatch.ClientToScreen(GetDropdownPoint);
|
||||
if IsRightToLeft then
|
||||
FDropDownMenu.BiDiMode := bdRightToLeft
|
||||
else
|
||||
FDropDownMenu.BiDiMode := bdLeftToRight;
|
||||
FDropdownMenu.Popup(DropPoint.x, DropPoint.y);
|
||||
FButtonState := bsBtnHottrack;
|
||||
if Assigned(FToolbarDispatch) then
|
||||
@ -773,6 +777,10 @@ begin
|
||||
if Assigned(FDropdownMenu) then
|
||||
begin
|
||||
DropPoint := FToolbarDispatch.ClientToScreen(GetDropdownPoint);
|
||||
if IsRightToLeft then
|
||||
FDropDownMenu.BiDiMode := bdRightToLeft
|
||||
else
|
||||
FDropDownMenu.BiDiMode := bdLeftToRight;
|
||||
FDropdownMenu.Popup(DropPoint.x, DropPoint.y);
|
||||
FButtonState := bsBtnHottrack;
|
||||
if Assigned(FToolbarDispatch) then
|
||||
@ -1477,6 +1485,7 @@ var
|
||||
Bitmap: TBitmap;
|
||||
TextWidth: Integer;
|
||||
AdditionalPadding: Boolean;
|
||||
isRTL: Boolean;
|
||||
begin
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
BtnRect := T2DIntRect.Create(0, 0, 0, 0);
|
||||
@ -1495,6 +1504,8 @@ begin
|
||||
if not Assigned(Bitmap) then
|
||||
exit;
|
||||
|
||||
isRTL := IsRightToLeft;
|
||||
|
||||
// *** Regardless of the type, there must be room for the icon and / or text ***
|
||||
|
||||
BtnWidth := 0;
|
||||
@ -1569,14 +1580,26 @@ begin
|
||||
else
|
||||
DropdownWidth := DropdownWidth + SmallButtonBorderWidth;
|
||||
|
||||
if isRTL then
|
||||
begin
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
BtnRect := T2DIntRect.Create(0, 0, BtnWidth - 1, PaneRowHeightT - 1);
|
||||
DropRect := T2DIntRect.Create(0, 0, DropdownWidth - 1, PaneRowHeight - 1);
|
||||
BtnRect := T2DIntRect.Create(DropRect.Right+1, 0, DropRect.Right + BtnWidth, PaneRowHeight - 1);
|
||||
{$ELSE}
|
||||
DropRect.Create(0, 0, DropdownWidth - 1, PaneRowHeight - 1);
|
||||
BtnRect.Create(DropRect.Right+1, 0, DropRect.Right + BtnWidth, PaneRowHeight - 1);
|
||||
{$ENDIF}
|
||||
end else
|
||||
begin
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
BtnRect := T2DIntRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1);
|
||||
DropRect := T2DIntRect.Create(BtnRect.Right+1, 0, BtnRect.Right+DropdownWidth, PaneRowHeight - 1);
|
||||
{$ELSE}
|
||||
BtnRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1);
|
||||
DropRect.Create(BtnRect.Right+1, 0, BtnRect.Right+DropdownWidth, PaneRowHeight - 1);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
bkDropdown:
|
||||
begin
|
||||
@ -1614,18 +1637,19 @@ var
|
||||
gradientFromColor, gradientToColor: TColor;
|
||||
gradientKind: TBackgroundKind;
|
||||
P: T2DIntPoint;
|
||||
x, y: Integer;
|
||||
x, dx, y, w: Integer;
|
||||
delta: Integer;
|
||||
cornerRadius: Integer;
|
||||
ppi, sgn: Integer;
|
||||
imgList: TImageList;
|
||||
imgSize: TSize;
|
||||
drawBtn: Boolean;
|
||||
R: TRect;
|
||||
dx: Integer;
|
||||
ppi: Integer;
|
||||
SeparatorRect: TRect;
|
||||
SeparatorLineColor: TColor;
|
||||
leftEdgeOpen, rightEdgeOpen: Boolean;
|
||||
drawImgEnabled: Boolean = true;
|
||||
isRTL: Boolean;
|
||||
begin
|
||||
if (FToolbarDispatch = nil) or (FAppearance = nil) then
|
||||
exit;
|
||||
@ -1649,6 +1673,9 @@ begin
|
||||
if (FRect.Width < 2*SmallButtonRadius) or (FRect.Height < 2*SmallButtonRadius) then
|
||||
exit;
|
||||
|
||||
isRTL := IsRightToLeft;
|
||||
sgn := IfThen(isRTL, -1, +1);
|
||||
|
||||
delta := FAppearance.Element.HotTrackBrightnessChange;
|
||||
case FAppearance.Element.Style of
|
||||
esRounded:
|
||||
@ -1692,6 +1719,14 @@ begin
|
||||
|
||||
if drawBtn then
|
||||
begin
|
||||
if isRTL then begin
|
||||
rightEdgeOpen := (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]);
|
||||
leftEdgeOpen := (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown);
|
||||
end else
|
||||
begin
|
||||
leftEdgeOpen := (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]);
|
||||
rightEdgeOpen := (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown);
|
||||
end;
|
||||
TButtonTools.DrawButton(
|
||||
ABuffer,
|
||||
FButtonRect, // draw button part only
|
||||
@ -1701,8 +1736,8 @@ begin
|
||||
gradientFromColor,
|
||||
gradientToColor,
|
||||
gradientKind,
|
||||
(FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]),
|
||||
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
|
||||
leftEdgeOpen,
|
||||
rightEdgeOpen,
|
||||
false,
|
||||
false,
|
||||
cornerRadius,
|
||||
@ -1728,10 +1763,11 @@ begin
|
||||
imgSize := Size(imgList.Width, imgList.Height);
|
||||
{$ENDIF}
|
||||
|
||||
x := IfThen(isRTL, FButtonRect.Right - imgSize.CX, FButtonRect.Left);
|
||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||
x := FButtonRect.Left + SmallButtonHalfBorderWidth + SmallButtonPadding
|
||||
inc(x, sgn * (SmallButtonHalfBorderWidth + SmallButtonPadding))
|
||||
else
|
||||
x := FButtonRect.Left + SmallButtonBorderWidth + SmallButtonPadding;
|
||||
inc(x, sgn * (SmallButtonBorderWidth + SmallButtonPadding));
|
||||
y := FButtonRect.top + (FButtonRect.height - imgSize.CY) div 2;
|
||||
P := {$IFDEF EnhancedRecordSupport}T2DIntPoint.Create{$ELSE}Create2DIntPoint{$ENDIF}(x, y);
|
||||
TGUITools.DrawImage(
|
||||
@ -1767,15 +1803,19 @@ begin
|
||||
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
ABuffer.Canvas.Font.Color := fontColor;
|
||||
|
||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||
x := FButtonRect.Left + SmallButtonHalfBorderWidth
|
||||
if isRTL then
|
||||
x := FButtonRect.Right - ABuffer.Canvas.TextWidth(FCaption)
|
||||
else
|
||||
x := FButtonRect.Left + SmallButtonBorderWidth;
|
||||
x := FButtonRect.Left;
|
||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||
inc(x, sgn * SmallButtonHalfBorderWidth)
|
||||
else
|
||||
inc(x, sgn * SmallButtonBorderWidth);
|
||||
|
||||
if FImageIndex <> -1 then
|
||||
x := x + 2 * SmallButtonPadding + SmallButtonGlyphWidth
|
||||
inc(x, sgn * (2 * SmallButtonPadding + SmallButtonGlyphWidth))
|
||||
else
|
||||
x := x + SmallButtonPadding;
|
||||
inc(x, sgn * SmallButtonPadding);
|
||||
y := FButtonRect.Top + (FButtonRect.Height - ABuffer.Canvas.TextHeight('Wy')) div 2;
|
||||
|
||||
TGUITools.DrawText(ABuffer.Canvas, x, y, FCaption, fontColor, ClipRect);
|
||||
@ -1816,7 +1856,17 @@ begin
|
||||
end else
|
||||
drawBtn := false;
|
||||
|
||||
// Dropdown button
|
||||
if drawBtn then begin
|
||||
if isRTL then
|
||||
begin
|
||||
leftEdgeOpen := (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]);
|
||||
rightEdgeOpen := true;
|
||||
end else
|
||||
begin
|
||||
leftEdgeOpen := true;
|
||||
rightEdgeOpen := (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]);
|
||||
end;
|
||||
TButtonTools.DrawButton(
|
||||
ABuffer,
|
||||
FDropdownRect,
|
||||
@ -1826,8 +1876,8 @@ begin
|
||||
gradientFromColor,
|
||||
gradientToColor,
|
||||
gradientKind,
|
||||
true,
|
||||
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]),
|
||||
leftEdgeOpen,
|
||||
rightEdgeOpen,
|
||||
false,
|
||||
false,
|
||||
cornerRadius,
|
||||
@ -1844,10 +1894,19 @@ begin
|
||||
else
|
||||
inc(dx, SmallButtonBorderWidth);
|
||||
if FButtonKind = bkDropdown then
|
||||
R := Classes.Rect(FButtonRect.Right-dx, FButtonRect.Top, FButtonRect.Right, FButtonRect.Bottom)
|
||||
begin
|
||||
if isRTL then
|
||||
R := Classes.Rect(FButtonRect.Left+1, FButtonRect.Top, FButtonRect.Left+dx, FButtonRect.Bottom)
|
||||
else
|
||||
R := Classes.Rect(FButtonRect.Right-dx, FButtonRect.Top, FButtonRect.Right, FButtonRect.Bottom);
|
||||
end else
|
||||
begin
|
||||
if isRTL then
|
||||
R := Classes.Rect(FDropDownRect.Left+1, FDropDownRect.Top, FDropDownRect.Left+dx, FDropDownRect.Bottom)
|
||||
else
|
||||
R := Classes.Rect(FDropdownRect.Right-dx, FDropdownRect.Top, FDropdownRect.Right, FDropdownRect.Bottom);
|
||||
DrawdropdownArrow(ABuffer, R, fontcolor);
|
||||
end;
|
||||
DrawDropdownArrow(ABuffer, R, fontcolor);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1901,8 +1960,12 @@ begin
|
||||
ConstructRects(BtnRect, DropRect);
|
||||
|
||||
if FButtonKind = bkButtonDropdown then
|
||||
Result := DropRect.Right+1
|
||||
begin
|
||||
if IsRightToLeft then
|
||||
Result := BtnRect.Right + 1
|
||||
else
|
||||
Result := DropRect.Right + 1;
|
||||
end else
|
||||
Result := BtnRect.Right+1;
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user