-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathbgraresizespeedbutton.pas
88 lines (74 loc) · 2.32 KB
/
bgraresizespeedbutton.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-License-Identifier: LGPL-3.0-linking-exception
{
Created by Fox. Part of BGRA Controls.
For detailed information see readme.txt
Site: https://sourceforge.net/p/bgra-controls/
Wiki: http://wiki.lazarus.freepascal.org/BGRAControls
Forum: http://forum.lazarus.freepascal.org/index.php/board,46.0.html
}
{******************************* CONTRIBUTOR(S) ******************************
- Edivando S. Santos Brasil | mailedivando@gmail.com
(Compatibility with delphi VCL 11/2018)
***************************** END CONTRIBUTOR(S) *****************************}
unit BGRAResizeSpeedButton;
{$I bgracontrols.inc}
interface
uses
Classes, SysUtils, Buttons, {$IFDEF FPC}LResources,{$ENDIF} Forms,
Controls, Graphics, Dialogs,
{$IFNDEF FPC}Types, BGRAGraphics, GraphType, FPImage, {$ENDIF}
BGRASpeedButton, BGRABitmap;
type
TBGRAResizeSpeedButton = class(TBGRASpeedButton)
private
{ Private declarations }
FBGRA: TBGRABitmap;
protected
{ Protected declarations }
function DrawGlyph(ACanvas: TCanvas; const AClient: TRect;
const {%H-}AOffset: TPoint; AState: TButtonState; {%H-}ATransparent: boolean;
{%H-}BiDiFlags: longint): TRect; {$IFDEF FPC}override;{$ENDIF}
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
end;
{$IFDEF FPC}procedure Register;{$ENDIF}
implementation
function TBGRAResizeSpeedButton.DrawGlyph(ACanvas: TCanvas;
const AClient: TRect; const AOffset: TPoint; AState: TButtonState;
ATransparent: boolean; BiDiFlags: longint): TRect;
begin
Result := Rect(0, 0, 0, 0);
if Glyph = nil then
Exit;
Result := AClient;
if Assigned(Glyph) and not Glyph.Empty then
begin
FBGRA.Assign(Glyph);
BGRAReplace(FBGRA, FBGRA.Resample(Self.Width - 6, Self.Height - 6));
if (AState = bsDown) or (Down = True) then
FBGRA.Draw(ACanvas, 4, 4, False)
else
FBGRA.Draw(ACanvas, 3, 3, False);
end;
end;
constructor TBGRAResizeSpeedButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FBGRA := TBGRABitmap.Create;
end;
destructor TBGRAResizeSpeedButton.Destroy;
begin
FBGRA.Free;
inherited Destroy;
end;
{$IFDEF FPC}
procedure Register;
begin
RegisterComponents('BGRA Button Controls', [TBGRAResizeSpeedButton]);
end;
{$ENDIF}
end.