Thread: [Anygui-checkins] CVS: anygui/lib/anygui/backends ctmswgui.py,1.7,1.8
Brought to you by:
mlh
From: Robin B. <rgb...@us...> - 2003-05-18 10:16:43
|
Update of /cvsroot/anygui/anygui/lib/anygui/backends In directory sc8-pr-cvs1:/tmp/cvs-serv2482 Modified Files: ctmswgui.py Log Message: Fix up to use ctype-0.6.0 Index: ctmswgui.py =================================================================== RCS file: /cvsroot/anygui/anygui/lib/anygui/backends/ctmswgui.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** ctmswgui.py 29 Nov 2002 09:15:24 -0000 1.7 --- ctmswgui.py 18 May 2003 10:16:26 -0000 1.8 *************** *** 26,30 **** ################################################################ ! from ctypes import CDLL, _DLLS, _DynFunction, CFunction, c_string, Structure, WinError, byref, GetLastError _apiMode = 'A' --- 26,30 ---- ################################################################ ! from ctypes import CDLL, _DLLS, WinDLL, WINFUNCTYPE, c_buffer, c_int, c_char_p, Structure, WinError, byref, GetLastError _apiMode = 'A' *************** *** 35,48 **** return text.replace('\r\n', '\n') ! class WinDLL(CDLL): ! def __getattr__(self, name): try: ! func = _DynFunction(name, self) except: ! func = _DynFunction(name+_apiMode, self) setattr(self, name, func) return func ! windll = _DLLS(WinDLL) user32 = windll.user32 --- 35,50 ---- return text.replace('\r\n', '\n') ! class LocalWinDLL(WinDLL): def __getattr__(self, name): + if name[:2] == '__' and name[-2:] == '__': + raise AttributeError, name try: ! func = self._StdcallFuncPtr(name, self) except: ! func = self._StdcallFuncPtr(name+_apiMode, self) setattr(self, name, func) return func ! ! windll = _DLLS(LocalWinDLL) user32 = windll.user32 *************** *** 213,220 **** class t_rect(Structure): ! _fields_=(('left','i'),('top','i'),('right','i'),('bottom','i')) class t_point(Structure): ! _fields_=(('x','i'),('y','i')) # BUGS: --- 215,222 ---- class t_rect(Structure): ! _fields_=(('left',c_int),('top',c_int),('right',c_int),('bottom',c_int)) class t_point(Structure): ! _fields_=(('x',c_int),('y',c_int)) # BUGS: *************** *** 356,365 **** if not self.widget: return #if _verbose: log("%s.SetWindowText('%s'(%s)) hwnd=%s(%s) self=%s" % (self.__class__.__name__,text,type(text),self.widget,type(self.widget),str(self))) ! SetWindowText(self.widget,c_string(_to_native(text))) def _getText(self): 'return native text' n = GetWindowTextLength(self.widget) ! t = c_string('\000'*(n+1)) GetWindowText(self.widget,t,n+1) return t.value --- 358,367 ---- if not self.widget: return #if _verbose: log("%s.SetWindowText('%s'(%s)) hwnd=%s(%s) self=%s" % (self.__class__.__name__,text,type(text),self.widget,type(self.widget),str(self))) ! SetWindowText(self.widget,c_buffer(_to_native(text))) def _getText(self): 'return native text' n = GetWindowTextLength(self.widget) ! t = c_buffer('\000'*(n+1)) GetWindowText(self.widget,t,n+1) return t.value *************** *** 428,432 **** for item in map(str, list(items)): # FIXME: This doesn't work! Items get jumbled... ! SendMessage(self.widget, LB_ADDSTRING, 0, c_string(item)) --- 430,434 ---- for item in map(str, list(items)): # FIXME: This doesn't work! Items get jumbled... ! SendMessage(self.widget, LB_ADDSTRING, 0, c_buffer(item)) *************** *** 605,609 **** if self.kind=='bitmap': try: ! self._handle = LoadImage(0,c_string(fn), IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE) except: --- 607,611 ---- if self.kind=='bitmap': try: ! self._handle = LoadImage(0,c_buffer(fn), IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE) except: *************** *** 713,717 **** def setTitle(self,title): if self.widget and title: ! SetWindowText(self.widget, c_string(title)) def getTitle(self): --- 715,719 ---- def setTitle(self,title): if self.widget and title: ! SetWindowText(self.widget, c_buffer(title)) def getTitle(self): *************** *** 810,828 **** def _register_class(self): #if _verbose: log('Application._register_class:start',str(self)) ! class WINDOWPROC(CFunction): ! _types_ = "iiii" ! _stdcall_ = 1 class WNDCLASS(Structure): _fields_= ( ! ('style','i'), ('lpfnWndProc',WINDOWPROC), ! ('cls_extra','i'), ! ('wnd_extra','i'), ! ('hInst','i'), ! ('hIcon','i'), ! ('hCursor','i'), ! ('hbrBackground','i'), ! ('menu_name','z'), ! ('lpzClassName','z'), ) --- 812,829 ---- def _register_class(self): #if _verbose: log('Application._register_class:start',str(self)) ! WINDOWPROC = WINFUNCTYPE(c_int,c_int,c_int,c_int,c_int) ! class WNDCLASS(Structure): _fields_= ( ! ('style',c_int), ('lpfnWndProc',WINDOWPROC), ! ('cls_extra',c_int), ! ('wnd_extra',c_int), ! ('hInst',c_int), ! ('hIcon',c_int), ! ('hCursor',c_int), ! ('hbrBackground',c_int), ! ('menu_name',c_char_p), ! ('lpzClassName',c_char_p), ) *************** *** 861,871 **** class MSG(Structure): _fields_ = ( ! ('hwnd','i'), ! ('message','i'), ! ('wParam','i'), ! ('lParam','i'), ! ('time','i'), ! ('x','i'), ! ('y','i'), ) --- 862,872 ---- class MSG(Structure): _fields_ = ( ! ('hwnd',c_int), ! ('message',c_int), ! ('wParam',c_int), ! ('lParam',c_int), ! ('time',c_int), ! ('x',c_int), ! ('y',c_int), ) |