From d7116a786dc64d679ff5dad81fcfebd9885cc170 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 1 May 2003 17:54:05 +0000 Subject: [PATCH] Round up the virtual size to be a multiple of the scroll rate git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20414 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/wxPython/lib/scrolledpanel.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/wxPython/wxPython/lib/scrolledpanel.py b/wxPython/wxPython/lib/scrolledpanel.py index b8da67e498..1b8c79a844 100644 --- a/wxPython/wxPython/lib/scrolledpanel.py +++ b/wxPython/wxPython/lib/scrolledpanel.py @@ -27,8 +27,10 @@ as a proper class (and the demo is now converted to just use it.) pos=pos, size=size, style=style, name=name) + EVT_CHILD_FOCUS(self, self.OnChildFocus) - def SetupScrolling(self, scroll_x=True, scroll_y=True, rate_x=1, rate_y=1): + + def SetupScrolling(self, scroll_x=True, scroll_y=True, rate_x=20, rate_y=20): """ This function sets up the event handling necessary to handle scrolling properly. It should be called within the __init__ @@ -42,10 +44,18 @@ as a proper class (and the demo is now converted to just use it.) if not scroll_x: rate_x = 0 if not scroll_y: rate_y = 0 - self.SetScrollRate(rate_x, rate_y) + # Round up the virtual size to be a multiple of the scroll rate + sizer = self.GetSizer() + if sizer: + w, h = sizer.GetMinSize() + if rate_x: + w += rate_x - (w % rate_x) + if rate_y: + h += rate_y - (h % rate_y) + self.SetVirtualSize( (w, h) ) + self.SetVirtualSizeHints( w, h ) - self.GetSizer().SetVirtualSizeHints(self) - EVT_CHILD_FOCUS(self, self.OnChildFocus) + self.SetScrollRate(rate_x, rate_y) wxCallAfter(self.Scroll, 0, 0) # scroll back to top after initial events