You've already forked lazarus-ccr
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:
@ -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;
|
case FButtonState of
|
||||||
|
bsIdle : fontColor := FAppearance.Element.IdleCaptionColor;
|
||||||
|
bsBtnHottrack,
|
||||||
|
bsDropdownHottrack : fontColor := FAppearance.Element.HotTrackCaptionColor;
|
||||||
|
bsBtnPressed,
|
||||||
|
bsDropdownPressed : fontColor := FAppearance.ELement.ActiveCaptionColor;
|
||||||
|
end;
|
||||||
if not(FEnabled) then
|
if not(FEnabled) then
|
||||||
case FButtonState of
|
fontColor := TColorTools.ColorToGrayscale(fontColor);
|
||||||
bsIdle : FontColor := TColorTools.ColorToGrayscale(FAppearance.Element.IdleCaptionColor);
|
|
||||||
bsBtnHottrack,
|
|
||||||
bsDropdownHottrack : FontColor := TColorTools.ColorToGrayscale(FAppearance.Element.HotTrackCaptionColor);
|
|
||||||
bsBtnPressed,
|
|
||||||
bsDropdownPressed : FontColor := TColorTools.ColorToGrayscale(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;
|
|
||||||
|
|
||||||
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;
|
||||||
|
Reference in New Issue
Block a user