home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / gui / vista.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  5.7 KB  |  163 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from gui.textutil import default_font
  5. from gui.toolbox import TransparentBitmap
  6. import ctypes
  7. import wx
  8. dwm = ctypes.windll.dwmapi
  9. ux = ctypes.windll.uxtheme
  10. from ctypes.wintypes import RECT, DWORD, BOOL, HRGN, COLORREF, POINT, LPARAM
  11. from ctypes import byref, c_int32, c_void_p, Structure
  12. adjusted_controls = [
  13.     wx.StaticText,
  14.     wx.CheckBox,
  15.     wx.TextCtrl,
  16.     wx.Button,
  17.     wx.HyperlinkCtrl,
  18.     wx.StaticBox,
  19.     wx.RadioBox,
  20.     wx.RadioButton,
  21.     wx.Choice,
  22.     wx.ComboBox,
  23.     wx.FilePickerCtrl,
  24.     wx.DirPickerCtrl]
  25. from wx.py.editwindow import FACES
  26. FACES['mono'] = 'Consolas'
  27.  
  28. def _change_font(ctrl):
  29.     oldinit = ctrl.__init__
  30.     
  31.     def newinit(self, *a, **k):
  32.         
  33.         try:
  34.             oldinit(self, *a, **k)
  35.         except:
  36.             funcinfo = funcinfo
  37.             import util
  38.             import sys
  39.             print >>sys.stderr, '_change_font failed at %s' % funcinfo(oldinit)
  40.             raise 
  41.  
  42.         self.SetFont(default_font())
  43.  
  44.     ctrl.__init__ = newinit
  45.  
  46. for ctrl in adjusted_controls:
  47.     _change_font(ctrl)
  48.  
  49.  
  50. class DWM_BLURBEHIND(Structure):
  51.     _fields_ = [
  52.         ('dwFlags', DWORD),
  53.         ('fEnable', BOOL),
  54.         ('hRgnBlur', HRGN),
  55.         ('fTransitionOnMaximized', BOOL)]
  56.  
  57.  
  58. class DTTOPTS(Structure):
  59.     _fields_ = [
  60.         ('dwSize', DWORD),
  61.         ('dwFlags', DWORD),
  62.         ('crText', COLORREF),
  63.         ('crBorder', COLORREF),
  64.         ('crShadow', COLORREF),
  65.         ('iTextShadowType', c_int32),
  66.         ('ptShadowOffset', POINT),
  67.         ('iBorderSize', c_int32),
  68.         ('iFontPropId', c_int32),
  69.         ('iColorPropId', c_int32),
  70.         ('iStateId', c_int32),
  71.         ('fApplyOverlay', BOOL),
  72.         ('iGlowSize', c_int32),
  73.         ('pfnDrawTextCallback', c_void_p),
  74.         ('lParam', LPARAM)]
  75.  
  76. DWM_BB_ENABLE = 1
  77. DWM_BB_BLURREGION = 2
  78. DWM_BB_TRANSITIONONMAXIMIZED = 4
  79.  
  80. def glassExtendInto(win, left = -1, right = -1, top = -1, bottom = -1):
  81.     rect = RECT(left, right, top, bottom)
  82.     if IsCompositionEnabled():
  83.         dwm.DwmExtendFrameIntoClientArea(win.Handle, byref(rect))
  84.         return True
  85.     return False
  86.  
  87.  
  88. def glassBlurRegion(win, region = 0):
  89.     bb = DWM_BLURBEHIND()
  90.     bb.dwFlags = DWM_BB_ENABLE
  91.     bb.fEnable = 1
  92.     bb.hRgnBlur = region
  93.     return dwm.DwmEnableBlurBehindWindow(win.Handle, byref(bb))
  94.  
  95.  
  96. def IsCompositionEnabled():
  97.     enabled = c_int32(0)
  98.     dwm.DwmIsCompositionEnabled(byref(enabled))
  99.     return bool(enabled)
  100.  
  101.  
  102. class ThemeMixin(object):
  103.     
  104.     def __init__(self, window):
  105.         self._hTheme = ux.OpenThemeData(window.Handle, u'globals')
  106.         print 'hTheme', self._hTheme
  107.  
  108.     
  109.     def __del__(self):
  110.         ux.CloseThemeData(self._hTheme)
  111.  
  112.  
  113. DTT_COMPOSITED = 8192
  114. DTT_GLOWSIZE = 2048
  115. DTT_TEXTCOLOR = 1
  116. DT_TOP = 0
  117. DT_LEFT = 0
  118. DT_CENTER = 1
  119. DT_RIGHT = 2
  120. DT_VCENTER = 4
  121. DT_WORDBREAK = 16
  122. DT_SINGLELINE = 32
  123. DT_NOPREFIX = 2048
  124.  
  125. def DrawThemeTextEx(win, handle, text):
  126.     dto = DTTOPTS()
  127.     uFormat = DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX
  128.     dto.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE
  129.     dto.iGlowSize = 10
  130.     rcText2 = RECT(0, 0, 150, 30)
  131.     ux.DrawThemeTextEx(win._hTheme, handle, 0, 0, unicode(text), -1, uFormat, byref(rcText2), byref(dto))
  132.  
  133.  
  134. class ThemedFrame(wx.Frame, ThemeMixin):
  135.     
  136.     def __init__(self, *a, **k):
  137.         wx.Frame.__init__(self, *a, **k)
  138.         ThemeMixin.__init__(self, self)
  139.  
  140.  
  141. if __name__ == '__main__':
  142.     app = wx.PySimpleApp()
  143.     f = ThemedFrame(None)
  144.     f.Sizer = sz = wx.BoxSizer(wx.VERTICAL)
  145.     
  146.     def paint(e):
  147.         dc = wx.PaintDC(f)
  148.         dc.Brush = wx.BLACK_BRUSH
  149.         dc.Pen = wx.TRANSPARENT_PEN
  150.         bmap = TransparentBitmap(f.Size)
  151.         dc2 = wx.MemoryDC()
  152.         dc2.SelectObject(bmap)
  153.         dc2.Font = default_font()
  154.         dc2.TextForeground = wx.RED
  155.         dc2.DrawText('hello', 0, 0)
  156.         dc.DrawBitmap(bmap, 0, 0)
  157.         e.Skip(True)
  158.  
  159.     f.Bind(wx.EVT_PAINT, paint)
  160.     f.Show(True)
  161.     app.MainLoop()
  162.  
  163.