home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- import sys
- import wx
- import ctypes
- from ctypes.wintypes import RECT, byref
- from wx import Rect
- from platform import platform
- from util import Storage
- user32 = ctypes.windll.user32
- gdi32 = ctypes.windll.gdi32
- 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))
- states = Storage(inactive = 256, pushed = 512, checked = 1024, transparent = 2048, hot = 4096, adjustrect = 8192, flat = 16384, mono = 32768)
-
- def rect2wx(winRECT):
- return Rect(winRECT.left, winRECT.top, winRECT.right - winRECT.left, winRECT.bottom - winRECT.top)
-
- _smokeFrame = None
-
- try:
- from cgui import ApplySmokeAndMirrors
- except ImportError:
- print >>sys.stderr, 'WARNING: using slow ApplySmokeAndMirrors'
-
- def ApplySmokeAndMirrors(win, shape = None, ox = 0, oy = 0):
- global _smokeFrame
- if _smokeFrame is None:
- _smokeFrame = wx.Frame(wx.FindWindowByName('Buddy List'), -1, '', style = wx.FRAME_SHAPED)
-
- def on_destroy(e):
- e.Skip()
- if e.EventObject is _smokeFrame:
-
- globals()['ApplySmokeAndMirrors'] = lambda win, shape = None, ox = 0, oy = 0: pass
-
-
- _smokeFrame.Bind(wx.EVT_WINDOW_DESTROY, on_destroy)
-
- if isinstance(shape, (int, type(None))):
- return user32.SetWindowRgn(win.Handle, shape, True)
-
- rgn = gdi32.CreateRectRgn(0, 0, *win.Size)
- if shape:
- if isinstance(shape, wx.Region):
- region = shape
- elif not shape.GetMask():
- image = wx.ImageFromBitmap(shape)
- image.ConvertAlphaToMask(200)
- bitmap = wx.BitmapFromImage(image)
- else:
- bitmap = shape
- region = wx.RegionFromBitmap(bitmap)
- _smokeFrame.SetShape(region)
- user32.GetWindowRgn(_smokeFrame.Handle, rgn)
- gdi32.OffsetRgn(rgn, -1 + ox, -1 + oy)
-
- user32.SetWindowRgn(win.Handle, rgn, True)
- gdi32.DeleteObject(rgn)
-
-
-
- def GetRgn(win):
- rgn = gdi32.CreateRectRgn(0, 0, *win.Size)
- type = user32.GetWindowRgn(win.Handle, rgn)
- if not type:
- rgn = gdi32.CreateRectRgn(0, 0, win.Rect.Right, win.Rect.Bottom)
-
- return rgn
-
-
- def SmokeAndMirrorsBomb(win, windows):
- rgn = gdi32.CreateRectRgn(0, 0, 0, 0)
- shown = _[1]
- rgns = [ GetRgn(window) for window in shown ]
- for i in xrange(len(shown)):
- gdi32.OffsetRgn(rgns[i], *shown[i].Position)
- gdi32.CombineRgn(rgn, rgn, rgns[i], 2)
- gdi32.DeleteObject(rgns[i])
-
- user32.SetWindowRgn(win.Handle, rgn, True)
- gdi32.DeleteObject(rgn)
-
- SB_HORZ = 0
- SB_VERT = 1
- SB_BOTH = 3
- WS_EX_LAYERED = 524288
- _user32 = ctypes.windll.user32
- GetWindowLongA = _user32.GetWindowLongA
- SetWindowLongA = _user32.SetWindowLongA
-
- try:
- GetLayeredWindowAttributes = _user32.GetLayeredWindowAttributes
- SetLayeredWindowAttributes = _user32.SetLayeredWindowAttributes
- except AttributeError:
- pass
-
- from ctypes import c_byte
-
- def ShowScrollbar(window, show):
- hwnd = window.GetHandle()
- scrollbar = SB_VERT
- _user32.ShowScrollBar(hwnd, scrollbar, show)
-
-
- def _setalpha_wxMSW_ctypes(window, alpha):
- hwnd = window.GetHandle()
- oldStyle = style = GetWindowLongA(hwnd, 0xFFFFFFECL)
- if alpha == 255:
- style &= ~WS_EX_LAYERED
- else:
- style |= WS_EX_LAYERED
- if oldStyle != style:
- SetWindowLongA(hwnd, 0xFFFFFFECL, style)
-
- SetLayeredWindowAttributes(hwnd, 0, alpha, 2)
- window._alpha = alpha
-
-
- def _donealpha_wxMSW_ctypes(window):
- if not window:
- return None
-
- hwnd = window.GetHandle()
- oldStyle = style = GetWindowLongA(hwnd, 0xFFFFFFECL)
- style &= ~WS_EX_LAYERED
- if getattr(window, '_alpha', 255) == 0:
- window.Hide()
-
- if oldStyle != style:
- SetWindowLongA(hwnd, 0xFFFFFFECL, style)
-
- window._alpha = 255
-
-
- def _getalpha_wxMSW_ctypes(window):
- return getattr(window, '_alpha', 255)
- hwnd = window.GetHandle()
- alpha = c_byte()
-
- try:
- GetLayeredWindowAttributes(hwnd, 0, alpha, 2)
- return alpha.value
- except AttributeError:
- return getattr(window, '_alpha', 255)
-
-
-
- def _drawnativecontrol_wxMSW(handle, rect, control, state = 0):
- _user32.DrawFrameControl(handle, rect, control[0], control[1] | state)
-
- setalpha = _setalpha_wxMSW_ctypes
- getalpha = _getalpha_wxMSW_ctypes
- donealpha = _donealpha_wxMSW_ctypes
-
- def DrawSubMenuArrow(dc, rect):
- wxRectToRECT = wxRectToRECT
- import gui.native.win.winextensions
- rect = wxRectToRECT(rect)
- _drawnativecontrol_wxMSW(dc.GetHDC(), byref(rect), controls.menuarrow, 0)
-
- if platform().startswith('Windows-2000'):
-
- setalpha = lambda *a: pass
-
- getalpha = lambda *a: 255
-
- fadein = lambda win, *a, **k: win.Show(True)
-
- def fadeout(win, speed = 'normal', on_done = None, from_ = None):
- win.Show(False)
- if on_done is not None:
- on_done()
-
-
-
-