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

Last change on this file was 431, checked in by chronos, 2 years ago
  • Modified: Changed WindowMode numerical constants to enumeration.
File size: 1.5 KB
Line 
1unit ButtonA;
2
3interface
4
5uses
6 ButtonBase, Classes, Graphics, LCLIntf, LCLType, ScreenTools, Types;
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;
38 FCaption := '';
39 SetBounds(0, 0, 100, 25);
40end;
41
42procedure TButtonA.Paint;
43var
44 TextSize: TSize;
45begin
46 with Canvas do
47 if FGraphic <> nil then begin
48 BitBltCanvas(Canvas, 0, 0, 100, 25, Graphic.Canvas, 195,
49 243 + 26 * Byte(Down));
50 Canvas.Brush.Style := bsClear;
51 TextSize := TextExtent(FCaption);
52 TextOut(50 - (TextSize.Width + 1) div 2,
53 12 - TextSize.Height div 2, FCaption);
54 end else 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.