home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / gui / toolbox / scrolling.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  6.1 KB  |  172 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import wx
  5.  
  6. class ScrollWinBase(object):
  7.     
  8.     def BindScrollWin(self, obj):
  9.         return None
  10.         obj.Bind(wx.EVT_SCROLLWIN, self._on_scrollwin)
  11.  
  12.     
  13.     def _on_scrollwin(self, e):
  14.         pass
  15.  
  16.  
  17.  
  18. class ScrollWinMixin(ScrollWinBase):
  19.     
  20.     def _on_scrollwin(self, e):
  21.         scrollType = e.GetEventType()
  22.         horiz = e.GetOrientation() == wx.HORIZONTAL
  23.         if horiz:
  24.             return e.Skip()
  25.         if scrollType == wx.EVT_SCROLLWIN_THUMBTRACK or scrollType == wx.EVT_SCROLLWIN_THUMBRELEASE:
  26.             return e.Skip()
  27.         if scrollType == wx.EVT_SCROLLWIN_LINEDOWN:
  28.             self.ScrollLines(1)
  29.         elif scrollType == wx.EVT_SCROLLWIN_LINEUP:
  30.             self.ScrollLines(-1)
  31.         elif scrollType == wx.EVT_SCROLLWIN_PAGEUP:
  32.             self.ScrollPages(1)
  33.         elif scrollType == wx.EVT_SCROLLWIN_PAGEDOWN:
  34.             self.ScrollPages(-1)
  35.         else:
  36.             return e.Skip()
  37.         return horiz
  38.  
  39.  
  40.  
  41. class WheelBase(object):
  42.     
  43.     def get_wheel_lines(self, rotation, e):
  44.         return int(round((rotation / float(e.GetWheelDelta())) * e.LinesPerAction))
  45.  
  46.     
  47.     def rotation_for_lines(self, lines, e):
  48.         return int((float(e.GetWheelDelta()) / e.LinesPerAction) * lines)
  49.  
  50.     
  51.     def BindWheel(self, obj):
  52.         obj.Bind(wx.EVT_MOUSEWHEEL, self._on_mousewheel)
  53.  
  54.     
  55.     def _on_mousewheel(self, e):
  56.         pass
  57.  
  58.  
  59.  
  60. class WheelScrollMixin(WheelBase):
  61.     
  62.     def __init__(self, *a, **k):
  63.         super(WheelScrollMixin, self).__init__(*a, **k)
  64.         self.wheel_rotation_scroll = 0
  65.  
  66.     
  67.     def _on_mousewheel(self, e):
  68.         wheel_rotation_scroll = e.WheelRotation + self.wheel_rotation_scroll
  69.         lines = self.get_wheel_lines(wheel_rotation_scroll, e)
  70.         if lines:
  71.             self._do_scroll(e, -lines)
  72.             self.wheel_rotation_scroll = self.rotation_for_lines(-lines, e) + wheel_rotation_scroll
  73.         else:
  74.             self.wheel_rotation_scroll = wheel_rotation_scroll
  75.  
  76.     
  77.     def _do_scroll(self, e, lines):
  78.         self.ScrollLines(lines)
  79.  
  80.  
  81.  
  82. class FrozenLoopScrollMixin(object):
  83.     
  84.     def ScrollLines(self, lines):
  85.         abslines = int(abs(lines))
  86.         self.Frozen().__enter__()
  87.         
  88.         try:
  89.             for _i in xrange(abslines):
  90.                 super(FrozenLoopScrollMixin, self).ScrollLines(int(lines / abslines))
  91.         finally:
  92.             pass
  93.  
  94.  
  95.  
  96.  
  97. class WheelZoomMixin(WheelBase):
  98.     
  99.     def __init__(self, *a, **k):
  100.         super(WheelZoomMixin, self).__init__(*a, **k)
  101.         self.wheel_rotation_zoom = 0
  102.  
  103.     
  104.     def _on_mousewheel(self, e):
  105.         wheel_rotation_zoom = e.WheelRotation + self.wheel_rotation_zoom
  106.         lines = self.get_wheel_lines(wheel_rotation_zoom, e)
  107.         if lines > 0:
  108.             self.IncreaseTextSize()
  109.         elif lines < 0:
  110.             self.DecreaseTextSize()
  111.         else:
  112.             self.wheel_rotation_zoom = wheel_rotation_zoom
  113.  
  114.  
  115.  
  116. class WheelCtrlZoomMixin(WheelZoomMixin):
  117.     
  118.     def _on_mousewheel(self, e):
  119.         if e.CmdDown():
  120.             WheelZoomMixin._on_mousewheel(self, e)
  121.         else:
  122.             super(WheelZoomMixin, self)._on_mousewheel(e)
  123.  
  124.  
  125.  
  126. class WheelScrollCtrlZoomMixin(WheelCtrlZoomMixin, WheelScrollMixin):
  127.     pass
  128.  
  129.  
  130. class WheelScrollFastMixin(WheelScrollMixin):
  131.     
  132.     def _do_scroll(self, e, lines):
  133.         if self._fast_scroll_test(e):
  134.             self.ScrollPages(lines)
  135.         else:
  136.             return super(WheelScrollFastMixin, self)._do_scroll(e, lines)
  137.         return self._fast_scroll_test(e)
  138.  
  139.  
  140.  
  141. class WheelShiftScrollFastMixin(WheelScrollFastMixin):
  142.     
  143.     def _fast_scroll_test(self, e):
  144.         if e.ShiftDown():
  145.             return True
  146.         
  147.         try:
  148.             return super(WheelShiftScrollFastMixin, self)._fast_scroll_test(e)
  149.         except AttributeError:
  150.             e.ShiftDown()
  151.             e.ShiftDown()
  152.             return False
  153.  
  154.  
  155.  
  156.  
  157. class WheelCtrlScrollFastMixin(WheelScrollFastMixin):
  158.     
  159.     def _fast_scroll_test(self, e):
  160.         if e.CmdDown():
  161.             return True
  162.         
  163.         try:
  164.             return super(WheelCtrlScrollFastMixin, self)._fast_scroll_test(e)
  165.         except AttributeError:
  166.             e.CmdDown()
  167.             e.CmdDown()
  168.             return False
  169.  
  170.  
  171.  
  172.