optimizing scrolling

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@50130 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2007-11-21 13:05:15 +00:00
parent 51156271b7
commit 54be106d59

View File

@@ -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 );
}