From 54be106d59e2ac95dd86cd3b398fee8d58e39d62 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 21 Nov 2007 13:05:15 +0000 Subject: [PATCH] optimizing scrolling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@50130 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/utils.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index a04b05437d..a8f49fcc4d 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -2269,9 +2269,18 @@ void wxMacDataItemBrowserControl::MacScrollTo( unsigned int n ) GetScrollPosition( &top , &left ) ; wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n ); + // there is a bug in RevealItem that leads to situations + // in large lists, where the item does not get scrolled + // into sight, so we do a pre-scroll if necessary UInt16 height ; GetRowHeight( (DataBrowserItemID) item , &height ) ; - SetScrollPosition( n * ((UInt32)height) , left ) ; + UInt32 linetop = n * ((UInt32) height ); + UInt32 linebottom = linetop + height; + Rect rect ; + GetRect( &rect ); + + if ( linetop < top || linebottom > (top + rect.bottom - rect.top ) ) + SetScrollPosition( wxMax( n-2, 0 ) * ((UInt32)height) , left ) ; RevealItem( item , kDataBrowserRevealWithoutSelecting ); }