home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 September / maximum-cd-2009-09.iso / DiscContents / digsby_setup.exe / lib / wx / lib / scrolledpanel.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  2.6 KB  |  78 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import wx
  5.  
  6. class ScrolledPanel(wx.PyScrolledWindow):
  7.     
  8.     def __init__(self, parent, id = -1, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.TAB_TRAVERSAL, name = 'scrolledpanel'):
  9.         wx.PyScrolledWindow.__init__(self, parent, id, pos = pos, size = size, style = style, name = name)
  10.         self.SetInitialSize(size)
  11.         self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
  12.  
  13.     
  14.     def SetupScrolling(self, scroll_x = True, scroll_y = True, rate_x = 20, rate_y = 20):
  15.         if not scroll_x:
  16.             rate_x = 0
  17.         
  18.         if not scroll_y:
  19.             rate_y = 0
  20.         
  21.         sizer = self.GetSizer()
  22.         if sizer:
  23.             (w, h) = sizer.GetMinSize()
  24.             if rate_x:
  25.                 w += rate_x - w % rate_x
  26.             
  27.             if rate_y:
  28.                 h += rate_y - h % rate_y
  29.             
  30.             self.SetVirtualSize((w, h))
  31.         
  32.         self.SetScrollRate(rate_x, rate_y)
  33.         wx.CallAfter(self._SetupAfter)
  34.  
  35.     
  36.     def _SetupAfter(self):
  37.         self.SetVirtualSize(self.GetBestVirtualSize())
  38.         self.Scroll(0, 0)
  39.  
  40.     
  41.     def OnChildFocus(self, evt):
  42.         evt.Skip()
  43.         child = evt.GetWindow()
  44.         self.ScrollChildIntoView(child)
  45.  
  46.     
  47.     def ScrollChildIntoView(self, child):
  48.         (sppu_x, sppu_y) = self.GetScrollPixelsPerUnit()
  49.         (vs_x, vs_y) = self.GetViewStart()
  50.         cr = child.GetRect()
  51.         clntsz = self.GetClientSize()
  52.         (new_vs_x, new_vs_y) = (-1, -1)
  53.         if cr.x < 0 and sppu_x > 0:
  54.             new_vs_x = vs_x + cr.x / sppu_x
  55.         
  56.         if cr.y < 0 and sppu_y > 0:
  57.             new_vs_y = vs_y + cr.y / sppu_y
  58.         
  59.         if cr.right > clntsz.width and sppu_x > 0:
  60.             diff = (cr.right - clntsz.width) / sppu_x
  61.             if cr.x - diff * sppu_x > 0:
  62.                 new_vs_x = vs_x + diff + 1
  63.             else:
  64.                 new_vs_x = vs_x + cr.x / sppu_x
  65.         
  66.         if cr.bottom > clntsz.height and sppu_y > 0:
  67.             diff = (cr.bottom - clntsz.height) / sppu_y
  68.             if cr.y - diff * sppu_y > 0:
  69.                 new_vs_y = vs_y + diff + 1
  70.             else:
  71.                 new_vs_y = vs_y + cr.y / sppu_y
  72.         
  73.         if new_vs_x != -1 or new_vs_y != -1:
  74.             self.Scroll(new_vs_x, new_vs_y)
  75.         
  76.  
  77.  
  78.