home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / gui / native / win / winutil.pyo (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  4.5 KB  |  123 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.     
  83.     def _get_glass_color(active = False):
  84.         DwmGetColorizationParameters(ctypes.byref(p))
  85.         extra_alpha_percent = None if active else 0
  86.         return alpha_blend_on_white(p.ColorizationColor, extra_alpha_percent)
  87.  
  88.     get_glass_color = _get_glass_color
  89.     
  90.     def alpha_blend_on_white(c, extra_alpha_percent = 0):
  91.         r = c >> 16 & 255
  92.         g = c >> 8 & 255
  93.         b = c & 255
  94.         a = (c >> 24 & 255) / 255 + extra_alpha_percent
  95.         white = (1 - a) * 255
  96.         return wx.Color(white + a * r, white + a * g, white + a * b)
  97.  
  98.  
  99.  
  100. try:
  101.     IsThemeActive = ctypes.windll.uxtheme.IsThemeActive
  102. except Exception:
  103.     
  104.     IsThemeActive = lambda : False
  105.  
  106.  
  107. def rgbdword_to_color(c):
  108.     return wx.Color(c & 255, (c & 65280) >> 8, (c & 16711680) >> 16)
  109.  
  110.  
  111. def _get_active_caption_color(active):
  112.     COLOR_ACTIVECAPTION = 2
  113.     return rgbdword_to_color(ctypes.windll.user32.GetSysColor(COLOR_ACTIVECAPTION))
  114.  
  115.  
  116. def get_frame_color(active):
  117.     if IsThemeActive() and get_glass_color is not None:
  118.         return get_glass_color(active)
  119.     if IsThemeActive():
  120.         return _get_active_caption_color(active)
  121.     return wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)
  122.  
  123.