unit _DesktopIconList;

interface

uses
  System.Classes, System.Contnrs, Winapi.Windows;

type
  TDesktopIconItem = class(TObject)
  private
    FX: Integer;
    FY: Integer;
    FIconText: string;
    procedure SetX(const Value: Integer);
    procedure SetY(const Value: Integer);
    procedure SetIconText(const Value: string);
  public
    property IconText: string read FIconText write SetIconText;
    property X: Integer read FX write SetX;
    property Y: Integer read FY write SetY;
  end;

  TDesktopIconList = class(TObjectList)
  private
  protected
    function GetItem(Index: Integer): TDesktopIconItem;
    procedure SetItem(Index: Integer; AObject: TDesktopIconItem);
  public
    function Add(AObject: TDesktopIconItem): Integer;
    property Items[Index: Integer]: TDesktopIconItem read GetItem write SetItem;
    function GetItemByIconText(const AText: string): TDesktopIconItem;
  end;

implementation

{ TDesktopIconList }

function TDesktopIconList.Add(AObject: TDesktopIconItem): Integer;
begin
  Result := inherited Add(AObject);
end;

function TDesktopIconList.GetItem(Index: Integer): TDesktopIconItem;
begin
  Result := TDesktopIconItem(inherited Items[Index]);
end;

function TDesktopIconList.GetItemByIconText(
  const AText: string): TDesktopIconItem;
var
  i: Integer;
begin
  Result := nil;

  for i := 0 to Count - 1 do
  begin
    if Items[i].IconText = AText then
    begin
      Result := Items[i];
      break;
    end;
  end;
end;

procedure TDesktopIconList.SetItem(Index: Integer; AObject: TDesktopIconItem);
begin
  inherited Items[Index] := AObject;
end;

{ TDesktopIconItem }

procedure TDesktopIconItem.SetIconText(const Value: string);
begin
  FIconText := Value;
end;

procedure TDesktopIconItem.SetX(const Value: Integer);
begin
  FX := Value;
end;

procedure TDesktopIconItem.SetY(const Value: Integer);
begin
  FY := Value;
end;

end.
