From b1273c0d8a737699859aae4c4564532a7f4ea162 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 25 Feb 2014 17:26:57 +0000 Subject: [PATCH] Fix wxGenericTreeCtrl::ScrollTo() for all ports, not just wxOSX. When scrolling down, make the item being scrolled into view completely visible instead of just showing its top part. The fix was already used for wxOSX but not for the other ports for some reason, do use it everywhere as this code is generic and behaves in the same way in all ports. Also fix the wrong comments about scrolling direction. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76014 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/treectlg.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 4539b8972d..87d0733ce4 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -2308,21 +2308,20 @@ void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) if ( itemY + itemHeight > start_y*PIXELS_PER_UNIT + clientHeight ) { - // need to scroll up by enough to show this item fully + // need to scroll down by enough to show this item fully itemY += itemHeight - clientHeight; -#ifdef __WXOSX__ + // because itemY below will be divided by PIXELS_PER_UNIT it may // be rounded down, with the result of the item still only being // partially visible, so make sure we are rounding up - itemY += PIXELS_PER_UNIT-1; -#endif + itemY += PIXELS_PER_UNIT - 1; } else if ( itemY > start_y*PIXELS_PER_UNIT ) { // item is already fully visible, don't do anything return; } - //else: scroll down to make this item the top one displayed + //else: scroll up to make this item the top one displayed Scroll(-1, itemY/PIXELS_PER_UNIT); }