home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / gui / uberwidgets / uberbook / tabmanager.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  5.5 KB  |  175 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  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
  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.         if self.destination and self.destination.tabbar.Rect.Contains(self.destination.ScreenToClient(wx.GetMousePosition())):
  96.             destination = self.destination
  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.DragFinish(True)
  104.                 destbar.dragtarget = page.tab
  105.                 destbar.dragside = 1
  106.             
  107.             for tab in list(currentbook.tabbar.tabs):
  108.                 currentbook.tabbar.tabs.remove(tab)
  109.                 tab.Destroy()
  110.             
  111.             self.fadeflag = True
  112.         
  113.         if self.destination:
  114.             self.destination.tabbar.Toggle()
  115.             self.destination.tabbar.dragtarget = None
  116.             self.destination.tabbar.dragorigin = None
  117.             self.destination.tabbar.dropmarker.Show(False)
  118.             self.destination.tabbar.dragside = None
  119.             self.destination = None
  120.         
  121.  
  122.     
  123.     def Notify(self, notebook = None):
  124.         self.source = notebook
  125.         if self.source:
  126.             self.dragtimer.Start(SimpleOverlayImage(notebook, self.source.tabbar.dragorigin))
  127.         
  128.  
  129.     
  130.     def Request(self, notebook = None):
  131.         self.destination = notebook
  132.  
  133.     
  134.     def Trigger(self):
  135.         if self.source:
  136.             self.source.tabbar.DragFinish()
  137.         
  138.  
  139.     
  140.     def ShowDropMarker(self, dropmarker = None):
  141.         if not dropmarker:
  142.             if self.dropmarker and not wx.IsDestroyed(self.dropmarker):
  143.                 self.dropmarker.Show(False)
  144.             
  145.             return None
  146.         
  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.wdt = WinDragTimer()
  159.         self.tabman = TabManager()
  160.         self.factory = create_window_func
  161.  
  162.     
  163.     def TabManager(self):
  164.         return self.tabman
  165.  
  166.     TabManager = property(TabManager)
  167.     
  168.     def NewWindow(self, tabman = None, pos = wx.DefaultPosition, size = None):
  169.         win = self.factory(pos, size)
  170.         win.Show(False)
  171.         fadein(win, 'normal')
  172.         return win
  173.  
  174.  
  175.