Changeset 501

Show
Ignore:
Timestamp:
04/06/03 13:25:01 (6 years ago)
Author:
sholloway
Message:

Removed dependencies on calldll/npstruct/dynwin in favor of the more generally and better architected ctypes module

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBSkinning/RBSkinning/wxPythonSkin/dockcontainer.py

    r479 r501  
    5454        # Create the layout sizer 
    5555        self.object = wxDockContainerSizerAdaptor() 
     56        for name, value in self.settings.iteritems(): 
     57            if isinstance(name, str) and name not in ['ctxvar','ctxnode']: 
     58                setattr(self.object, name, value) 
    5659        self.wxInitialStandardOptions() 
    57  
    5860        self.PushContext() 
    5961 
  • trunk/RBSkinning/RBSkinning/wxPythonSkin/wxSkinObject.py

    r499 r501  
    6868 
    6969        ## Standard wx Options 
    70         'enable':       '1', 
    71         'tooltip':      '', 
    72         'fgcolor':      None, 
    73         'bgcolor':      None, 
    74         'sizehints':    '-1,-1,-1,-1,-1,-1', 
     70        #'enable':       '1', 
     71        #'tooltip':      '', 
     72        #'fgcolor':      None, 
     73        #'bgcolor':      None, 
     74        #'sizehints':    '-1,-1,-1,-1,-1,-1', 
    7575 
    7676        }) 
     
    150150 
    151151    def wxEvalCond(self, Setting, Default=None): 
    152         try: Setting = self.settings[Setting] 
    153         except KeyError: return Default 
    154         else: return self.EvalLocalEx(Setting, self.ctxVars) 
     152        try:  
     153            Setting = self.settings[Setting] 
     154        except KeyError:  
     155            return Default 
     156        else:  
     157            return self.EvalLocalEx(Setting, self.ctxVars) 
    155158 
    156159    def wxEval(self, Setting): 
     
    159162    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    160163 
    161     def wxSettingDict(self, Eval=[], NonEval=[], kwStart=None, *args, **kw): 
     164    def wxSettingDict(self, Eval=[], NonEval=[], kwStart=None): 
    162165        result = kwStart or {} 
    163         for each in Eval: result[each] = self.wxEval(each, *args, **kw) 
    164         for each in NonEval: result[each] = self.settings[each] 
     166        for each in Eval:  
     167            result[each] = self.wxEvalCond(each) 
     168        for each in NonEval:  
     169            result[each] = self.settings[each] 
    165170        if 'wxid' in result: 
    166171            result['id'] = result['wxid'] 
  • trunk/RBSkinning/RBSkinning/wxTools/AlphaBlend.py

    r253 r501  
    2424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2525 
     26import ctypes 
     27 
    2628#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2729#~ Definitions  
    2830#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     31 
     32""" 
     33hWndNext = self.user32.WindowFromPoint(*pos) 
     34while hWndNext: 
     35    hWnd = hWndNext 
     36    hWndNext = self.user32.GetParent(hWnd) 
     37style = self.user32.GetWindowLongA(hWnd,GWL_EXSTYLE) 
     38self.user32.SetWindowLongA(hWnd, GWL_EXSTYLE, style^WS_EX_LAYERED) 
     39if 0.0 < alpha < 1.0: 
     40    alpha = int(alpha*255.0) 
     41else: alpha = int(alpha) 
     42LastSettings = (hWnd, colorkey, alpha, LWA_ALPHA) 
     43self.user32.SetLayeredWindowAttributes(*LastSettings) 
     44return LastSettings 
     45""" 
    2946 
    3047class winAlphaBlend(object): 
     
    3653    alpha = 1.0 
    3754    colorkey = None 
     55    user32 = ctypes.WinDLL('user32.dll') 
    3856 
    3957    def __init__(self, hWnd): 
    4058        self.hWnd = hWnd 
    41  
    42         import win32api 
    43         win32api.SetWindowLong(hWnd, self.GWL_EXSTYLE, win32api.GetWindowLong(hWnd, self.GWL_EXSTYLE) ^ self.WS_EX_LAYERED); 
    44  
    45         import calldll 
    46         self.__calldll = calldll 
    47         self.__User32Library = self.__calldll.load_library ('user32.dll') 
    48         self.__addrSetLayeredWindowAttributes = self.__calldll.get_proc_address(self.__User32Library, 'SetLayeredWindowAttributes') 
    49         assert self.__addrSetLayeredWindowAttributes  
    50  
    51     def __del__(self): 
    52         if self.__User32Library:  
    53             self.__calldll.free_library(self.__User32Library) 
    54  
    55         try: del self.__calldll 
    56         except AttributeError: pass 
    57  
    58     def __SetLayeredWindowAttributes(self, alpha, colorkey, flag): 
    59         if flag: 
    60             self.__calldll.call_foreign_function(self.__addrSetLayeredWindowAttributes, 'LLBL', '', (self.hWnd, colorkey, alpha, flag)) 
     59        style = self.user32.GetWindowLongA(self.hWnd, self.GWL_EXSTYLE) 
     60        self.user32.SetWindowLongA(self.hWnd, self.GWL_EXSTYLE, style|self.WS_EX_LAYERED) 
    6161 
    6262    def Blend(self, alpha=None, colorkey=None, usedefaults=1): 
     
    8686            self.colorkey = None 
    8787 
    88         self.__SetLayeredWindowAttributes(alpha, colorkey, flag) 
     88        self.user32.SetLayeredWindowAttributes(self.hWnd, colorkey, alpha, flag) 
    8989 
    9090#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBSkinning/RBSkinning/wxTools/winUtils.py

    r319 r501  
    2020##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2121 
     22"""Microsoft Windows specific calls. 
     23 
     24Highly dependent upon ctypes and struct modules. 
     25 
     26Note: Hack warning!  Only bit twiddlers will like this stuff.  ;) 
     27""" 
     28 
    2229#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2330#~ Imports  
    2431#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2532 
    26 import calldll 
     33import ctypes 
    2734import struct 
    2835 
     
    3340def ChangeDisplaySettings(xres=None, yres=None, BitsPerPixel=None): 
    3441    """Changes the display resolution and bit depth on Windows. 
    35  
    36     Note: Hack warning!  Only bit twiddlers will like this stuff.  ;) 
    3742    """ 
    3843 
    39     u32 = calldll.load_library('user32.dll') 
    40     try: 
    41         DM_BITSPERPEL = 0x00040000 
    42         DM_PELSWIDTH = 0x00080000 
    43         DM_PELSHEIGHT = 0x00100000 
    44         CDS_FULLSCREEN = 0x00000004 
    45         SIZEOF_DEVMODE = 148 
     44    DM_BITSPERPEL = 0x00040000 
     45    DM_PELSWIDTH = 0x00080000 
     46    DM_PELSHEIGHT = 0x00100000 
     47    CDS_FULLSCREEN = 0x00000004 
     48    SIZEOF_DEVMODE = 148 
    4649 
    47         addr = calldll.get_proc_address(u32, 'ChangeDisplaySettingsA') 
     50    user32 = ctypes.WinDLL('user32.dll') 
     51    DevModeData = struct.calcsize("32BHH") * '\x00' 
     52    DevModeData += struct.pack("H", SIZEOF_DEVMODE) 
     53    DevModeData += struct.calcsize("H") * '\x00' 
     54    dwFields = (xres and DM_PELSWIDTH or 0) | (yres and DM_PELSHEIGHT or 0) | (BitsPerPixel and DM_BITSPERPEL or 0) 
     55    DevModeData += struct.pack("L", dwFields) 
     56    DevModeData += struct.calcsize("l9h32BHL") * '\x00' 
     57    DevModeData += struct.pack("LLL", BitsPerPixel or 0, xres or 0, yres or 0) 
     58    DevModeData += struct.calcsize("8L") * '\x00' 
     59    result = user32.ChangeDisplaySettingsA(DevModeData, CDS_FULLSCREEN) 
     60    return result == 0 
    4861 
    49         DevModeData = struct.calcsize("32BHH") * '\x00' 
    50         DevModeData += struct.pack("H", SIZEOF_DEVMODE) 
    51         DevModeData += struct.calcsize("H") * '\x00' 
    52         dwFields = (xres and DM_PELSWIDTH or 0) | (yres and DM_PELSHEIGHT or 0) | (BitsPerPixel and DM_BITSPERPEL or 0) 
    53         DevModeData += struct.pack("L", dwFields) 
    54         DevModeData += struct.calcsize("l9h32BHL") * '\x00' 
    55         DevModeData += struct.pack("LLL", BitsPerPixel or 0, xres or 0, yres or 0) 
    56         DevModeData += struct.calcsize("8L") * '\x00' 
    57         DevMode = calldll.membuf(SIZEOF_DEVMODE) 
    58         DevMode.write(DevModeData ) 
    59         result = calldll.call_foreign_function(addr, 'll', '', (DevMode.address(), CDS_FULLSCREEN)) 
    60     finally: 
    61         calldll.free_library(u32) 
    62     return result == 0 
    6362SetResolution = ChangeDisplaySettings 
     63 
     64#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     65 
     66def GlobalMemoryStatus(): 
     67    buf = '\x00' * 32 
     68    kernel32 = ctypes.WinDLL('kernel32') 
     69    kernel32.GlobalMemoryStatus(buf) 
     70    rtuple = struct.unpack('8L', buf) 
     71    result   = {} 
     72    result['MemoryLoad'] = rtuple[1]   # [0] is len 
     73    result['TotalPhysical'] = rtuple[2] 
     74    result['AvailablePhysical'] = rtuple[3] 
     75    result['TotalPageFile'] = rtuple[4] 
     76    result['AvailablePageFile'] = rtuple[5] 
     77    result['TotalVirtual'] = rtuple[6] 
     78    result['AvailableVirtual'] = rtuple[7] 
     79 
  • trunk/RBSkinning/RBSkinning/wxTools/wxDockingTools.py

    r499 r501  
    267267            page.DockItem(dockitem, *args, **kw) 
    268268 
    269             try:  
    270                 text = dockitem.GetLabel() 
    271             except AttributeError:  
    272                 text = None 
    273             text = text or dockitem.__class__.__name__ 
     269            text = None 
     270            if text is None: 
     271                try: text = container.pagename 
     272                except AttributeError: pass 
     273            if text is None: 
     274                try: text = dockitem.GetLabel() 
     275                except AttributeError: pass 
     276            if text is None: 
     277                text = text or dockitem.__class__.__name__ 
    274278 
    275279            if self.prepend: 
  • trunk/RBSkinning/demo/wxPythonSkin/grafting/graft_layout.py

    r500 r501  
    11#!/usr/bin/env python 
     2##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     3##~ License  
     4##~  
     5##- The RuneBlade Foundation library is intended to ease some  
     6##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.)  
     7##- applications, while providing the flexibility to modularly change the  
     8##- architecture. Enjoy. 
     9##~  
     10##~ Copyright (C) 2002  TechGame Networks, LLC. 
     11##~  
     12##~ This library is free software; you can redistribute it and/or 
     13##~ modify it under the terms of the BSD style License as found in the  
     14##~ LICENSE file included with this distribution. 
     15##~  
     16##~ TechGame Networks, LLC can be reached at: 
     17##~ 3578 E. Hartsel Drive #211 
     18##~ Colorado Springs, Colorado, USA, 80920 
     19##~ 
     20##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    221 
    322#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~