source: branches/delphi/ButtonA.pas

Last change on this file was 2, checked in by chronos, 7 years ago
File size: 1.4 KB
Line 
1unit ButtonA;
2
3interface
4
5uses
6 ButtonBase,
7 WinProcs, Classes, Graphics;
8
9type
10 TButtonA = class(TButtonBase)
11 constructor Create(aOwner: TComponent); override;
12 private
13 FCaption: string;
14 procedure SetCaption(x: string);
15 procedure SetFont(const x: TFont);
16 published
17 property Visible;
18 property Caption: string read FCaption write SetCaption;
19 property OnClick;
20 public
21 property Font: TFont write SetFont;
22 protected
23 procedure Paint; override;
24 end;
25
26procedure Register;
27
28implementation
29
30procedure Register;
31begin
32RegisterComponents('Samples', [TButtonA]);
33end;
34
35constructor TButtonA.Create;
36begin
37inherited Create(aOwner);
38FCaption:='';
39SetBounds(0,0,100,25);
40end;
41
42procedure TButtonA.Paint;
43begin
44with Canvas do
45 if FGraphic<>nil then
46 begin
47 BitBlt(Canvas.Handle,0,0,100,25,Graphic.Canvas.Handle,
48 195,243+26*Byte(Down),SRCCOPY);
49 Canvas.Brush.Style:=bsClear;
50 Textout(50-(TextWidth(FCaption)+1) div 2,12-textheight(FCaption) div 2,
51 FCaption);
52 end
53 else begin Brush.Color:=$0000FF; FrameRect(Rect(0,0,100,25)) end
54end;
55
56procedure TButtonA.SetCaption(x: string);
57begin
58if x<>FCaption then
59 begin
60 FCaption:=x;
61 Invalidate
62 end
63end;
64
65procedure TButtonA.SetFont(const x: TFont);
66begin
67Canvas.Font.Assign(x);
68Canvas.Font.Color:=$000000;
69end;
70
71end.
72
Note: See TracBrowser for help on using the repository browser.