SpkToolbar: Respect ElementAppearance.Style when drawing checkboxes or radiobuttons.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5369 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-11-18 22:22:49 +00:00
parent 2188bdf375
commit 34a9a3ad70

View File

@ -80,7 +80,7 @@ implementation
uses uses
LCLType, LCLIntf, Math, Themes, LCLType, LCLIntf, Math, Themes,
SpkGraphTools, spkt_Const, spkt_Tools, spkt_Pane; SpkGraphTools, spkt_Const, spkt_Tools, spkt_Pane, spkt_Appearance;
{ TSpkCheckboxActionLink } { TSpkCheckboxActionLink }
@ -225,10 +225,11 @@ end;
procedure TSpkCustomCheckbox.Draw(ABuffer: TBitmap; ClipRect: T2DIntRect); procedure TSpkCustomCheckbox.Draw(ABuffer: TBitmap; ClipRect: T2DIntRect);
var var
FontColor: TColor; fontColor: TColor;
x, y: Integer; x, y: Integer;
h: Integer; h: Integer;
te: TThemedElementDetails; te: TThemedElementDetails;
cornerRadius: Integer;
begin begin
if FToolbarDispatch = nil then if FToolbarDispatch = nil then
exit; exit;
@ -237,6 +238,13 @@ 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;
case FAppearance.Element.Style of
esRounded:
cornerRadius := SmallButtonRadius;
esRectangle:
cornerRadius := 0;
end;
// Border // Border
if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then begin if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then begin
with FAppearance.Element do with FAppearance.Element do
@ -253,7 +261,7 @@ begin
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
false, false,
false, false,
SmallButtonRadius, cornerRadius,
ClipRect ClipRect
); );
end else end else
@ -272,7 +280,7 @@ begin
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
false, false,
false, false,
SmallButtonRadius, cornerRadius,
ClipRect ClipRect
); );
end else end else
@ -291,7 +299,7 @@ begin
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
false, false,
false, false,
SmallButtonRadius, cornerRadius,
ClipRect ClipRect
); );
end; end;
@ -320,23 +328,15 @@ begin
// Text // Text
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont); ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
FontColor := clNone;
if not(FEnabled) then
case FButtonState of case FButtonState of
bsIdle : FontColor := TColorTools.ColorToGrayscale(FAppearance.Element.IdleCaptionColor); bsIdle : fontColor := FAppearance.Element.IdleCaptionColor;
bsBtnHottrack, bsBtnHottrack,
bsDropdownHottrack : FontColor := TColorTools.ColorToGrayscale(FAppearance.Element.HotTrackCaptionColor); bsDropdownHottrack : fontColor := FAppearance.Element.HotTrackCaptionColor;
bsBtnPressed, bsBtnPressed,
bsDropdownPressed : FontColor := TColorTools.ColorToGrayscale(FAppearance.ELement.ActiveCaptionColor); bsDropdownPressed : fontColor := FAppearance.ELement.ActiveCaptionColor;
end
else
case FButtonState of
bsIdle : FontColor := FAppearance.Element.IdleCaptionColor;
bsBtnHottrack,
bsDropdownHottrack : FontColor := FAppearance.Element.HotTrackCaptionColor;
bsBtnPressed,
bsDropdownPressed : FontColor := FAppearance.ELement.ActiveCaptionColor;
end; end;
if not(FEnabled) then
fontColor := TColorTools.ColorToGrayscale(fontColor);
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
x := FButtonRect.Left + SmallButtonHalfBorderWidth x := FButtonRect.Left + SmallButtonHalfBorderWidth
@ -345,14 +345,7 @@ begin
x := x + 2 * SmallButtonPadding + SmallButtonGlyphWidth; x := x + 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( TGUITools.DrawText(ABuffer.Canvas, x, y, FCaption, fontColor, ClipRect);
ABuffer.Canvas,
x,
y,
FCaption,
FontColor,
ClipRect
);
end; end;
function TSpkCustomCheckbox.GetChecked: Boolean; function TSpkCustomCheckbox.GetChecked: Boolean;