home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from gui.textutil import default_font
- from gui.toolbox import TransparentBitmap
- import ctypes
- import wx
- from util import do
- dwm = ctypes.windll.dwmapi
- ux = ctypes.windll.uxtheme
- from ctypes.wintypes import RECT, DWORD, BOOL, HRGN, COLORREF, POINT, LPARAM
- from ctypes import byref, c_int32, c_void_p, Structure
- adjusted_controls = [
- wx.StaticText,
- wx.CheckBox,
- wx.TextCtrl,
- wx.Button,
- wx.HyperlinkCtrl,
- wx.StaticBox,
- wx.RadioBox,
- wx.RadioButton,
- wx.Choice,
- wx.ComboBox,
- wx.FilePickerCtrl,
- wx.DirPickerCtrl]
- from wx.py.editwindow import FACES
- FACES['mono'] = 'Consolas'
-
- def _change_font(ctrl):
- oldinit = ctrl.__init__
-
- def newinit(self, *a, **k):
-
- try:
- oldinit(self, *a, **k)
- except:
- funcinfo = funcinfo
- import util
- import sys
- print >>sys.stderr, '_change_font failed at %s' % funcinfo(oldinit)
- raise
-
- self.SetFont(default_font())
-
- ctrl.__init__ = newinit
-
- for ctrl in adjusted_controls:
- _change_font(ctrl)
-
-
- class DWM_BLURBEHIND(Structure):
- _fields_ = [
- ('dwFlags', DWORD),
- ('fEnable', BOOL),
- ('hRgnBlur', HRGN),
- ('fTransitionOnMaximized', BOOL)]
-
-
- class DTTOPTS(Structure):
- _fields_ = [
- ('dwSize', DWORD),
- ('dwFlags', DWORD),
- ('crText', COLORREF),
- ('crBorder', COLORREF),
- ('crShadow', COLORREF),
- ('iTextShadowType', c_int32),
- ('ptShadowOffset', POINT),
- ('iBorderSize', c_int32),
- ('iFontPropId', c_int32),
- ('iColorPropId', c_int32),
- ('iStateId', c_int32),
- ('fApplyOverlay', BOOL),
- ('iGlowSize', c_int32),
- ('pfnDrawTextCallback', c_void_p),
- ('lParam', LPARAM)]
-
- DWM_BB_ENABLE = 1
- DWM_BB_BLURREGION = 2
- DWM_BB_TRANSITIONONMAXIMIZED = 4
-
- def glassExtendInto(win, left = -1, right = -1, top = -1, bottom = -1):
- rect = RECT(left, right, top, bottom)
- if IsCompositionEnabled():
- dwm.DwmExtendFrameIntoClientArea(win.Handle, byref(rect))
- return True
- else:
- return False
-
-
- def glassBlurRegion(win, region = 0):
- bb = DWM_BLURBEHIND()
- bb.dwFlags = DWM_BB_ENABLE
- bb.fEnable = 1
- bb.hRgnBlur = region
- return dwm.DwmEnableBlurBehindWindow(win.Handle, byref(bb))
-
-
- def IsCompositionEnabled():
- enabled = c_int32(0)
- dwm.DwmIsCompositionEnabled(byref(enabled))
- return bool(enabled)
-
-
- class ThemeMixin(object):
-
- def __init__(self, window):
- self._hTheme = ux.OpenThemeData(window.Handle, u'globals')
- print 'hTheme', self._hTheme
-
-
- def __del__(self):
- ux.CloseThemeData(self._hTheme)
-
-
- DTT_COMPOSITED = 8192
- DTT_GLOWSIZE = 2048
- DTT_TEXTCOLOR = 1
- DT_TOP = 0
- DT_LEFT = 0
- DT_CENTER = 1
- DT_RIGHT = 2
- DT_VCENTER = 4
- DT_WORDBREAK = 16
- DT_SINGLELINE = 32
- DT_NOPREFIX = 2048
-
- def DrawThemeTextEx(win, handle, text):
- dto = DTTOPTS()
- uFormat = DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX
- dto.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE
- dto.iGlowSize = 10
- rcText2 = RECT(0, 0, 150, 30)
- ux.DrawThemeTextEx(win._hTheme, handle, 0, 0, unicode(text), -1, uFormat, byref(rcText2), byref(dto))
-
-
- class ThemedFrame(wx.Frame, ThemeMixin):
-
- def __init__(self, *a, **k):
- wx.Frame.__init__(self, *a, **k)
- ThemeMixin.__init__(self, self)
-
-
- if __name__ == '__main__':
- app = wx.PySimpleApp()
- f = ThemedFrame(None)
- f.Sizer = sz = wx.BoxSizer(wx.VERTICAL)
-
- def paint(e):
- dc = wx.PaintDC(f)
- dc.Brush = wx.BLACK_BRUSH
- dc.Pen = wx.TRANSPARENT_PEN
- bmap = TransparentBitmap(f.Size)
- dc2 = wx.MemoryDC()
- dc2.SelectObject(bmap)
- dc2.Font = default_font()
- dc2.TextForeground = wx.RED
- dc2.DrawText('hello', 0, 0)
- dc.DrawBitmap(bmap, 0, 0)
- e.Skip(True)
-
- f.Bind(wx.EVT_PAINT, paint)
- f.Show(True)
- app.MainLoop()
-
-