source: trunk/Packages/CevoComponents/ButtonB.pas

Last change on this file was 554, checked in by chronos, 3 weeks ago
  • Added: TButtonG class as a button class component referencing TGraphicSet item.
  • Modified: Code cleanup.
File size: 1.5 KB
Line 
1unit ButtonB;
2
3interface
4
5uses
6 ButtonBase, Classes, LCLIntf, LCLType,
7 {$IFDEF DPI}Dpi.Graphics{$ELSE}Graphics{$ENDIF};
8
9type
10 TButtonB = class(TButtonBase)
11 constructor Create(AOwner: TComponent); override;
12 private
13 FMask: TBitmap;
14 FIndex: Integer;
15 procedure SetIndex(Text: Integer);
16 protected
17 procedure Paint; override;
18 public
19 property Mask: TBitmap read FMask write FMask;
20 published
21 property Visible;
22 property ButtonIndex: Integer read FIndex write SetIndex;
23 property OnClick;
24 end;
25
26procedure Register;
27
28
29implementation
30
31uses
32 ScreenTools;
33
34procedure Register;
35begin
36 RegisterComponents('C-evo', [TButtonB]);
37end;
38
39constructor TButtonB.Create(AOwner: TComponent);
40begin
41 inherited;
42 ShowHint := True;
43 SetBounds(0, 0, 25, 25);
44end;
45
46procedure TButtonB.Paint;
47begin
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;
62end;
63
64procedure TButtonB.SetIndex(Text: Integer);
65begin
66 if Text <> FIndex then begin
67 FIndex := Text;
68 Invalidate;
69 end;
70end;
71
72end.
Note: See TracBrowser for help on using the repository browser.