source: branches/AlphaChannel/Packages/CevoComponents/ButtonA.pas

Last change on this file was 209, checked in by chronos, 5 years ago
  • Modified: Code formatting.
File size: 1.5 KB
Line 
1unit ButtonA;
2
3interface
4
5uses
6 ButtonBase, Classes, Graphics, LCLIntf, LCLType, ScreenTools;
7
8type
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
25procedure Register;
26
27
28implementation
29
30procedure Register;
31begin
32 RegisterComponents('C-evo', [TButtonA]);
33end;
34
35constructor TButtonA.Create(aOwner: TComponent);
36begin
37 inherited Create(aOwner);
38 FCaption := '';
39 SetBounds(0, 0, 100, 25);
40end;
41
42procedure TButtonA.Paint;
43begin
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;
58end;
59
60procedure TButtonA.SetCaption(Text: string);
61begin
62 if Text <> FCaption then begin
63 FCaption := Text;
64 Invalidate;
65 end;
66end;
67
68procedure TButtonA.SetFont(const Font: TFont);
69begin
70 Canvas.Font.Assign(Font);
71 Canvas.Font.Color := $000000;
72end;
73
74end.
Note: See TracBrowser for help on using the repository browser.