| 1 | unit InfoPanelUnit;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|---|
| 7 | Dialogs, StdCtrls, ExtCtrls;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 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 |
|
|---|
| 34 | procedure Register;
|
|---|
| 35 |
|
|---|
| 36 | implementation
|
|---|
| 37 |
|
|---|
| 38 | constructor TInfoPanel.Create(AOwner: TComponent);
|
|---|
| 39 | begin
|
|---|
| 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;
|
|---|
| 98 | end;
|
|---|
| 99 |
|
|---|
| 100 | procedure Register;
|
|---|
| 101 | begin
|
|---|
| 102 | RegisterComponents('Chronosoft', [TInfoPanel]);
|
|---|
| 103 | end;
|
|---|
| 104 |
|
|---|
| 105 | function TInfoPanel.GetCaption: TCaption;
|
|---|
| 106 | begin
|
|---|
| 107 | GetCaption:= Label2.Caption;
|
|---|
| 108 | end;
|
|---|
| 109 |
|
|---|
| 110 | function TInfoPanel.GetImage: TPicture;
|
|---|
| 111 | begin
|
|---|
| 112 | GetImage:= Image1.Picture;
|
|---|
| 113 | end;
|
|---|
| 114 |
|
|---|
| 115 | function TInfoPanel.GetTitle: TCaption;
|
|---|
| 116 | begin
|
|---|
| 117 | GetTitle:= Label1.Caption;
|
|---|
| 118 | end;
|
|---|
| 119 |
|
|---|
| 120 | procedure TInfoPanel.Resize;
|
|---|
| 121 | begin
|
|---|
| 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;
|
|---|
| 129 | end;
|
|---|
| 130 |
|
|---|
| 131 | procedure TInfoPanel.SetCaption(S: TCaption);
|
|---|
| 132 | begin
|
|---|
| 133 | Label2.Caption:= S;
|
|---|
| 134 | end;
|
|---|
| 135 |
|
|---|
| 136 | procedure TInfoPanel.SetImage(P: TPicture);
|
|---|
| 137 | begin
|
|---|
| 138 | Image1.Picture:= P;
|
|---|
| 139 | end;
|
|---|
| 140 |
|
|---|
| 141 | procedure TInfoPanel.SetName(const S: TComponentName);
|
|---|
| 142 | begin
|
|---|
| 143 | inherited;
|
|---|
| 144 | if Label1.Caption='' then Label1.Caption := Self.Name;
|
|---|
| 145 | if Label2.Caption='' then Label2.Caption := Self.Name;
|
|---|
| 146 | end;
|
|---|
| 147 |
|
|---|
| 148 | procedure TInfoPanel.SetTitle(S: TCaption);
|
|---|
| 149 | begin
|
|---|
| 150 | Label1.Caption:= S;
|
|---|
| 151 | end;
|
|---|
| 152 |
|
|---|
| 153 | end.
|
|---|