source: tags/1.3.1/Packages/CevoComponents/ButtonB.pas

Last change on this file was 290, checked in by chronos, 3 years ago
  • Modified: Use FreeAndNil instead of Free as defensive measure.
  • Modified: Use ihnerited without same method name specification.
File size: 1.5 KB
Line 
1unit ButtonB;
2
3interface
4
5uses
6 ButtonBase, Classes, Graphics, LCLIntf, LCLType;
7
8type
9 TButtonB = class(TButtonBase)
10 constructor Create(aOwner: TComponent); override;
11 private
12 FMask: TBitmap;
13 FIndex: integer;
14 procedure SetIndex(Text: integer);
15 public
16 property Mask: TBitmap read FMask write FMask;
17 published
18 property Visible;
19 property ButtonIndex: integer read FIndex write SetIndex;
20 property OnClick;
21 protected
22 procedure Paint; override;
23 end;
24
25procedure Register;
26
27
28implementation
29
30uses
31 ScreenTools;
32
33procedure Register;
34begin
35 RegisterComponents('C-evo', [TButtonB]);
36end;
37
38constructor TButtonB.Create(aOwner: TComponent);
39begin
40 inherited;
41 ShowHint := True;
42 SetBounds(0, 0, 25, 25);
43end;
44
45procedure TButtonB.Paint;
46begin
47 with Canvas do
48 if FGraphic <> nil then begin
49 BitBltCanvas(Canvas, 0, 0, 25, 25, FGraphic.Canvas, 169,
50 243 + 26 * Byte(FDown));
51 if FIndex >= 0 then begin
52 BitBltCanvas(Canvas, 0, 0, 25, 25, FMask.Canvas,
53 1 + FIndex mod 12 * 26, 337 + FIndex div 12 * 26, SRCAND);
54 BitBltCanvas(Canvas, 0, 0, 25, 25, FGraphic.Canvas,
55 1 + FIndex mod 12 * 26, 337 + FIndex div 12 * 26, SRCPAINT);
56 end
57 end else begin
58 Brush.Color := $0000FF;
59 FrameRect(Rect(0, 0, 25, 25));
60 end;
61end;
62
63procedure TButtonB.SetIndex(Text: integer);
64begin
65 if Text <> FIndex then begin
66 FIndex := Text;
67 Invalidate;
68 end;
69end;
70
71end.
Note: See TracBrowser for help on using the repository browser.