1 | unit ButtonB;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | ButtonBase, Classes, LCLIntf, LCLType,
|
---|
7 | {$IFDEF DPI}Dpi.Graphics{$ELSE}Graphics{$ENDIF};
|
---|
8 |
|
---|
9 | type
|
---|
10 | TButtonB = class(TButtonBase)
|
---|
11 | constructor Create(aOwner: TComponent); override;
|
---|
12 | private
|
---|
13 | FMask: TBitmap;
|
---|
14 | FIndex: Integer;
|
---|
15 | procedure SetIndex(Text: Integer);
|
---|
16 | public
|
---|
17 | property Mask: TBitmap read FMask write FMask;
|
---|
18 | published
|
---|
19 | property Visible;
|
---|
20 | property ButtonIndex: Integer read FIndex write SetIndex;
|
---|
21 | property OnClick;
|
---|
22 | protected
|
---|
23 | procedure Paint; override;
|
---|
24 | end;
|
---|
25 |
|
---|
26 | procedure Register;
|
---|
27 |
|
---|
28 |
|
---|
29 | implementation
|
---|
30 |
|
---|
31 | uses
|
---|
32 | ScreenTools;
|
---|
33 |
|
---|
34 | procedure Register;
|
---|
35 | begin
|
---|
36 | RegisterComponents('C-evo', [TButtonB]);
|
---|
37 | end;
|
---|
38 |
|
---|
39 | constructor TButtonB.Create(aOwner: TComponent);
|
---|
40 | begin
|
---|
41 | inherited;
|
---|
42 | ShowHint := True;
|
---|
43 | SetBounds(0, 0, 25, 25);
|
---|
44 | end;
|
---|
45 |
|
---|
46 | procedure TButtonB.Paint;
|
---|
47 | begin
|
---|
48 | with Canvas do
|
---|
49 | if FGraphic <> nil then begin
|
---|
50 | BitBltCanvas(Canvas, 0, 0, 25, 25, FGraphic.Canvas, 169,
|
---|
51 | 243 + 26 * Byte(FDown));
|
---|
52 | if FIndex >= 0 then begin
|
---|
53 | BitBltCanvas(Canvas, 0, 0, 25, 25, FMask.Canvas,
|
---|
54 | 1 + FIndex mod 12 * 26, 337 + FIndex div 12 * 26, SRCAND);
|
---|
55 | BitBltCanvas(Canvas, 0, 0, 25, 25, FGraphic.Canvas,
|
---|
56 | 1 + FIndex mod 12 * 26, 337 + FIndex div 12 * 26, SRCPAINT);
|
---|
57 | end;
|
---|
58 | end else begin
|
---|
59 | Brush.Color := $0000FF;
|
---|
60 | FrameRect(Rect(0, 0, 25, 25));
|
---|
61 | end;
|
---|
62 | end;
|
---|
63 |
|
---|
64 | procedure TButtonB.SetIndex(Text: Integer);
|
---|
65 | begin
|
---|
66 | if Text <> FIndex then begin
|
---|
67 | FIndex := Text;
|
---|
68 | Invalidate;
|
---|
69 | end;
|
---|
70 | end;
|
---|
71 |
|
---|
72 | end.
|
---|