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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import sys
  5. import wx
  6. import ctypes
  7. from ctypes.wintypes import RECT, byref
  8. from wx import Rect
  9. from platform import platform
  10. from util import Storage
  11. user32 = ctypes.windll.user32
  12. gdi32 = ctypes.windll.gdi32
  13. controls = Storage(captionclose = (1, 0), captionmin = (1, 1), captionmax = (1, 2), captionrestore = (1, 3), captionhelp = (1, 4), menuarrow = (2, 0), menucheck = (2, 1), menubullet = (2, 2), menuarrowright = (2, 4), scrollup = (3, 0), scrolldown = (3, 1), scrollleft = (3, 2), scrollright = (3, 3), scrollcombobox = (3, 5), scrollsizegrip = (3, 8), scrollsizegripright = (3, 16), buttoncheck = (1, 0), buttonradioimage = (4, 1), buttonradiomask = (4, 2), buttonradio = (4, 4), button3state = (4, 8), buttonpush = (4, 16))
  14. states = Storage(inactive = 256, pushed = 512, checked = 1024, transparent = 2048, hot = 4096, adjustrect = 8192, flat = 16384, mono = 32768)
  15.  
  16. def rect2wx(winRECT):
  17.     return Rect(winRECT.left, winRECT.top, winRECT.right - winRECT.left, winRECT.bottom - winRECT.top)
  18.  
  19. _smokeFrame = None
  20.  
  21. try:
  22.     from cgui import ApplySmokeAndMirrors
  23. except ImportError:
  24.     print >>sys.stderr, 'WARNING: using slow ApplySmokeAndMirrors'
  25.     
  26.     def ApplySmokeAndMirrors(win, shape = None, ox = 0, oy = 0):
  27.         global _smokeFrame
  28.         if _smokeFrame is None:
  29.             _smokeFrame = wx.Frame(wx.FindWindowByName('Buddy List'), -1, '', style = wx.FRAME_SHAPED)
  30.             
  31.             def on_destroy(e):
  32.                 e.Skip()
  33.                 if e.EventObject is _smokeFrame:
  34.                     
  35.                     globals()['ApplySmokeAndMirrors'] = lambda win, shape = None, ox = 0, oy = 0: pass
  36.                 
  37.  
  38.             _smokeFrame.Bind(wx.EVT_WINDOW_DESTROY, on_destroy)
  39.         
  40.         if isinstance(shape, (int, type(None))):
  41.             return user32.SetWindowRgn(win.Handle, shape, True)
  42.         rgn = gdi32.CreateRectRgn(0, 0, *win.Size)
  43.         user32.SetWindowRgn(win.Handle, rgn, True)
  44.         gdi32.DeleteObject(rgn)
  45.  
  46.  
  47.  
  48. def GetRgn(win):
  49.     rgn = gdi32.CreateRectRgn(0, 0, *win.Size)
  50.     type = user32.GetWindowRgn(win.Handle, rgn)
  51.     if not type:
  52.         rgn = gdi32.CreateRectRgn(0, 0, win.Rect.Right, win.Rect.Bottom)
  53.     
  54.     return rgn
  55.  
  56.  
  57. def SmokeAndMirrorsBomb(win, windows):
  58.     rgn = gdi32.CreateRectRgn(0, 0, 0, 0)
  59.     shown = _[1]
  60.     rgns = [ GetRgn(window) for window in shown ]
  61.     for i in xrange(len(shown)):
  62.         gdi32.OffsetRgn(rgns[i], *shown[i].Position)
  63.         gdi32.CombineRgn(rgn, rgn, rgns[i], 2)
  64.         gdi32.DeleteObject(rgns[i])
  65.     
  66.     user32.SetWindowRgn(win.Handle, rgn, True)
  67.     gdi32.DeleteObject(rgn)
  68.  
  69. SB_HORZ = 0
  70. SB_VERT = 1
  71. SB_BOTH = 3
  72. WS_EX_LAYERED = 524288
  73. _user32 = ctypes.windll.user32
  74. GetWindowLongA = _user32.GetWindowLongA
  75. SetWindowLongA = _user32.SetWindowLongA
  76.  
  77. try:
  78.     GetLayeredWindowAttributes = _user32.GetLayeredWindowAttributes
  79.     SetLayeredWindowAttributes = _user32.SetLayeredWindowAttributes
  80. except AttributeError:
  81.     pass
  82.  
  83. from ctypes import c_byte
  84. LWA_COLORKEY = 1
  85.  
  86. def SetColorKey(window, rgb_color_tuple):
  87.     color = ctypes.c_uint(0x0L | 16711680 & rgb_color_tuple[0] | 65280 & rgb_color_tuple[1] | 255 & rgb_color_tuple[2])
  88.     hwnd = window.Handle
  89.     style = GetWindowLongA(hwnd, 0xFFFFFFECL)
  90.     layered_style = style | WS_EX_LAYERED
  91.     if layered_style != style:
  92.         SetWindowLongA(hwnd, 0xFFFFFFECL, layered_style)
  93.     
  94.     SetLayeredWindowAttributes(hwnd, byref(color), 0, LWA_COLORKEY)
  95.  
  96.  
  97. def ShowScrollbar(window, show):
  98.     hwnd = window.GetHandle()
  99.     scrollbar = SB_VERT
  100.     _user32.ShowScrollBar(hwnd, scrollbar, show)
  101.  
  102.  
  103. def _setalpha_wxMSW_ctypes(window, alpha):
  104.     hwnd = window.GetHandle()
  105.     oldStyle = style = GetWindowLongA(hwnd, 0xFFFFFFECL)
  106.     if alpha == 255:
  107.         style &= ~WS_EX_LAYERED
  108.     else:
  109.         style |= WS_EX_LAYERED
  110.     if oldStyle != style:
  111.         SetWindowLongA(hwnd, 0xFFFFFFECL, style)
  112.     
  113.     SetLayeredWindowAttributes(hwnd, 0, alpha, 2)
  114.     window._alpha = alpha
  115.  
  116.  
  117. def _donealpha_wxMSW_ctypes(window):
  118.     if not window:
  119.         return None
  120.     hwnd = window.GetHandle()
  121.     style &= ~WS_EX_LAYERED
  122.     if oldStyle != style:
  123.         SetWindowLongA(hwnd, 0xFFFFFFECL, style)
  124.     
  125.     window._alpha = 255
  126.  
  127.  
  128. def _getalpha_wxMSW_ctypes(window):
  129.     return getattr(window, '_alpha', 255)
  130.     hwnd = window.GetHandle()
  131.     alpha = c_byte()
  132.     
  133.     try:
  134.         GetLayeredWindowAttributes(hwnd, 0, alpha, 2)
  135.         return alpha.value
  136.     except AttributeError:
  137.         return getattr(window, '_alpha', 255)
  138.  
  139.  
  140.  
  141. def _drawnativecontrol_wxMSW(handle, rect, control, state = 0):
  142.     _user32.DrawFrameControl(handle, rect, control[0], control[1] | state)
  143.  
  144. setalpha = _setalpha_wxMSW_ctypes
  145. getalpha = _getalpha_wxMSW_ctypes
  146. donealpha = _donealpha_wxMSW_ctypes
  147.  
  148. def DrawSubMenuArrow(dc, rect):
  149.     wxRectToRECT = wxRectToRECT
  150.     import gui.native.win.winextensions
  151.     rect = wxRectToRECT(rect)
  152.     _drawnativecontrol_wxMSW(dc.GetHDC(), byref(rect), controls.menuarrow, 0)
  153.  
  154. if platform().startswith('Windows-2000'):
  155.     
  156.     setalpha = lambda *a: pass
  157.     
  158.     getalpha = lambda *a: 255
  159.     
  160.     fadein = lambda win, *a, **k: win.Show(True)
  161.     
  162.     def fadeout(win, speed = 'normal', on_done = None, from_ = None):
  163.         win.Show(False)
  164.         if on_done is not None:
  165.             on_done()
  166.         
  167.  
  168.  
  169.