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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import wx
  5. import ctypes.wintypes as ctypes
  6. from gui.native.win.winconstants import WM_USER
  7. from ctypes.wintypes import UINT, HWND, DWORD
  8. from util.ffi import Struct
  9. from util import memoize
  10.  
  11. def _win_id_gen():
  12.     i = 100
  13.     while True:
  14.         i += 1
  15.         yield WM_USER + i
  16.  
  17. _win_id_gen = _win_id_gen()
  18.  
  19. def win_id():
  20.     return _win_id_gen.next()
  21.  
  22.  
  23. class WinStruct(Struct):
  24.     cbSize = property((lambda self: len(self)), (lambda self, val: pass))
  25.  
  26.  
  27. class FLASHWINFO(WinStruct):
  28.     _fields_ = [
  29.         ('cbSize', UINT),
  30.         ('hwnd', HWND),
  31.         ('dwFlags', DWORD),
  32.         ('uCount', UINT),
  33.         ('dwTimeout', DWORD)]
  34.  
  35.  
  36. def is_vista():
  37.     import wx
  38.     if 'wxMSW' in wx.PlatformInfo:
  39.         pass
  40.     return hasattr(ctypes.windll, 'dwmapi')
  41.  
  42. is_vista = memoize(is_vista)
  43.  
  44. def disable_callback_filter():
  45.     byref = byref
  46.     import ctypes
  47.     k = ctypes.windll.kernel32
  48.     PROCESS_CALLBACK_FILTER_ENABLED = 1
  49.     dwflags = DWORD()
  50.     
  51.     try:
  52.         GetProcessUserModeExceptionPolicy = k.GetProcessUserModeExceptionPolicy
  53.         SetProcessUserModeExceptionPolicy = k.SetProcessUserModeExceptionPolicy
  54.     except AttributeError:
  55.         pass
  56.  
  57.     if GetProcessUserModeExceptionPolicy(byref(dwflags)):
  58.         return SetProcessUserModeExceptionPolicy(dwflags.value & ~PROCESS_CALLBACK_FILTER_ENABLED)
  59.     return False
  60.  
  61. get_glass_color = None
  62. if 'wxMSW' in wx.PlatformInfo:
  63.     from ctypes import c_uint32
  64.     
  65.     class DWMCOLORIZATIONPARAMS(ctypes.Structure):
  66.         _fields_ = [
  67.             ('ColorizationColor', c_uint32),
  68.             ('ColorizationAfterglow', c_uint32),
  69.             ('ColorizationColorBalance', c_uint32),
  70.             ('ColorizationAfterglowBalance', c_uint32),
  71.             ('ColorizationBlurBalance', c_uint32),
  72.             ('ColorizationGlassReflectionIntensity', c_uint32),
  73.             ('ColorizationOpaqueBlend', c_uint32)]
  74.  
  75.     p = DWMCOLORIZATIONPARAMS()
  76.     
  77.     try:
  78.         DwmGetColorizationParameters = ctypes.windll.dwmapi[127]
  79.     except Exception:
  80.         pass
  81.  
  82.     disable_gcp = False
  83.     
  84.     def _get_glass_color(active = False):
  85.         global disable_gcp
  86.         VISTA_GLASS_COLOR = wx.Color(189, 211, 239)
  87.         if disable_gcp:
  88.             return VISTA_GLASS_COLOR
  89.         
  90.         try:
  91.             DwmGetColorizationParameters(ctypes.byref(p))
  92.         except ValueError:
  93.             disable_gcp
  94.             disable_gcp
  95.             disable_gcp = True
  96.             return VISTA_GLASS_COLOR
  97.  
  98.         extra_alpha_percent = disable_gcp if active else 0
  99.         return alpha_blend_on_white(p.ColorizationColor, extra_alpha_percent)
  100.  
  101.     get_glass_color = _get_glass_color
  102.     
  103.     def alpha_blend_on_white(c, extra_alpha_percent = 0):
  104.         r = c >> 16 & 255
  105.         g = c >> 8 & 255
  106.         b = c & 255
  107.         a = (c >> 24 & 255) / 255 + extra_alpha_percent
  108.         white = (1 - a) * 255
  109.         return wx.Color(white + a * r, white + a * g, white + a * b)
  110.  
  111.  
  112.  
  113. try:
  114.     IsThemeActive = ctypes.windll.uxtheme.IsThemeActive
  115. except Exception:
  116.     
  117.     IsThemeActive = lambda : False
  118.  
  119.  
  120. def rgbdword_to_color(c):
  121.     return wx.Color(c & 255, (c & 65280) >> 8, (c & 16711680) >> 16)
  122.  
  123.  
  124. def _get_active_caption_color(active):
  125.     COLOR_ACTIVECAPTION = 2
  126.     return rgbdword_to_color(ctypes.windll.user32.GetSysColor(COLOR_ACTIVECAPTION))
  127.  
  128.  
  129. def get_frame_color(active):
  130.     if IsThemeActive() and get_glass_color is not None:
  131.         return get_glass_color(active)
  132.     if IsThemeActive():
  133.         return _get_active_caption_color(active)
  134.     return wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)
  135.  
  136.