1 | unit ButtonA;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | ButtonBase, Classes, Graphics, LCLIntf, LCLType, ScreenTools;
|
---|
7 |
|
---|
8 | type
|
---|
9 | TButtonA = class(TButtonBase)
|
---|
10 | constructor Create(aOwner: TComponent); override;
|
---|
11 | private
|
---|
12 | FCaption: string;
|
---|
13 | procedure SetCaption(Text: string);
|
---|
14 | procedure SetFont(const Font: TFont);
|
---|
15 | published
|
---|
16 | property Visible;
|
---|
17 | property Caption: string read FCaption write SetCaption;
|
---|
18 | property OnClick;
|
---|
19 | public
|
---|
20 | property Font: TFont write SetFont;
|
---|
21 | protected
|
---|
22 | procedure Paint; override;
|
---|
23 | end;
|
---|
24 |
|
---|
25 | procedure Register;
|
---|
26 |
|
---|
27 |
|
---|
28 | implementation
|
---|
29 |
|
---|
30 | procedure Register;
|
---|
31 | begin
|
---|
32 | RegisterComponents('C-evo', [TButtonA]);
|
---|
33 | end;
|
---|
34 |
|
---|
35 | constructor TButtonA.Create(aOwner: TComponent);
|
---|
36 | begin
|
---|
37 | inherited Create(aOwner);
|
---|
38 | FCaption := '';
|
---|
39 | SetBounds(0, 0, 100, 25);
|
---|
40 | end;
|
---|
41 |
|
---|
42 | procedure TButtonA.Paint;
|
---|
43 | begin
|
---|
44 | with Canvas do
|
---|
45 | if FGraphic <> nil then
|
---|
46 | begin
|
---|
47 | BitBltCanvas(Canvas, 0, 0, 100, 25, Graphic.Canvas, 195,
|
---|
48 | 243 + 26 * Byte(Down));
|
---|
49 | Canvas.Brush.Style := bsClear;
|
---|
50 | Textout(50 - (TextWidth(FCaption) + 1) div 2, 12 - textheight(FCaption)
|
---|
51 | div 2, FCaption);
|
---|
52 | end
|
---|
53 | else
|
---|
54 | begin
|
---|
55 | Brush.Color := $0000FF;
|
---|
56 | FrameRect(Rect(0, 0, 100, 25))
|
---|
57 | end;
|
---|
58 | end;
|
---|
59 |
|
---|
60 | procedure TButtonA.SetCaption(Text: string);
|
---|
61 | begin
|
---|
62 | if Text <> FCaption then begin
|
---|
63 | FCaption := Text;
|
---|
64 | Invalidate;
|
---|
65 | end;
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TButtonA.SetFont(const Font: TFont);
|
---|
69 | begin
|
---|
70 | Canvas.Font.Assign(Font);
|
---|
71 | Canvas.Font.Color := $000000;
|
---|
72 | end;
|
---|
73 |
|
---|
74 | end.
|
---|