unit applist;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, StdCtrls, ExtCtrls, Controls, common, Arrow;

type
//** One entry of Listaller's visual software lists
TListEntry = class(TPanel) //Helper class / a software entry
protected
AppLabel: TLabel;
DescLabel: TLabel;
Vlabel: TLabel;
Graphic: TImage;
pkg: String;
sid: String;
DArrow: TArrow;
IMemo: TMemo;
private
 procedure SetAppName(s: String);
 function GetAppName: String;
 procedure SetAppDesc(s: String);
 function GetAppDesc: String;
 procedure SetAppVersion(s: String);
 function GetAppVersion: String;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
//** Name of the application
property AppName: String read GetAppName write SetAppName;
//** Description of the application
property AppDesc: String read GetAppDesc write SetAppDesc;
//** Version of the application
property AppVersion: String read GetAppVersion write SetAppVersion;
//** Set the package
property PackageName: String read pkg write pkg;
//** Set an image for the entry
procedure SetImage(AImage: String);
//** Expands additional information
procedure ExpandInformation;
//** Contracts the information
procedure CollapseInformation;
end;

implementation

{ TListEntry }
constructor TListEntry.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
pkg:='';
self.Align:=alTop;
self.Height:=54;
self.BevelOuter:=BVNone;
self.BevelInner:=bvLowered;

AppLabel:=TLabel.Create(nil);
with AppLabel do begin
Parent:=Self;
AutoSize:=true;
Caption:='<appname>';
Font.Size:=15;
Anchors:=[akLeft,akTop];
Top:=4;
Left:=54;
end;

DescLabel:=TLabel.Create(nil);
with DescLabel do begin
Parent:=Self;
AutoSize:=true;
Anchors:=[akLeft,akTop];
Top:=24;
Left:=60;
Caption:='<description>';
end;

vLabel:=TLabel.Create(nil);
with vLabel do begin
Parent:=Self;
AutoSize:=true;
Anchors:=[akBottom,akRight];
Top:=self.Height-54;
Left:=self.Width-140;
Caption:='';
end;

Graphic:=TImage.Create(nil);
with Graphic do begin
Parent:=self;
Width:=32;
Height:=32;
Top:=8;
Left:=8;
Center:=true;
Stretch:=true;
Proportional:=true;
Anchors:=[akLeft];
//Picture.LoadFromFile(GetFile('graphics/spackage.png'));
end;

DArrow:=TArrow.Create(nil);
with DArrow do begin
Parent:=self;
AutoSize:=true;
ArrowType:=atDown;
Anchors:=[akBottom,akRight];
Top:=16;
end;
DArrow.Left:=Width-DArrow.Width-10;
end;

destructor TListEntry.Destroy;
begin
AppLabel.Free;
DArrow.free;
Graphic.free;
DescLabel.Free;
vLabel.Free;
if Assigned(IMemo) then IMemo.Free;
inherited Destroy;
end;

procedure TListEntry.SetAppName(s: String);
begin
 AppLabel.Caption:=s;
end;

function TListEntry.GetAppName: String;
begin
 Result:=AppLabel.Caption;
end;

procedure TListEntry.SetAppDesc(s: String);
begin
 DescLabel.Caption:=s;
end;

function TListEntry.GetAppDesc: String;
begin
 Result:=DescLabel.Caption;
end;

procedure TListEntry.SetAppVersion(s: String);
begin
 VLabel.Caption:=s;
end;

function TListEntry.GetAppVersion: String;
begin
 Result:=VLabel.Caption;
end;

procedure TListEntry.SetImage(AImage: String);
begin
Graphic.Picture.LoadFromFile(AImage);
end;

procedure TListEntry.ExpandInformation;
begin
Height:=200;
DArrow.ArrowType:=atUp;
end;

procedure TListEntry.CollapseInformation;
begin
Height:=54;
DArrow.ArrowType:=atDown;
end;

end.

