From c5117d42dada9d219a72bbe1888d1d74fad93ff4 Mon Sep 17 00:00:00 2001 From: micha Date: Fri, 21 May 2004 11:13:18 +0000 Subject: [PATCH] add measureitem to tcustomlistbox just like tcustomcombobox has git-svn-id: trunk@5492 - --- lcl/include/customlistbox.inc | 10 ++++++++++ lcl/interfaces/win32/win32winapi.inc | 25 ++++++++++++++----------- lcl/stdctrls.pp | 8 ++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/lcl/include/customlistbox.inc b/lcl/include/customlistbox.inc index a6e31d903a..1b466a9390 100644 --- a/lcl/include/customlistbox.inc +++ b/lcl/include/customlistbox.inc @@ -437,6 +437,16 @@ begin FItems.Clear; end; +{------------------------------------------------------------------------------ + procedure TCustomListBox.MeasureItem(Index: Integer; var TheHeight: Integer); + + ------------------------------------------------------------------------------} +procedure TCustomListBox.MeasureItem(Index: Integer; var TheHeight: Integer); +begin + if Assigned(OnMeasureItem) then + OnMeasureItem(Self,Index,TheHeight); +end; + {------------------------------------------------------------------------------ function TCustomListBox.GetIndexAtY(Y: integer): integer; diff --git a/lcl/interfaces/win32/win32winapi.inc b/lcl/interfaces/win32/win32winapi.inc index 70481350aa..b38a55b2ca 100644 --- a/lcl/interfaces/win32/win32winapi.inc +++ b/lcl/interfaces/win32/win32winapi.inc @@ -182,12 +182,12 @@ var begin with TLMMouseEvent(Message) do begin - WParam := Windows.WParam(ScrollInfo.nPos - (WheelDelta * Integer(ScrollInfo.nPage) * 4) div (120 * 10)); - if WParam > ScrollInfo.nMax then - WParam := ScrollInfo.nMax; - if WParam < ScrollInfo.nMin then - WParam := ScrollInfo.nMin; - WParam := SB_THUMBPOSITION or (WParam shl 16); + WParam := Windows.WParam(ScrollInfo.nPos - (WheelDelta * Integer(ScrollInfo.nPage) * 4) div (120 * 10)); + if WParam > ScrollInfo.nMax then + WParam := ScrollInfo.nMax; + if WParam < ScrollInfo.nMin then + WParam := ScrollInfo.nMin; + WParam := SB_THUMBPOSITION or (WParam shl 16); end; Windows.PostMessage(TWinControl(Sender).Handle, WM_VSCROLL, WParam, HWND(nil)); end; @@ -349,11 +349,11 @@ begin with TLMMeasureItem(Message).MeasureItemStruct^ do begin if Sender is TCustomListBox then - begin - itemHeight := TCustomListBox(Sender).ItemHeight; -// if TCustomListBox(Sender).Style = lbOwnerDrawVariable then -// TCustomListBox(Sender).MeasureItem(itemID, integer(itemHeight)); - end; + begin + itemHeight := TCustomListBox(Sender).ItemHeight; + if TCustomListBox(Sender).Style = lbOwnerDrawVariable then + TCustomListBox(Sender).MeasureItem(itemID, integer(itemHeight)); + end; end; end; @@ -2996,6 +2996,9 @@ end; { ============================================================================= $Log$ + Revision 1.113 2004/05/21 11:13:18 micha + add measureitem to tcustomlistbox just like tcustomcombobox has + Revision 1.112 2004/05/20 21:28:54 marc * Fixed win32 listview diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp index 397c975e40..67126240bc 100644 --- a/lcl/stdctrls.pp +++ b/lcl/stdctrls.pp @@ -351,6 +351,7 @@ type FItemHeight: Integer; FItemIndex: integer; FOnDrawItem: TDrawItemEvent; + FOnMeasureItem: TMeasureItemEvent; FSorted: boolean; FStyle: TListBoxStyle; FTopIndex: integer; @@ -383,6 +384,9 @@ type procedure SetStyle(Val : TListBoxStyle); virtual; procedure DrawItem(Index: Integer; ARect: TRect; State: TOwnerDrawState); virtual; + + property OnMeasureItem: TMeasureItemEvent + read FOnMeasureItem write FOnMeasureItem; public constructor Create(AOwner : TComponent); override; destructor Destroy; override; @@ -391,6 +395,7 @@ type function ItemRect(Index: Integer): TRect; function ItemVisible(Index: Integer): boolean; procedure MakeCurrentVisible; + procedure MeasureItem(Index: Integer; var TheHeight: Integer); virtual; procedure Clear; public property Align; @@ -1544,6 +1549,9 @@ end. { ============================================================================= $Log$ + Revision 1.143 2004/05/21 11:13:18 micha + add measureitem to tcustomlistbox just like tcustomcombobox has + Revision 1.142 2004/05/21 09:03:54 micha implement new borderstyle - centralize to twincontrol (protected)