home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / gui / uberwidgets / formattedinput2 / splittereventsmixin.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  3.5 KB  |  92 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import wx
  5. import config
  6. from common import setpref, pref
  7. wxMSW = 'wxMSW' in wx.PlatformInfo
  8. from FormattedExpandoTextCtrl import EVT_ETC_LAYOUT_NEEDED
  9. EVT_SIZE = None if config.platform == 'win' else wx.wxEVT_SIZE
  10.  
  11. class SplitterEventMixin(object):
  12.     
  13.     def OnExpandEventSplitter(self, event):
  14.         if self.resizing:
  15.             return None
  16.         self.OnExpandEvent(event)
  17.         if hasattr(self, 'splitter'):
  18.             best_size = self.BestSizeControl.BestSize.height
  19.             splitterpos = self.splitter.ClientSize.height - best_size - self.splitter.SashSize
  20.             self.splitter.SetSashPosition(splitterpos)
  21.             self.Layout()
  22.         
  23.  
  24.     
  25.     def BestSizeControl(self):
  26.         if 'wxMac' in wx.PlatformInfo:
  27.             return self.tc
  28.         return self
  29.  
  30.     BestSizeControl = property(BestSizeControl)
  31.     
  32.     def BindSplitter(self, splitter, heightpref = None):
  33.         splitter.Bind(wx.EVT_LEFT_DOWN, self.OnSplitterStart)
  34.         splitter.Bind(wx.EVT_LEFT_UP, self.OnSplitterSet)
  35.         self.splitter = splitter
  36.         self.heightpref = heightpref
  37.         self.resizing = False
  38.         self.Bind(EVT_ETC_LAYOUT_NEEDED, self.OnExpandEventSplitter)
  39.         if 'wxMac' in wx.PlatformInfo:
  40.             self.tc.Bind(wx.EVT_TEXT, self.OnExpandEventSplitter)
  41.         
  42.         tc = self.tc
  43.         tc.SetMinHeight(pref(self.heightpref, 0))
  44.         tc.ForceExpandEvent()
  45.         self.Top.Bind(wx.EVT_SHOW, self.OnTopShow)
  46.         self.Top.Bind(wx.EVT_SET_FOCUS, self.OnTopShow)
  47.         self.splitter.GrandParent.Bind(wx.EVT_SHOW, self.OnTopShow)
  48.         if hasattr(self.Top, 'iconizecallbacks'):
  49.             self.Top.iconizecallbacks.add(self.OnRestore)
  50.         else:
  51.             self.Top.Bind(wx.EVT_ICONIZE, self.OnRestore)
  52.  
  53.     
  54.     def OnSplitterStart(self, event):
  55.         self.resizing = True
  56.         tc = self.tc
  57.         baseh = tc.GetNatHeight()
  58.         tc.SetMinHeight(baseh)
  59.         self.BestSizeControl.MinSize = self.BestSizeControl.BestSize
  60.         event.Skip()
  61.  
  62.     
  63.     def OnSplitterSet(self, event):
  64.         self.resizing = False
  65.         event.Skip()
  66.         tc = self.tc
  67.         natHeight = tc.GetNatHeight()
  68.         setHeight = tc.GetSize().height
  69.         h = None if setHeight <= natHeight else setHeight
  70.         if hasattr(self, 'heightpref') and self.heightpref is not None:
  71.             setpref(self.heightpref, h)
  72.         
  73.         tc.SetMinHeight(h)
  74.  
  75.     
  76.     def OnTopShow(self, event):
  77.         event.Skip()
  78.         if not hasattr(event, 'GetShow') or event.GetShow():
  79.             self.tc.ForceExpandEvent()
  80.         
  81.  
  82.     
  83.     def OnRestore(self, event = None):
  84.         if event is not None:
  85.             event.Skip()
  86.         
  87.         if event is None or not event.Iconized():
  88.             wx.CallAfter(self.tc.ForceExpandEvent)
  89.         
  90.  
  91.  
  92.