added TListView.FindCaption from Matthijs Willemstein

git-svn-id: trunk@7095 -
This commit is contained in:
mattias 2005-04-21 16:15:52 +00:00
parent a94e69edd1
commit b045cbd550
3 changed files with 59 additions and 1 deletions

View File

@ -635,6 +635,7 @@ type
constructor Create(AOwner : TCustomListView);
destructor Destroy; override;
procedure Delete(const AIndex : Integer);
function FindCaption(StartIndex: Integer; Value: string; Partial, Inclusive, Wrap: Boolean): TListItem;
function FindData(const AData: Pointer): TListItem;
function Insert(const AIndex: Integer) : TListItem;
procedure InsertItem(AItem: TListItem; const AIndex: Integer);
@ -889,7 +890,7 @@ type
destructor Destroy; override;
procedure BeginUpdate;
procedure EndUpdate;
public
function FindCaption(StartIndex: Integer; Value: string; Partial, Inclusive, Wrap: Boolean): TListItem;
property BoundingRect: TRect read GetBoundingRect;
property Canvas: TCanvas read FCanvas;
property Checkboxes: Boolean index Ord(lvpCheckboxes) read GetProperty write SetProperty {$IFNDEF VER1_0}default False{$ENDIF};
@ -2408,6 +2409,9 @@ end.
{ =============================================================================
$Log$
Revision 1.171 2005/04/21 16:15:52 mattias
added TListView.FindCaption from Matthijs Willemstein
Revision 1.170 2005/03/07 00:52:51 mattias
various Delphi compatibilities from C Western

View File

@ -407,6 +407,12 @@ begin
then TWSCustomListViewClass(WidgetSetClass).EndUpdate(Self);
end;
function TCustomListView.FindCaption(StartIndex: Integer; Value: string;
Partial, Inclusive, Wrap: Boolean): TListItem;
begin
Result := FListItems.FindCaption(StartIndex, Value, Partial, Inclusive, Wrap);
end;
function TCustomListView.GetBoundingRect: TRect;
begin
if not HandleAllocated
@ -746,6 +752,9 @@ end;
{ =============================================================================
$Log$
Revision 1.45 2005/04/21 16:15:52 mattias
added TListView.FindCaption from Matthijs Willemstein
Revision 1.44 2005/02/26 18:01:19 mattias
fixed warnings

View File

@ -248,6 +248,48 @@ begin
inherited Destroy;
end;
{------------------------------------------------------------------------------}
{ TListItems FindCaption }
{------------------------------------------------------------------------------}
function TListItems.FindCaption(StartIndex: Integer; Value: string;
Partial, Inclusive, Wrap: Boolean): TListItem;
var
I: Integer;
CaptionFound, AllChecked: Boolean;
begin
result := nil;
if (Count = 0) or (StartIndex > Count) or (not Inclusive and (count = 1)) then Exit;
CaptionFound := False;
AllChecked := False;
if Inclusive then
I := StartIndex
else begin
I := succ(StartIndex);
if I >= Count then I := 0;
end;
if Wrap then Wrap := (StartIndex <> 0);
repeat
if not AllChecked then begin
if Partial then CaptionFound := pos(Value, Item[I].Caption) > 0
else CaptionFound := Value = Item[I].Caption;
end;
if not CaptionFound then begin
Inc(I);
if Wrap then begin
if I = Count then
I := 0
else
if I = StartIndex then
AllChecked := True;
end else begin
if I = Count then AllChecked := True;
end;
end;
until CaptionFound or AllChecked;
if CaptionFound then result := Item[I];
end;
{------------------------------------------------------------------------------}
{ TListItems FindData }
{------------------------------------------------------------------------------}
@ -467,6 +509,9 @@ end;
{ =============================================================================
$Log$
Revision 1.29 2005/04/21 16:15:52 mattias
added TListView.FindCaption from Matthijs Willemstein
Revision 1.28 2005/02/26 17:08:41 marc
* Reworked listviews to match new interface