unit InfoPanelUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TInfoPanel = class(TCustomControl)
  private
    Shape1: TShape;
    Bevel1: TBevel;
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    procedure SetTitle(S: TCaption);
    function GetTitle: TCaption;
    function GetImage: TPicture;
    procedure SetImage(P: TPicture);
    procedure SetCaption(S: TCaption);
    function GetCaption: TCaption;
  public
    constructor Create(AOwner: TComponent); override;
    procedure SetName(const S: TComponentName); override;
    procedure Resize; override;
  published
    property Caption: TCaption read GetCaption write SetCaption;
    property Image: TPicture read GetImage write SetImage;
    property Title: TCaption read GetTitle write SetTitle;
    property Align;
  end;

procedure Register;

implementation

constructor TInfoPanel.Create(AOwner: TComponent);
begin
  inherited;
  Shape1:= TShape.Create(Self);
  Label1:= TLabel.Create(Self);
  Label2:= TLabel.Create(Self);
  Bevel1:= TBevel.Create(Self);
  Image1:= TImage.Create(Self);
  InsertControl(Shape1);
  InsertControl(Bevel1);
  InsertControl(Label1);
  InsertControl(Label2);
  InsertControl(Image1);
  Width:= 100;
  Height:= 60;
  Align:= alTop;
  with Shape1 do begin
    Align:= alClient;
//    Left := 0;
//    Top := 0;
//    Width := Self.Width;
//    Height := 59;
//    Anchors := [akLeft, akTop, akRight, akBottom];
    Pen.Color := clWhite
  end;
  with Bevel1 do begin
    Left := 0;
    Top := Self.Height-2;
    Width := Self.Width;
    Height := 1;
    Anchors := [akLeft, akRight, akBottom];
    Style := bsRaised;
  end;
  with Image1 do begin
    Stretch:= True;
    Left := Self.Width - 53;
    Top := 4;
    Width := 49;
    Height := 49;
    Anchors := [akTop, akRight, akBottom];
    Proportional := True;
  end;
  with Label1 do begin
    Left := 16;
    Top := 8;
    Width := Self.Width - 100;
    Height := 13;
    Font.Style := [fsBold];
    Transparent := True;
  end;
  with Label2 do begin
    Left := 40;
    Top := 24;
    Width := Self.Width - 100;
    Height := 26;
    Anchors := [akLeft, akTop, akRight, akBottom];
    AutoSize := False;
    Transparent := True;
    WordWrap := True;
  end;
end;

procedure Register;
begin
  RegisterComponents('Chronosoft', [TInfoPanel]);
end;

function TInfoPanel.GetCaption: TCaption;
begin
  GetCaption:= Label2.Caption;
end;

function TInfoPanel.GetImage: TPicture;
begin
  GetImage:= Image1.Picture;
end;

function TInfoPanel.GetTitle: TCaption;
begin
  GetTitle:= Label1.Caption;
end;

procedure TInfoPanel.Resize;
begin
  inherited;
  with Image1 do begin
    Left:= Self.Width-4-Height;
    Width:= Height;
  end;
  Label1.Width:= Image1.Left-Label1.Left-20;
  Label2.Width:= Image1.Left-Label2.Left-20;
end;

procedure TInfoPanel.SetCaption(S: TCaption);
begin
  Label2.Caption:= S;
end;

procedure TInfoPanel.SetImage(P: TPicture);
begin
  Image1.Picture:= P;
end;

procedure TInfoPanel.SetName(const S: TComponentName);
begin
  inherited;
  if Label1.Caption='' then Label1.Caption := Self.Name;
  if Label2.Caption='' then Label2.Caption := Self.Name;
end;

procedure TInfoPanel.SetTitle(S: TCaption);
begin
  Label1.Caption:= S;
end;

end.
