home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from __future__ import with_statement
- import ctypes
- import sys
- import os
- from ctypes.wintypes import RECT
- from ctypes import byref, c_int, c_long, WinError
- from logging import getLogger
- log = getLogger('winhelpers')
- user32 = ctypes.windll.user32
- kernel32 = ctypes.windll.kernel32
- SetWindowLong = user32.SetWindowLongW
- CallWindowProc = user32.CallWindowProcW
- DefWindowProc = user32.DefWindowProcW
- WndProcType = ctypes.PYFUNCTYPE(c_int, c_long, c_int, c_int, c_int)
- GWL_WNDPROC = -4
- WM_SIZING = 532
- WM_MOVING = 534
- WM_ENTERSIZEMOVE = 561
- WM_EXITSIZEMOVE = 562
- WM_NCHITTEST = 132
- WM_WINDOWPOSCHANGING = 70
- GW_HWNDNEXT = 2
- import wx
-
- def bindwin32(win, msg, callback):
- if not hasattr(win, '_win32binder'):
- PlatformMessageBinder = PlatformMessageBinder
- import cgui
- win._win32binder = PlatformMessageBinder.ForWindow(win)
-
- win._win32binder.Bind(msg, callback)
-
-
- def unbindwin32(win, msg, callback):
- if not hasattr(win, '_win32binder'):
- return None
-
- win._win32binder.Unbind(msg, callback)
-
-
- wx.Window.ShowNoFocus = lambda win: win.Show(show = True, activate = False)
- if getattr(wx, 'WXPY', False):
- import new
- meth = new.instancemethod
- wx._Window.BindWin32 = meth(bindwin32, None, wx._Window)
- wx._Window.UnbindWin32 = meth(unbindwin32, None, wx._Window)
- else:
- wx.Window.BindWin32 = bindwin32
- wx.Window.UnbindWin32 = unbindwin32
-
- try:
- AttachThreadInput = user32.AttachThreadInput
- GetWindowThreadProcessId = user32.GetWindowThreadProcessId
- GetCurrentThreadId = kernel32.GetCurrentThreadId
- GetForegroundWindow = user32.GetForegroundWindow
- GetDesktopWindow = user32.GetDesktopWindow
- GetShellWindow = user32.GetShellWindow
- SetForegroundWindow = user32.SetForegroundWindow
- except:
- print >>sys.stderr, 'No ReallyRaise'
-
- wx.WindowClass.ReallyRaise = lambda win: win.Raise()
-
-
- def ReallyRaise(win):
- AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), 0), GetCurrentThreadId(), True)
- SetForegroundWindow(win.Handle)
- AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), 0), GetCurrentThreadId(), False)
-
- getattr(wx, '_Window', wx.Window).ReallyRaise = ReallyRaise
- GetLastInputInfo = user32.GetLastInputInfo
- GetTickCount = kernel32.GetTickCount
- GetLastError = kernel32.GetLastError
-
- class LastInputInfo(ctypes.Structure):
- _fields_ = [
- ('cbSize', ctypes.wintypes.UINT),
- ('dwTime', ctypes.wintypes.DWORD)]
-
- input_info = LastInputInfo()
- input_info.cbSize = ctypes.sizeof(input_info)
- input_info_ref = ctypes.byref(input_info)
-
- def GetUserIdleTime():
- if GetLastInputInfo(input_info_ref):
- return GetTickCount() - input_info.dwTime
- else:
- raise WinError()
-
- GetTopWindow = user32.GetTopWindow
- GetWindow = user32.GetWindow
- GetWindowRect = user32.GetWindowRect
- IsWindowVisible = user32.IsWindowVisible
- GetWindowLong = user32.GetWindowLongA
- GWL_EXSTYLE = -20
- WS_EX_TOPMOST = 8
-
- def win32ontop(hwnd):
- return bool(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
-
- from wx import FRAME_NO_TASKBAR
- from gui.native.win.winconstants import SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, SWP_FRAMECHANGED, WS_EX_APPWINDOW, GWL_EXSTYLE
- window_pos_flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED
- from ctypes import windll
- user32 = windll.user32
- GA_ROOT = 2
-
- def ctypes_import(src, **k):
- G = globals()
- for name, funcs in k.iteritems():
- dll = getattr(src, name)
- (G.update,)((lambda .0: for func in .0:
- (func, getattr(dll, func)))(funcs))
-
-
- SetWindowLongA = user32.SetWindowLongA
- GetWindowLongA = user32.GetWindowLongA
- SetWindowPos = user32.SetWindowPos
- GetParent = user32.GetParent
- SetParent = user32.SetParent
- FindWindowA = user32.FindWindowA
- ShowWindow = user32.ShowWindow
- GetAncestor = user32.GetAncestor
- SetLastError = kernel32.SetLastError
- GetLastError = kernel32.GetLastError
-
- def SetOnTaskbar(f, val):
- hwnd = f.Handle
- needs_show = f.IsShown()
- needs_focus = getattr(wx.Window.FindFocus(), 'Top', None) is f
- f.Frozen().__enter__()
-
- try:
- if needs_show:
- f.Hide()
-
- SetLastError(0)
- if val:
- f.WindowStyle = f.WindowStyle & ~FRAME_NO_TASKBAR
- res = SetWindowLongA(hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) | WS_EX_APPWINDOW)
- else:
- f.WindowStyle = f.WindowStyle | FRAME_NO_TASKBAR
- res = SetWindowLongA(hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) & ~WS_EX_APPWINDOW)
- if needs_show:
- if not needs_focus:
-
- try:
- return f.Show(True, False)
- except Exception:
- pass
- except:
- None<EXCEPTION MATCH>Exception
-
-
- None<EXCEPTION MATCH>Exception
- f.Show(True)
- finally:
- pass
-
-
-
- def GetOnTaskbar(f):
- return not (FRAME_NO_TASKBAR & f.WindowStyle)
-
- wx.TopLevelWindow.OnTaskbar = property(GetOnTaskbar, SetOnTaskbar)
- import cgui
- wx.TopLevelWindow.Visible = property(cgui.WindowVisible)
-
- def FullscreenApp():
-
- try:
- winfullscreen = winfullscreen
- import gui.native.win
- except ImportError:
- traceback.print_exc_once()
-
- if winfullscreen.enabled:
-
- try:
- return not winfullscreen.get_accepts_notifications()
- except Exception:
- traceback.print_exc()
- winfullscreen.enabled = False
- except:
- None<EXCEPTION MATCH>Exception
-
-
- None<EXCEPTION MATCH>Exception
- hwnd = GetForegroundWindow()
- desktopHwnd = GetDesktopWindow()
- shellHwnd = GetShellWindow()
- winRECT = RECT()
- RECT2wx = wxRectFromRECT
- import gui.native.win.winextensions
- Monitor = Monitor
- import gui.toolbox
- if hwnd and hwnd not in (desktopHwnd, shellHwnd):
- GetWindowRect(hwnd, byref(winRECT))
- winrect = RECT2wx(winRECT)
- mrect = Monitor.GetFromHandle(hwnd).Geometry
- if winrect.Size == mrect.Size:
- return True
-
-
- return False
-
-
- def createEmail(mailto):
- return os.startfile(mailto)
-
-
- def GetProcessDefaultLayout():
- windll = windll
- byref = byref
- import ctypes
- DWORD = DWORD
- import ctypes.wintypes
- layout = DWORD()
- windll.user32.GetProcessDefaultLayout(byref(layout))
- return layout.value
-
- WS_EX_LAYOUTRTL = 4194304
-
- def mirror(win):
- hwnd = win.Handle
- new_style = GetWindowLong(hwnd, GWL_EXSTYLE) ^ WS_EX_LAYOUTRTL
- return SetWindowLong(hwnd, GWL_EXSTYLE, new_style)
-
-