source: InfoPanel/InfoPanelUnit.pas

Last change on this file was 3, checked in by chronos, 12 years ago
File size: 3.4 KB
Line 
1unit InfoPanelUnit;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ExtCtrls;
8
9type
10 TInfoPanel = class(TCustomControl)
11 private
12 Shape1: TShape;
13 Bevel1: TBevel;
14 Image1: TImage;
15 Label1: TLabel;
16 Label2: TLabel;
17 procedure SetTitle(S: TCaption);
18 function GetTitle: TCaption;
19 function GetImage: TPicture;
20 procedure SetImage(P: TPicture);
21 procedure SetCaption(S: TCaption);
22 function GetCaption: TCaption;
23 public
24 constructor Create(AOwner: TComponent); override;
25 procedure SetName(const S: TComponentName); override;
26 procedure Resize; override;
27 published
28 property Caption: TCaption read GetCaption write SetCaption;
29 property Image: TPicture read GetImage write SetImage;
30 property Title: TCaption read GetTitle write SetTitle;
31 property Align;
32 end;
33
34procedure Register;
35
36implementation
37
38constructor TInfoPanel.Create(AOwner: TComponent);
39begin
40 inherited;
41 Shape1:= TShape.Create(Self);
42 Label1:= TLabel.Create(Self);
43 Label2:= TLabel.Create(Self);
44 Bevel1:= TBevel.Create(Self);
45 Image1:= TImage.Create(Self);
46 InsertControl(Shape1);
47 InsertControl(Bevel1);
48 InsertControl(Label1);
49 InsertControl(Label2);
50 InsertControl(Image1);
51 Width:= 100;
52 Height:= 60;
53 Align:= alTop;
54 with Shape1 do begin
55 Align:= alClient;
56// Left := 0;
57// Top := 0;
58// Width := Self.Width;
59// Height := 59;
60// Anchors := [akLeft, akTop, akRight, akBottom];
61 Pen.Color := clWhite
62 end;
63 with Bevel1 do begin
64 Left := 0;
65 Top := Self.Height-2;
66 Width := Self.Width;
67 Height := 1;
68 Anchors := [akLeft, akRight, akBottom];
69 Style := bsRaised;
70 end;
71 with Image1 do begin
72 Stretch:= True;
73 Left := Self.Width - 53;
74 Top := 4;
75 Width := 49;
76 Height := 49;
77 Anchors := [akTop, akRight, akBottom];
78 Proportional := True;
79 end;
80 with Label1 do begin
81 Left := 16;
82 Top := 8;
83 Width := Self.Width - 100;
84 Height := 13;
85 Font.Style := [fsBold];
86 Transparent := True;
87 end;
88 with Label2 do begin
89 Left := 40;
90 Top := 24;
91 Width := Self.Width - 100;
92 Height := 26;
93 Anchors := [akLeft, akTop, akRight, akBottom];
94 AutoSize := False;
95 Transparent := True;
96 WordWrap := True;
97 end;
98end;
99
100procedure Register;
101begin
102 RegisterComponents('Chronosoft', [TInfoPanel]);
103end;
104
105function TInfoPanel.GetCaption: TCaption;
106begin
107 GetCaption:= Label2.Caption;
108end;
109
110function TInfoPanel.GetImage: TPicture;
111begin
112 GetImage:= Image1.Picture;
113end;
114
115function TInfoPanel.GetTitle: TCaption;
116begin
117 GetTitle:= Label1.Caption;
118end;
119
120procedure TInfoPanel.Resize;
121begin
122 inherited;
123 with Image1 do begin
124 Left:= Self.Width-4-Height;
125 Width:= Height;
126 end;
127 Label1.Width:= Image1.Left-Label1.Left-20;
128 Label2.Width:= Image1.Left-Label2.Left-20;
129end;
130
131procedure TInfoPanel.SetCaption(S: TCaption);
132begin
133 Label2.Caption:= S;
134end;
135
136procedure TInfoPanel.SetImage(P: TPicture);
137begin
138 Image1.Picture:= P;
139end;
140
141procedure TInfoPanel.SetName(const S: TComponentName);
142begin
143 inherited;
144 if Label1.Caption='' then Label1.Caption := Self.Name;
145 if Label2.Caption='' then Label2.Caption := Self.Name;
146end;
147
148procedure TInfoPanel.SetTitle(S: TCaption);
149begin
150 Label1.Caption:= S;
151end;
152
153end.
Note: See TracBrowser for help on using the repository browser.