home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- import wx
-
- class ScrolledPanel(wx.PyScrolledWindow):
-
- def __init__(self, parent, id = -1, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.TAB_TRAVERSAL, name = 'scrolledpanel'):
- wx.PyScrolledWindow.__init__(self, parent, id, pos = pos, size = size, style = style, name = name)
- self.SetInitialSize(size)
- self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
-
-
- def SetupScrolling(self, scroll_x = True, scroll_y = True, rate_x = 20, rate_y = 20):
- if not scroll_x:
- rate_x = 0
-
- if not scroll_y:
- rate_y = 0
-
- 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.SetScrollRate(rate_x, rate_y)
- wx.CallAfter(self._SetupAfter)
-
-
- def _SetupAfter(self):
- self.SetVirtualSize(self.GetBestVirtualSize())
- self.Scroll(0, 0)
-
-
- def OnChildFocus(self, evt):
- evt.Skip()
- child = evt.GetWindow()
- self.ScrollChildIntoView(child)
-
-
- def ScrollChildIntoView(self, child):
- (sppu_x, sppu_y) = self.GetScrollPixelsPerUnit()
- (vs_x, vs_y) = self.GetViewStart()
- cr = child.GetRect()
- clntsz = self.GetClientSize()
- (new_vs_x, new_vs_y) = (-1, -1)
- if cr.x < 0 and sppu_x > 0:
- new_vs_x = vs_x + cr.x / sppu_x
-
- if cr.y < 0 and sppu_y > 0:
- new_vs_y = vs_y + cr.y / sppu_y
-
- if cr.right > clntsz.width and sppu_x > 0:
- diff = (cr.right - clntsz.width) / sppu_x
- if cr.x - diff * sppu_x > 0:
- new_vs_x = vs_x + diff + 1
- else:
- new_vs_x = vs_x + cr.x / sppu_x
-
- if cr.bottom > clntsz.height and sppu_y > 0:
- diff = (cr.bottom - clntsz.height) / sppu_y
- if cr.y - diff * sppu_y > 0:
- new_vs_y = vs_y + diff + 1
- else:
- new_vs_y = vs_y + cr.y / sppu_y
-
- if new_vs_x != -1 or new_vs_y != -1:
- self.Scroll(new_vs_x, new_vs_y)
-
-
-
-