DateTimePicker: small code refactoring

git-svn-id: trunk@63925 -
This commit is contained in:
zoran 2020-09-26 20:45:58 +00:00
parent 5779a01102
commit c0a1785e24

View File

@ -3656,7 +3656,8 @@ begin
end;
procedure TDTSpeedButton.Paint;
procedure DrawDropDownArrow(const Canvas: TCanvas; const DropDownButtonRect: TRect);
procedure DrawThemedDropDownArrow;
var
Details: TThemedElementDetails;
ArrowState: TThemedToolBar;
@ -3669,17 +3670,23 @@ procedure TDTSpeedButton.Paint;
ArrowState := ttbSplitButtonDropDownDisabled;
Details := ThemeServices.GetElementDetails(ArrowState);
ASize := ThemeServices.GetDetailSize(Details);
ARect := DropDownButtonRect;
ARect := Rect(0, 0, Width, Height);
InflateRect(ARect, -(ARect.Right - ARect.Left - ASize.cx) div 2, 0);
ThemeServices.DrawElement(Canvas.Handle, Details, ARect);
end;
const
ArrowColor = TColor($8D665A);
var
X, Y: Integer;
begin
inherited Paint;
if DTPicker.FArrowShape = asTheme then
DrawThemedDropDownArrow
else begin
// First I ment to put arrow images in a lrs file. In my opinion, however, that
// wouldn't be an elegant option for so simple shapes.
@ -3692,9 +3699,6 @@ begin
{ Let's draw shape of the arrow on the button: }
case DTPicker.FArrowShape of
asTheme:
DrawDropDownArrow(Canvas, Rect(0, 0, Width, Height));
asClassicLarger:
{ triangle: }
Canvas.Polygon([Point(X + 0, Y + 1), Point(X + 8, Y + 1),
@ -3716,6 +3720,8 @@ begin
Canvas.Polygon([Point(X + 0, Y + 1), Point(X + 1, Y + 0),
Point(X + 2, Y + 1), Point(X + 6, Y + 1),Point(X + 7, Y + 0), Point(X + 8, Y + 1), Point(X + 4, Y + 5)]);
end;
end;
end;
procedure TCustomDateTimePicker.UpdateShowArrowButton;