LCL: added Delphi compatibile function TCustomListView.FindData(StartIndex: Integer; Value: Pointer; Inclusive, Wrap: Boolean): TListItem;

git-svn-id: trunk@31480 -
This commit is contained in:
zeljko 2011-06-30 15:11:09 +00:00
parent 8ccc414025
commit 31a93e1b6e
3 changed files with 42 additions and 3 deletions

View File

@ -852,7 +852,8 @@ type
function FindCaption(StartIndex: Integer; Value: string;
Partial, Inclusive, Wrap: Boolean;
PartStart: Boolean = True): TListItem;
function FindData(const AData: Pointer): TListItem;
function FindData(const AData: Pointer): TListItem; overload;
function FindData(StartIndex: Integer; Value: Pointer; Inclusive, Wrap: Boolean): TListItem; overload;
function GetEnumerator: TListItemsEnumerator;
function IndexOf(const AItem: TListItem): Integer;
function Insert(const AIndex: Integer) : TListItem;
@ -1183,6 +1184,7 @@ type
procedure EndUpdate;
procedure Repaint; override;
function FindCaption(StartIndex: Integer; Value: string; Partial, Inclusive, Wrap: Boolean; PartStart: Boolean = True): TListItem;
function FindData(StartIndex: Integer; Value: Pointer; Inclusive, Wrap: Boolean): TListItem;
function GetHitTestInfoAt(X, Y: Integer): THitTests;
function GetItemAt(x,y: integer): TListItem;
property BoundingRect: TRect read GetBoundingRect;

View File

@ -863,6 +863,12 @@ begin
Result := FListItems.FindCaption(StartIndex, Value, Partial, Inclusive, Wrap);
end;
function TCustomListView.FindData(StartIndex: Integer; Value: Pointer;
Inclusive, Wrap: Boolean): TListItem;
begin
Result := FListItems.FindData(StartIndex, Value, Inclusive, Wrap);
end;
function TCustomListView.GetBoundingRect: TRect;
begin
if not HandleAllocated

View File

@ -436,11 +436,42 @@ begin
FCacheItem := Result;
Exit;
end;
end;
end;
Result := nil;
end;
function TListItems.FindData(StartIndex: Integer; Value: Pointer; Inclusive,
Wrap: Boolean): TListItem;
var
AnItem: TListItem;
i: Integer;
begin
Result := nil;
if Inclusive then Dec(StartIndex);
for i := StartIndex + 1 to Count - 1 do
begin
AnItem := Item[i];
if (AnItem <> nil) and (AnItem.Data = Value) then
begin
Result := AnItem;
exit;
end;
end;
if Wrap then
begin
if Inclusive then Inc(StartIndex);
for i := 0 to StartIndex - 1 do
begin
AnItem := Item[i];
if (AnItem <> nil) and (AnItem.Data = Value) then
begin
Result := AnItem;
exit;
end;
end;
end;
end;
function TListItems.GetEnumerator: TListItemsEnumerator;
begin
Result := TListItemsEnumerator.Create(Self);