You've already forked lazarus-ccr
TvPlanit: Support RTL in TSpkCheckbox and TSpkRadioButton
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8955 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1074,6 +1074,7 @@ var
|
|||||||
R: TRect;
|
R: TRect;
|
||||||
SeparatorRect: TRect;
|
SeparatorRect: TRect;
|
||||||
SeparatorLineColor: TColor;
|
SeparatorLineColor: TColor;
|
||||||
|
ts: TTextStyle;
|
||||||
drawImgEnabled: Boolean = true;
|
drawImgEnabled: Boolean = true;
|
||||||
begin
|
begin
|
||||||
if FToolbarDispatch = nil then
|
if FToolbarDispatch = nil then
|
||||||
@ -1081,6 +1082,10 @@ begin
|
|||||||
if FAppearance = nil then
|
if FAppearance = nil then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
ts := ABuffer.Canvas.TextStyle;
|
||||||
|
ts.RightToLeft := IsRightToLeft;
|
||||||
|
ABuffer.Canvas.TextStyle := ts;
|
||||||
|
|
||||||
if (FButtonKind <> bkSeparator) then
|
if (FButtonKind <> bkSeparator) then
|
||||||
begin
|
begin
|
||||||
if (FRect.Width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then
|
if (FRect.Width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then
|
||||||
@ -1650,6 +1655,7 @@ var
|
|||||||
leftEdgeOpen, rightEdgeOpen: Boolean;
|
leftEdgeOpen, rightEdgeOpen: Boolean;
|
||||||
drawImgEnabled: Boolean = true;
|
drawImgEnabled: Boolean = true;
|
||||||
isRTL: Boolean;
|
isRTL: Boolean;
|
||||||
|
ts: TTextStyle;
|
||||||
begin
|
begin
|
||||||
if (FToolbarDispatch = nil) or (FAppearance = nil) then
|
if (FToolbarDispatch = nil) or (FAppearance = nil) then
|
||||||
exit;
|
exit;
|
||||||
@ -1675,6 +1681,9 @@ begin
|
|||||||
|
|
||||||
isRTL := IsRightToLeft;
|
isRTL := IsRightToLeft;
|
||||||
sgn := IfThen(isRTL, -1, +1);
|
sgn := IfThen(isRTL, -1, +1);
|
||||||
|
ts := ABuffer.Canvas.TextStyle;
|
||||||
|
ts.RightToLeft := isRTL;
|
||||||
|
ABuffer.Canvas.TextStyle := ts;
|
||||||
|
|
||||||
delta := FAppearance.Element.HotTrackBrightnessChange;
|
delta := FAppearance.Element.HotTrackBrightnessChange;
|
||||||
case FAppearance.Element.Style of
|
case FAppearance.Element.Style of
|
||||||
@ -1896,13 +1905,13 @@ begin
|
|||||||
if FButtonKind = bkDropdown then
|
if FButtonKind = bkDropdown then
|
||||||
begin
|
begin
|
||||||
if isRTL then
|
if isRTL then
|
||||||
R := Classes.Rect(FButtonRect.Left+1, FButtonRect.Top, FButtonRect.Left+dx, FButtonRect.Bottom)
|
R := Classes.Rect(FButtonRect.Left+1, FButtonRect.Top, FButtonRect.Left+dx+1, FButtonRect.Bottom)
|
||||||
else
|
else
|
||||||
R := Classes.Rect(FButtonRect.Right-dx, FButtonRect.Top, FButtonRect.Right, FButtonRect.Bottom);
|
R := Classes.Rect(FButtonRect.Right-dx, FButtonRect.Top, FButtonRect.Right, FButtonRect.Bottom);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
if isRTL then
|
if isRTL then
|
||||||
R := Classes.Rect(FDropDownRect.Left+1, FDropDownRect.Top, FDropDownRect.Left+dx, FDropDownRect.Bottom)
|
R := Classes.Rect(FDropDownRect.Left+1, FDropDownRect.Top, FDropDownRect.Left+dx+1, FDropDownRect.Bottom)
|
||||||
else
|
else
|
||||||
R := Classes.Rect(FDropdownRect.Right-dx, FDropdownRect.Top, FDropdownRect.Right, FDropdownRect.Bottom);
|
R := Classes.Rect(FDropdownRect.Right-dx, FDropdownRect.Top, FDropdownRect.Right, FDropdownRect.Bottom);
|
||||||
end;
|
end;
|
||||||
|
@ -124,7 +124,7 @@ begin
|
|||||||
else
|
else
|
||||||
BtnWidth := BtnWidth + SmallButtonBorderWidth;
|
BtnWidth := BtnWidth + SmallButtonBorderWidth;
|
||||||
|
|
||||||
// Prawa krawêdŸ przycisku
|
// Right edge of the button
|
||||||
if (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) then
|
if (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) then
|
||||||
BtnWidth := BtnWidth + SmallButtonHalfBorderWidth
|
BtnWidth := BtnWidth + SmallButtonHalfBorderWidth
|
||||||
else
|
else
|
||||||
@ -141,9 +141,13 @@ procedure TSpkCustomCheckbox.Draw(ABuffer: TBitmap; ClipRect: T2DIntRect);
|
|||||||
var
|
var
|
||||||
fontColor: TColor;
|
fontColor: TColor;
|
||||||
x, y: Integer;
|
x, y: Integer;
|
||||||
h: Integer;
|
w, h: Integer;
|
||||||
|
sgn: Integer;
|
||||||
te: TThemedElementDetails;
|
te: TThemedElementDetails;
|
||||||
cornerRadius: Integer;
|
cornerRadius: Integer;
|
||||||
|
leftEdgeOpen, rightEdgeOpen: Boolean;
|
||||||
|
isRTL: Boolean;
|
||||||
|
ts: TTextStyle;
|
||||||
begin
|
begin
|
||||||
if FToolbarDispatch = nil then
|
if FToolbarDispatch = nil then
|
||||||
exit;
|
exit;
|
||||||
@ -152,6 +156,12 @@ begin
|
|||||||
if (FRect.Width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then
|
if (FRect.Width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
isRTL := IsRightToLeft;
|
||||||
|
sgn := IfThen(isRTL, -1, +1);
|
||||||
|
ts := ABuffer.Canvas.TextStyle;
|
||||||
|
ts.RightToLeft := isRTL;
|
||||||
|
ABuffer.Canvas.TextStyle := ts;
|
||||||
|
|
||||||
case FAppearance.Element.Style of
|
case FAppearance.Element.Style of
|
||||||
esRounded:
|
esRounded:
|
||||||
cornerRadius := SmallButtonRadius;
|
cornerRadius := SmallButtonRadius;
|
||||||
@ -162,6 +172,16 @@ begin
|
|||||||
// Border
|
// Border
|
||||||
if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then
|
if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then
|
||||||
begin
|
begin
|
||||||
|
if isRTL then
|
||||||
|
begin
|
||||||
|
leftEdgeOpen := (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown);
|
||||||
|
rightEdgeOpen := (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
leftEdgeOpen := (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]);
|
||||||
|
rightEdgeOpen := (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown);
|
||||||
|
end;
|
||||||
|
|
||||||
with FAppearance.Element do
|
with FAppearance.Element do
|
||||||
TButtonTools.DrawButton(
|
TButtonTools.DrawButton(
|
||||||
ABuffer,
|
ABuffer,
|
||||||
@ -172,8 +192,8 @@ begin
|
|||||||
IdleGradientFromColor,
|
IdleGradientFromColor,
|
||||||
IdleGradientToColor,
|
IdleGradientToColor,
|
||||||
IdleGradientType,
|
IdleGradientType,
|
||||||
(FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]),
|
leftEdgeOpen,
|
||||||
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
|
rightEdgeOpen,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
cornerRadius,
|
cornerRadius,
|
||||||
@ -192,8 +212,8 @@ begin
|
|||||||
HotTrackGradientFromColor,
|
HotTrackGradientFromColor,
|
||||||
HotTrackGradientToColor,
|
HotTrackGradientToColor,
|
||||||
HotTrackGradientType,
|
HotTrackGradientType,
|
||||||
(FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]),
|
leftEdgeOpen,
|
||||||
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
|
rightEdgeOpen,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
cornerRadius,
|
cornerRadius,
|
||||||
@ -212,8 +232,8 @@ begin
|
|||||||
ActiveGradientFromColor,
|
ActiveGradientFromColor,
|
||||||
ActiveGradientToColor,
|
ActiveGradientToColor,
|
||||||
ActiveGradientType,
|
ActiveGradientType,
|
||||||
(FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]),
|
leftEdgeOpen,
|
||||||
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
|
rightEdgeOpen,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
cornerRadius,
|
cornerRadius,
|
||||||
@ -226,13 +246,21 @@ begin
|
|||||||
begin
|
begin
|
||||||
te := ThemeServices.GetElementDetails(tbCheckboxCheckedNormal);
|
te := ThemeServices.GetElementDetails(tbCheckboxCheckedNormal);
|
||||||
h := ThemeServices.GetDetailSize(te).cy;
|
h := ThemeServices.GetDetailSize(te).cy;
|
||||||
|
w := ThemeServices.GetDetailSize(te).cx;
|
||||||
end else
|
end else
|
||||||
|
begin
|
||||||
h := GetSystemMetrics(SM_CYMENUCHECK);
|
h := GetSystemMetrics(SM_CYMENUCHECK);
|
||||||
|
w := GetSystemMetrics(SM_CXMENUCHECK);
|
||||||
|
end;
|
||||||
|
|
||||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
if isRTL then
|
||||||
x := FButtonRect.Left + SmallButtonHalfBorderWidth + SmallButtonPadding
|
x := FButtonRect.Right - w
|
||||||
else
|
else
|
||||||
x := FButtonRect.Left + SmallButtonBorderWidth + SmallButtonPadding;
|
x := FButtonRect.Left;
|
||||||
|
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||||
|
inc(x, sgn * (SmallButtonHalfBorderWidth + SmallButtonPadding))
|
||||||
|
else
|
||||||
|
inc(x, sgn * (SmallButtonBorderWidth + SmallButtonPadding));
|
||||||
y := FButtonRect.Top + (FButtonRect.Height - h) div 2;
|
y := FButtonRect.Top + (FButtonRect.Height - h) div 2;
|
||||||
|
|
||||||
TGUITools.DrawCheckbox(
|
TGUITools.DrawCheckbox(
|
||||||
@ -250,18 +278,22 @@ begin
|
|||||||
case FButtonState of
|
case FButtonState of
|
||||||
bsIdle : fontColor := FAppearance.Element.IdleCaptionColor;
|
bsIdle : fontColor := FAppearance.Element.IdleCaptionColor;
|
||||||
bsBtnHottrack,
|
bsBtnHottrack,
|
||||||
bsDropdownHottrack : fontColor := FAppearance.Element.HotTrackCaptionColor;
|
bsDropdownHotTrack : fontColor := FAppearance.Element.HotTrackCaptionColor;
|
||||||
bsBtnPressed,
|
bsBtnPressed,
|
||||||
bsDropdownPressed : fontColor := FAppearance.ELement.ActiveCaptionColor;
|
bsDropdownPressed : fontColor := FAppearance.ELement.ActiveCaptionColor;
|
||||||
end;
|
end;
|
||||||
if not(FEnabled) then
|
if not(FEnabled) then
|
||||||
fontColor := TColorTools.ColorToGrayscale(fontColor);
|
fontColor := TColorTools.ColorToGrayscale(fontColor);
|
||||||
|
|
||||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
if isRTL then
|
||||||
x := FButtonRect.Left + SmallButtonHalfBorderWidth
|
x := FButtonRect.Right - ABuffer.Canvas.TextWidth(FCaption)
|
||||||
else
|
else
|
||||||
x := FButtonRect.Left + SmallButtonBorderWidth;
|
x := FButtonRect.Left;
|
||||||
x := x + 2 * SmallButtonPadding + SmallButtonGlyphWidth;
|
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||||
|
inc(x, sgn * SmallButtonHalfBorderWidth)
|
||||||
|
else
|
||||||
|
inc(x, sgn * SmallButtonBorderWidth);
|
||||||
|
inc(x, sgn * (2 * SmallButtonPadding + SmallButtonGlyphWidth));
|
||||||
y := FButtonRect.Top + (FButtonRect.Height - ABuffer.Canvas.TextHeight('Wy')) div 2;
|
y := FButtonRect.Top + (FButtonRect.Height - ABuffer.Canvas.TextHeight('Wy')) div 2;
|
||||||
|
|
||||||
TGUITools.DrawText(ABuffer.Canvas, x, y, FCaption, fontColor, ClipRect);
|
TGUITools.DrawText(ABuffer.Canvas, x, y, FCaption, fontColor, ClipRect);
|
||||||
|
Reference in New Issue
Block a user