Fixed bug #10622 where Listview.ItemIndex did not exist

git-svn-id: trunk@22909 -
This commit is contained in:
andrew 2009-12-01 23:49:24 +00:00
parent ffcb9ab6f3
commit b88059e19b
3 changed files with 24 additions and 2 deletions

View File

@ -1030,6 +1030,7 @@ type
function GetFocused: TListItem;
function GetImageList(const ALvilOrd: Integer): TCustomImageList;
function GetHoverTime: Integer;
function GetItemIndex: Integer;
function GetProperty(const ALvpOrd: Integer): Boolean;
function GetSelCount: Integer;
function GetSelection: TListItem;
@ -1046,6 +1047,7 @@ type
procedure SetHoverTime(const AValue: Integer);
procedure SetIconOptions(const AValue: TIconOptions);
procedure SetImageList(const ALvilOrd: Integer; const AValue: TCustomImageList);
procedure SetItemIndex(const AValue: Integer);
procedure SetItems(const AValue : TListItems);
procedure SetItemVisible(const AValue: TListItem; const APartialOK: Boolean);
procedure SetOwnerData(const AValue: Boolean);
@ -1144,6 +1146,7 @@ type
property HotTrackStyles: TListHotTrackStyles read FHotTrackStyles write SetHotTrackStyles default [];
property IconOptions: TIconOptions read FIconOptions write SetIconOptions;
property ItemFocused: TListItem read GetFocused write SetFocused;
property ItemIndex: Integer read GetItemIndex write SetItemIndex;
property Items: TListItems read FListItems write SetItems;
// MultiSelect and ReadOnly should be protected, but can't because Carbon Interface
// needs to access this property and it cannot cast to TListItem, because we have
@ -1190,6 +1193,7 @@ type
// property HotTrackStyles;
// property HoverTime;
property IconOptions;
property ItemIndex;
property Items;
property LargeImages;
property MultiSelect;

View File

@ -737,6 +737,14 @@ begin
else Result := FHoverTime;
end;
function TCustomListView.GetItemIndex: Integer;
begin
Result := -1;
if Selected = nil then
Exit;
Result := Selected.Index;
end;
function TCustomListView.GetHitTestInfoAt(X, Y: Integer): THitTests;
begin
Result := [];
@ -909,6 +917,16 @@ begin
TWSCustomListViewClass(WidgetSetClass).SetImageList(Self, lvil, AValue);
end;
procedure TCustomListView.SetItemIndex(const AValue: Integer);
begin
if (AValue < -1) or (AValue >= Items.Count) then
raise Exception.Create(Format('index %d out of bounds',[AValue]));
if AValue = -1 then
Selected := nil
else
Selected := Items.Item[AValue];
end;
{------------------------------------------------------------------------------
TCustomListView SetSelection
------------------------------------------------------------------------------}

View File

@ -490,8 +490,8 @@ end;
* Params *
* *
* Target : The Control that will recieve the message LM_CHANGED *
* ItemIndex : Only used by Listviews. The Index of the Item that has *
* changed. *
* ItemIndex : Only used by Listviews and CheckBoxes. The Index of *
* the Item that has changed. *
* *
******************************************************************************}
function LCLSendChangedMsg(const Target: TControl; ItemIndex: WPARAM = 0): PtrInt;