-
Notifications
You must be signed in to change notification settings - Fork 19
/
ATPanelColor.pas
96 lines (79 loc) · 1.72 KB
/
ATPanelColor.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
Copyright (C) Alexey Torgashin, uvviewsoft.com
License: MPL 2.0 or LGPL
}
unit ATPanelColor;
interface
uses
Classes, SysUtils, Graphics, Controls, ExtCtrls, Types;
type
{ TATPanelColor }
TATPanelColor = class(TCustomControl)
private
FBorderWidth: integer; //new
FBorderColor: TColor;
public
constructor Create(AOwner: TComponent); override;
protected
procedure Paint; override;
procedure Resize; override;
published
property Align;
property Caption;
property Color;
property ParentColor;
property Enabled;
property Font;
property Visible;
property BorderColor: TColor read FBorderColor write FBorderColor default clBlack;
property BorderWidth: integer read FBorderWidth write FBorderWidth default 0;
property OnClick;
property OnDblClick;
property OnResize;
end;
implementation
{ TATPanelColor }
constructor TATPanelColor.Create(AOwner: TComponent);
begin
inherited;
Caption:= '';
Color:= clWhite;
BorderWidth:= 0;
BorderColor:= clBlack;
end;
procedure TATPanelColor.Paint;
var
R: TRect;
Pnt: TPoint;
Size: TSize;
i: integer;
begin
//inherited;
R:= ClientRect;
Canvas.Brush.Style:= bsSolid;
Canvas.Brush.Color:= Color;
Canvas.FillRect(R);
Canvas.Pen.Color:= BorderColor;
for i:= 1 to BorderWidth do
begin
Canvas.Rectangle(R);
Inc(R.Left);
Inc(R.Top);
Dec(R.Bottom);
Dec(R.Right);
end;
if Caption<>'' then
begin
Canvas.Font.Assign(Self.Font);
Size:= Canvas.TextExtent(Caption);
Pnt.X:= (R.Right-Size.cx) div 2;
Pnt.Y:= (R.Bottom-Size.cy) div 2;
Canvas.TextOut(Pnt.X, Pnt.Y, Caption);
end;
end;
procedure TATPanelColor.Resize;
begin
inherited Resize;
Invalidate;
end;
end.