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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import wx
  5. from gui.windowfx import fadein, fadeout
  6. from dragtimer import DragTimer, WinDragTimer
  7. from OverlayImage import SimpleOverlayImage
  8. from common import pref, profile
  9. from weakref import ref
  10.  
  11. class TabManager(object):
  12.     
  13.     def __init__(self):
  14.         self.books = []
  15.         self.source = None
  16.         self.destination = None
  17.         self.fadeflag = True
  18.         self.fadeobject = None
  19.         self.dropmarker = None
  20.         self.dragtimer = DragTimer(self)
  21.  
  22.     
  23.     def Register(self, book):
  24.         self.books.append(ref(book))
  25.  
  26.     
  27.     def UnRegister(self, book):
  28.         for bookref in self.books[:]:
  29.             if bookref() is book:
  30.                 self.books.remove(bookref)
  31.                 continue
  32.         
  33.  
  34.     
  35.     def ReadyBook(self, currentbook, pos):
  36.         if not (self.destination) or not self.destination.window.Rect.Contains(pos):
  37.             for bookref in self.books[:]:
  38.                 book = bookref()
  39.                 if book is None or wx.IsDestroyed(book):
  40.                     self.books.remove(bookref)
  41.                     continue
  42.                 if book.window != currentbook.window:
  43.                     rect = book.window.Rect
  44.                     if rect.Contains(pos) and self.destination != book:
  45.                         self.destination = book
  46.                         self.destination.tabbar.Toggle(True)
  47.                     
  48.                     if self.destination and not rect.Contains(pos) and self.destination == book:
  49.                         tb = self.destination.tabbar
  50.                         tb.Toggle()
  51.                         tb.dragtarget = None
  52.                         tb.dragorigin = None
  53.                         tb.dropmarker.Show(False)
  54.                         tb.dragside = None
  55.                         self.destination = None
  56.                         if not self.fadeflag:
  57.                             fadein(currentbook.window, pref('tabs.fade_speed', 'normal'))
  58.                             if currentbook.preview:
  59.                                 currentbook.preview.Show(False)
  60.                             
  61.                         
  62.                         self.fadeflag = True
  63.                     
  64.                 self.destination == book
  65.             
  66.         
  67.         if self.destination:
  68.             barrect = self.destination.tabbar.Rect
  69.             if barrect.Contains(self.destination.ScreenToClient(pos)):
  70.                 self.destination.tabbar.DragCalc(self.destination.tabbar.ScreenToClient(pos))
  71.                 self.destination.tabbar.dragorigin = None
  72.                 if currentbook.preview:
  73.                     currentbook.preview.Move(wx.GetMousePosition() + (2, 4))
  74.                 
  75.                 if self.fadeflag:
  76.                     self.fadeobject = currentbook.window.Show(False)
  77.                     if currentbook.preview:
  78.                         fadein(currentbook.preview, pref('tabs.fade_speed', 'normal'), to = currentbook.preview.alpha)
  79.                     
  80.                     self.fadeflag = False
  81.                 
  82.             else:
  83.                 self.destination.tabbar.dropmarker.Show(False)
  84.                 if not self.fadeflag:
  85.                     fadein(currentbook.window, pref('tabs.fade_speed', 'normal'))
  86.                     if currentbook.preview:
  87.                         currentbook.preview.Show(False)
  88.                     
  89.                 
  90.                 self.fadeflag = True
  91.         
  92.  
  93.     
  94.     def Transaction(self, currentbook):
  95.         destination = self.destination
  96.         if destination and destination.tabbar.Rect.Contains(self.destination.ScreenToClient(wx.GetMousePosition())):
  97.             pages = [ tab.page for tab in currentbook.tabbar.tabs ]
  98.             for i, page in enumerate(pages):
  99.                 destination.pagecontainer.Append(page)
  100.                 destbar = destination.tabbar
  101.                 destbar.Add(page, page.tab.active, False)
  102.                 destbar.dragorigin = page.tab
  103.                 destbar.Notebook.did_add(page.panel)
  104.                 destbar.DragFinish(True)
  105.                 destbar.dragtarget = page.tab
  106.                 destbar.dragside = 1
  107.             
  108.             for tab in list(currentbook.tabbar.tabs):
  109.                 currentbook.tabbar.tabs.remove(tab)
  110.                 tab.Destroy()
  111.             
  112.             self.fadeflag = True
  113.         
  114.         if destination:
  115.             destination.tabbar.Toggle()
  116.             destination.tabbar.dragtarget = None
  117.             destination.tabbar.dragorigin = None
  118.             destination.tabbar.dropmarker.Show(False)
  119.             destination.tabbar.dragside = None
  120.         
  121.         self.destination = None
  122.  
  123.     
  124.     def Notify(self, notebook = None):
  125.         self.source = notebook
  126.         if self.source:
  127.             self.dragtimer.Start(SimpleOverlayImage(notebook, self.source.tabbar.dragorigin))
  128.         
  129.  
  130.     
  131.     def Request(self, notebook = None):
  132.         self.destination = notebook
  133.  
  134.     
  135.     def Trigger(self):
  136.         if self.source:
  137.             self.source.tabbar.DragFinish()
  138.         
  139.  
  140.     
  141.     def ShowDropMarker(self, dropmarker = None):
  142.         if not dropmarker:
  143.             if self.dropmarker and not wx.IsDestroyed(self.dropmarker):
  144.                 self.dropmarker.Show(False)
  145.             
  146.             return None
  147.         if self.dropmarker and not wx.IsDestroyed(self.dropmarker) and self.dropmarker is not dropmarker:
  148.             self.dropmarker.Show(False)
  149.         
  150.         self.dropmarker = dropmarker
  151.         self.dropmarker.Show(True)
  152.  
  153.  
  154.  
  155. class TabWindowManager(object):
  156.     
  157.     def __init__(self, create_window_func):
  158.         self.factory = create_window_func
  159.  
  160.     
  161.     def NewWindow(self, pos = wx.DefaultPosition, size = None):
  162.         win = self.factory(pos, size)
  163.         win.Show(False)
  164.         fadein(win, 'normal')
  165.         return win
  166.  
  167.  
  168.