From 383c1ee5f1a7c4624c7af98c701cb494fb728f84 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 12 Jan 2004 15:04:41 +0000 Subject: [PATCH] implemented TCustomListBox.ItemAtPos git-svn-id: trunk@5054 - --- lcl/include/customlistbox.inc | 18 ++++++++++++++++++ lcl/stdctrls.pp | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/lcl/include/customlistbox.inc b/lcl/include/customlistbox.inc index daa4ded20f..57ede32e7c 100644 --- a/lcl/include/customlistbox.inc +++ b/lcl/include/customlistbox.inc @@ -457,6 +457,24 @@ begin Result:=GetListBoxIndexAtY(Self, Y); end; +{------------------------------------------------------------------------------ + function TCustomListBox.ItemAtPos(const Pos: TPoint; Existing: Boolean + ): Integer; + + Returns item index at y coordinate (including scrolling) +------------------------------------------------------------------------------} +function TCustomListBox.ItemAtPos(const Pos: TPoint; Existing: Boolean + ): Integer; +begin + Result:=GetIndexAtY(Pos.Y); + if Existing then begin + if Result>=Items.Count then Result:=-1; + end else begin + if (Result<0) and (Result>Items.Count) and PtInRect(ClientRect,Pos) then + Result:=Items.Count; + end; +end; + {------------------------------------------------------------------------------ function TCustomListBox.ItemRect(Index: Integer): TRect; diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp index c4708b3afe..a9f3f255f9 100644 --- a/lcl/stdctrls.pp +++ b/lcl/stdctrls.pp @@ -383,6 +383,7 @@ type constructor Create(AOwner : TComponent); override; destructor Destroy; override; function GetIndexAtY(Y: integer): integer; + function ItemAtPos(const Pos: TPoint; Existing: Boolean): Integer; function ItemRect(Index: Integer): TRect; procedure Clear; public @@ -1467,6 +1468,9 @@ end. { ============================================================================= $Log$ + Revision 1.116 2004/01/12 15:04:41 mattias + implemented TCustomListBox.ItemAtPos + Revision 1.115 2004/01/11 11:57:54 mattias implemented TCustomListBox.ItemRect for gtk1 intf