home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- import wx
- import ctypes.wintypes as ctypes
- from gui.native.win.winconstants import WM_USER
- from ctypes.wintypes import UINT, HWND, DWORD
- from util.ffi import Struct
- from util import memoize
-
- def _win_id_gen():
- i = 100
- while True:
- i += 1
- yield WM_USER + i
-
- _win_id_gen = _win_id_gen()
-
- def win_id():
- return _win_id_gen.next()
-
-
- class WinStruct(Struct):
- cbSize = property((lambda self: len(self)), (lambda self, val: pass))
-
-
- class FLASHWINFO(WinStruct):
- _fields_ = [
- ('cbSize', UINT),
- ('hwnd', HWND),
- ('dwFlags', DWORD),
- ('uCount', UINT),
- ('dwTimeout', DWORD)]
-
-
- def is_vista():
- import wx
- if 'wxMSW' in wx.PlatformInfo:
- pass
- return hasattr(ctypes.windll, 'dwmapi')
-
- is_vista = memoize(is_vista)
-
- def disable_callback_filter():
- byref = byref
- import ctypes
- k = ctypes.windll.kernel32
- PROCESS_CALLBACK_FILTER_ENABLED = 1
- dwflags = DWORD()
-
- try:
- GetProcessUserModeExceptionPolicy = k.GetProcessUserModeExceptionPolicy
- SetProcessUserModeExceptionPolicy = k.SetProcessUserModeExceptionPolicy
- except AttributeError:
- pass
-
- if GetProcessUserModeExceptionPolicy(byref(dwflags)):
- return SetProcessUserModeExceptionPolicy(dwflags.value & ~PROCESS_CALLBACK_FILTER_ENABLED)
- return False
-
- get_glass_color = None
- if 'wxMSW' in wx.PlatformInfo:
- from ctypes import c_uint32
-
- class DWMCOLORIZATIONPARAMS(ctypes.Structure):
- _fields_ = [
- ('ColorizationColor', c_uint32),
- ('ColorizationAfterglow', c_uint32),
- ('ColorizationColorBalance', c_uint32),
- ('ColorizationAfterglowBalance', c_uint32),
- ('ColorizationBlurBalance', c_uint32),
- ('ColorizationGlassReflectionIntensity', c_uint32),
- ('ColorizationOpaqueBlend', c_uint32)]
-
- p = DWMCOLORIZATIONPARAMS()
-
- try:
- DwmGetColorizationParameters = ctypes.windll.dwmapi[127]
- except Exception:
- pass
-
- disable_gcp = False
-
- def _get_glass_color(active = False):
- global disable_gcp
- VISTA_GLASS_COLOR = wx.Color(189, 211, 239)
- if disable_gcp:
- return VISTA_GLASS_COLOR
-
- try:
- DwmGetColorizationParameters(ctypes.byref(p))
- except ValueError:
- disable_gcp
- disable_gcp
- disable_gcp = True
- return VISTA_GLASS_COLOR
-
- extra_alpha_percent = disable_gcp if active else 0
- return alpha_blend_on_white(p.ColorizationColor, extra_alpha_percent)
-
- get_glass_color = _get_glass_color
-
- def alpha_blend_on_white(c, extra_alpha_percent = 0):
- r = c >> 16 & 255
- g = c >> 8 & 255
- b = c & 255
- a = (c >> 24 & 255) / 255 + extra_alpha_percent
- white = (1 - a) * 255
- return wx.Color(white + a * r, white + a * g, white + a * b)
-
-
-
- try:
- IsThemeActive = ctypes.windll.uxtheme.IsThemeActive
- except Exception:
-
- IsThemeActive = lambda : False
-
-
- def rgbdword_to_color(c):
- return wx.Color(c & 255, (c & 65280) >> 8, (c & 16711680) >> 16)
-
-
- def _get_active_caption_color(active):
- COLOR_ACTIVECAPTION = 2
- return rgbdword_to_color(ctypes.windll.user32.GetSysColor(COLOR_ACTIVECAPTION))
-
-
- def get_frame_color(active):
- if IsThemeActive() and get_glass_color is not None:
- return get_glass_color(active)
- if IsThemeActive():
- return _get_active_caption_color(active)
- return wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)
-
-