[Wnd-commit] wnd/wnd __init__.py,1.4,1.5 fwtypes.py,1.3,1.4 wintypes.py,1.3,1.4
Status: Alpha
Brought to you by:
jurner
|
From: jürgen u. <cer...@us...> - 2005-07-23 19:10:26
|
Update of /cvsroot/wnd/wnd/wnd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26125 Modified Files: __init__.py fwtypes.py wintypes.py Log Message: bit of this and a bit of that Index: fwtypes.py =================================================================== RCS file: /cvsroot/wnd/wnd/wnd/fwtypes.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fwtypes.py 2 Jul 2005 08:50:35 -0000 1.3 --- fwtypes.py 23 Jul 2005 19:10:17 -0000 1.4 *************** *** 1,5 **** ! """framework defined types ! ! """ --- 1,3 ---- ! """framework defined types""" *************** *** 9,12 **** --- 7,14 ---- POINTER, addressof, + byref, + sizeof, + memmove, + UINT_MAX, NMHDR, HIWORD, *************** *** 16,50 **** c_long, c_ushort, ! c_short,) import sys, atexit #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ! WND_MAX_CLASSNAME = 49 ! WND_N_TIMER_IDS= 10000 # counter ! WND_ERRORLEVEL= 0 # counter ! WND_MAXERROR= 0 ! WND_SZ_TRAY_MSG = "wnd_tray_msg" # Shell_NotifyIcon message ! WND_WM_TRAY = None # RegisterWindowMessage( ! # WND_SZ_TRAY_MSG) ! # ...done by TrayIcon class ! ! WND_ID_MDICHILD_MIN= 5000 # min/max IDs for MDI childs WND_ID_MDICHILD_MAX= 5999 WND_ID_CONTROL_MIN= WND_ID_MDICHILD_MAX +1 # min ID for controls ! # WND_WM_NOTIFY ! SZ_WND_NOTIFY= "wnd_notify_msg" WND_WM_NOTIFY = user32.RegisterWindowMessageA(SZ_WND_NOTIFY) if not WND_WM_NOTIFY: raise "could not register notify message" # notification codes (passed as wParam of the message) ! WND_NM_APPCREATED= 1 # not used currently ! WND_NM_MENU= 2 # lp= WND_MENU struct ! WND_NM_APPBAR= 3 # not used currently ! WND_NM_MSGREFLECT= 4 # lp= WND_MSGREFLECT struct ! WND_NM_EXCEPTION= 5 # lp= WND_EXCEPTION struct class WND_MSGREFLECT(Structure): _fields_ = [("hwndFrom", c_ulong), # who is reflecting --- 18,81 ---- c_long, c_ushort, ! c_short, ! c_ubyte, ! c_char, ! c_void_p, ! create_string_buffer, ! MAKELONG, ! COPYDATASTRUCT) ! ! from ctypes.com import GUID import sys, atexit #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ! WND_GUIMAIN = False ## main window created True/False ! WND_MSGRESULT_TRUE = 123456789 ! WND_MAX_CLASSNAME = 64 ! WND_N_TIMER_IDS = 10000 # counter ! WND_ERRORLEVEL = 0 # counter ! WND_MAXERROR = 0 ! # control id ranges ! WND_ID_MDICHILD_MIN= 5000 # min/max IDs for MDI child windows WND_ID_MDICHILD_MAX= 5999 WND_ID_CONTROL_MIN= WND_ID_MDICHILD_MAX +1 # min ID for controls ! # Shell_NotifyIcon message ! WND_SZ_TRAY_MSG = "wnd_tray_msg{D1A29F00-F917-11D9-B552-00112FF53A26}" ! WND_WM_TRAY = None # RegisterWindowMessage( ! # WND_SZ_TRAY_MSG) ! # ...done by TrayIcon class ! # copy data ! SZ_GUID_COPYDATA= "{88077500-F881-11D9-B552-00112FF53A26}" # cookie ! WND_COPYDATA_MAXDATA = 10000000 # arbitrary ! # message ids for WM_COPYDATA ! WND_CD_GUID = 1 ! ! ! # wnd notify ! SZ_WND_NOTIFY= "wnd_notify_msg{E4FB9FC0-F917-11D9-B552-00112FF53A26}" WND_WM_NOTIFY = user32.RegisterWindowMessageA(SZ_WND_NOTIFY) if not WND_WM_NOTIFY: raise "could not register notify message" # notification codes (passed as wParam of the message) ! WND_NM_APPCREATED = 1 # not used currently ! WND_NM_MENU = 2 # lp= struct WND_MENU ! WND_NM_APPBAR = 3 # not used currently ! WND_NM_MSGREFLECT = 4 # lp= struct WND_MSGREFLECT ! WND_NM_EXCEPTION = 5 # lp= struct WND_EXCEPTION ! WND_NM_DLGDISPATCH = 6 # lp= hwnd or 0 to clear ! # modeless dialogboxes should set and clear this ! # on creatinon/destruction to enable keyboard handling ! ! WND_NM_ISMAINWINDOW = 7 # lp= 0. Returns WND_MSGRESULT_TRUE for ! # mainwindows ! WND_NM_ISFWWINDOW = 8 # lp= 0. Returns WND_MSGRESULT_TRUE for framework ! # windows or childwindows ! WND_NM_GETGUID = 9 # lp= hwndReceiver. Will respond with a WM_COPYDATA ! # to the receiver passing the GUID ! class WND_MSGREFLECT(Structure): _fields_ = [("hwndFrom", c_ulong), # who is reflecting *************** *** 54,59 **** ("fReturn", c_ushort)] # filled in by receiver --> # ...True/False ! # True return the return value, ! # False continue processing MNUT_MENU= 1 --- 85,90 ---- ("fReturn", c_ushort)] # filled in by receiver --> # ...True/False ! # True: return the return value, ! # False: continue processing MNUT_MENU= 1 *************** *** 74,83 **** ! # stuff framwork defined messages and styles in a class ! # so base classes update their styles from them WS_BASE_DEBUG = 1 WS_BASE_DEBUGALL = 2 WND_DEBUGMASK= WS_BASE_DEBUG | WS_BASE_DEBUGALL class wnd_window_styles: prefix = ['WS_', 'WS_EX_', 'WS_BASE_', 'WS_CLIENT_'] --- 105,126 ---- ! # <- end wnd notify ! ! ! # framwork defined messages and styles ! # so base classes should update their styles and messages from the classes below WS_BASE_DEBUG = 1 WS_BASE_DEBUGALL = 2 WND_DEBUGMASK= WS_BASE_DEBUG | WS_BASE_DEBUGALL + + class wnd_control_styles: + prefix = ['WS_', 'WS_EX_', 'WS_BASE_', 'WS_CLIENT_'] + WS_BASE_DEBUG = WS_BASE_DEBUG + WS_BASE_DEBUGALL = WS_BASE_DEBUGALL + + WS_BASE_SUBCLASS = 64 # used for controls only + + class wnd_window_styles: prefix = ['WS_', 'WS_EX_', 'WS_BASE_', 'WS_CLIENT_'] *************** *** 90,95 **** # handling. Can not be set # at runtime. - WS_BASE_SUBCLASS = 64 # used for controls only - class wnd_window_msgs: --- 133,136 ---- *************** *** 109,121 **** class _ID(object): def __init__(self): ! # self.stack= [] self.n= WND_ID_CONTROL_MIN ! #def Recycle(self, ID): ! # if ID not in self.stack: ! # self.stack.append(ID) ! # else: raise "could not recycle ID: %s" % ID def New(self): ! #if self.stack: ! # return self.stack.pop() self.n += 1 return self.n --- 150,164 ---- class _ID(object): def __init__(self): ! self.stack= [] self.n= WND_ID_CONTROL_MIN ! ! def Recycle(self, ID): ! if ID not in self.stack: ! self.stack.append(ID) ! else: raise "could not recycle ID: %s" % ID ! def New(self): ! if self.stack: ! return self.stack.pop() self.n += 1 return self.n *************** *** 124,128 **** - class Handles(object): def __init__(self, initval=0): --- 167,170 ---- *************** *** 226,248 **** elif msg==WND_WM_NOTIFY: ! ## expand reflected messages ! mr= WND_MSGREFLECT.from_address(lp) ! if mr.msg== 78: # WM_NOTIFY ! msgOut= mr.msg ! name, code= self.GetNm(mr.lParam) ! s= self.remsg % (name, ! code, ! hwnd, ! mr.wParam, ! mr.lParam, ! mr.hwndFrom) else: ! msgOut= mr.msg ! s= self.remsg % (self.MsgName(mr.msg), ! mr.msg, ! hwnd, ! mr.wParam, ! mr.lParam, ! mr.hwndFrom) else: s= self.msg % (self.MsgName(msg), msg, hwnd, wp, lp) --- 268,294 ---- elif msg==WND_WM_NOTIFY: ! ! if wp== WND_NM_MSGREFLECT: ! ## expand reflected messages ! mr= WND_MSGREFLECT.from_address(lp) ! if mr.msg== 78: # WM_NOTIFY ! msgOut= mr.msg ! name, code= self.GetNm(mr.lParam) ! s= self.remsg % (name, ! code, ! hwnd, ! mr.wParam, ! mr.lParam, ! mr.hwndFrom) ! else: ! msgOut= mr.msg ! s= self.remsg % (self.MsgName(mr.msg), ! mr.msg, ! hwnd, ! mr.wParam, ! mr.lParam, ! mr.hwndFrom) else: ! s= self.msg % (self.MsgName(msg), msg, hwnd, wp, lp) else: s= self.msg % (self.MsgName(msg), msg, hwnd, wp, lp) *************** *** 326,329 **** --- 372,376 ---- window._base_fMsgReflect= Bool and 1 or 0 + """******************************************************************** handlers for reflecting messages *************** *** 364,368 **** def ReflectMessage(hwnd, hwndTo, msg, wp, lp): - fReturn = c_ushort() msgr= WND_MSGREFLECT(hwnd, msg, wp, lp) result =user32.SendMessageA(hwndTo, --- 411,414 ---- *************** *** 410,426 **** ! def IsDialogReflectMessage(hwnd, msg, wp, lp): ! ## TODO: test ## filter WM_COMMAND for dialog boxes if msg==273: # WM_COMMAND if lp: if lp !=1: # IDOK if lp != 2: # IDCANCEL #DM_GETDEFID = WM_USER + 0 result= user32.SendMessageA(hwnd, 1024, 0, 0) if HIWORD(result) == 21323: # DC_HASDEFID defID= user32.GetDlgItem(hwnd, LOWORD(result)) if defID != lp: return ReflectMessage(hwnd, lp, msg, wp, lp) --- 456,479 ---- ! def IsDialogReflectMessage(hwnd, msg, wp, lp, dlgmode): ! #print dlgmode ## TODO: test ## filter WM_COMMAND for dialog boxes if msg==273: # WM_COMMAND + + #print wp, lp if lp: + if dlgmode=='modeless': + return ReflectMessage(hwnd, lp, msg, wp, lp) + if lp !=1: # IDOK if lp != 2: # IDCANCEL #DM_GETDEFID = WM_USER + 0 result= user32.SendMessageA(hwnd, 1024, 0, 0) + if HIWORD(result) == 21323: # DC_HASDEFID defID= user32.GetDlgItem(hwnd, LOWORD(result)) + if defID != lp: return ReflectMessage(hwnd, lp, msg, wp, lp) *************** *** 452,454 **** return ReflectMessage(hwnd, user32.GetDlgItem(hwnd, wp),msg, wp, lp) ! return None \ No newline at end of file --- 505,559 ---- return ReflectMessage(hwnd, user32.GetDlgItem(hwnd, wp),msg, wp, lp) ! return None ! ! ! """***************************************************************************************** ! Copy Data handlers ! ! CopyData(hwndSource, hwndDest, lp, data, reserved = 0) ! Copies data to another window ! ! hwndSource = the source window for the data ! hwndDest = the destination window ! lp = user defined parameter (range 0-65535) ! data = data to send (may be any string) ! reserved = if 1 the message is handled internally, setting a var _base_copyDataResult ! not notifying the user, if 0 the user will receive a 'copydata' message in ! the handler of its window ! ! Return value: True if the receiver returned True, False otherwise ! ! ! HandleCopyData(hwnd, msg, wp, lp) ! ! Handles WM_COPYDATA in a messageloop ! ! Return value: the data being copied (as string) or None if the message ! does not conform framework rules ! ! ! For the framework to recognize a WM_COPYDATA as 'friendly' the data is ! prefixed internally with the GUID SZ_GUID_COPYDATA. ! ! *****************************************************************************************""" ! WM_COPYDATA = 74 ! ! def CopyData(hwndSource, hwndDest, lp, data, reserved = 0): ! p= create_string_buffer(SZ_GUID_COPYDATA + data) ! ## do not include NULL byte in cbData ! cd= COPYDATASTRUCT(MAKELONG(lp, reserved), sizeof(p) -1, addressof(p)) ! return bool(user32.SendMessageA(hwndDest, WM_COPYDATA, hwndSource, byref(cd))) ! ! def HandleCopyData(hwnd, msg, wp, lp): ! cd = COPYDATASTRUCT.from_address(lp) ! ! # make shure only trustable data gets in here ! if WND_COPYDATA_MAXDATA >= cd.cbData >= len(SZ_GUID_COPYDATA): ! data= (c_char*cd.cbData).from_address(cd.lpData) ! if data[:len(SZ_GUID_COPYDATA)] == SZ_GUID_COPYDATA: ! return (cd.dwData, ''.join(data[len(SZ_GUID_COPYDATA):])) ! ! ! ! ! Index: wintypes.py =================================================================== RCS file: /cvsroot/wnd/wnd/wnd/wintypes.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** wintypes.py 2 Jul 2005 08:50:35 -0000 1.3 --- wintypes.py 23 Jul 2005 19:10:17 -0000 1.4 *************** *** 26,30 **** #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ! UINT_MAX = 1<<32 INT_MIN = -2147483647 - 1 INT_MAX = 2147483647 --- 26,30 ---- #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ! UINT_MAX = 1 << 32 INT_MIN = -2147483647 - 1 INT_MAX = 2147483647 *************** *** 68,79 **** def MAKEWORD(byte1, byte2): return byte1 | (byte2 << 8) def MAKELONG(word1, word2): return word1 | (word2 << 16) - def MAKEINTRESOURCE(i): - p= create_string_buffer(4) - memmove(p, addressof(c_int(i)), 4) - return p - - - #return LPSTR(addressof(c_ulong(i))) - def RGB(r, g, b): return r | (g<<8) | (b<<16) def GETRGB(colorref): return colorref & 255,colorref >> 8 & 255,colorref >> 16 & 255 --- 68,71 ---- *************** *** 86,91 **** class NMHDR(Structure): _fields_=[("hwndFrom", HWND), ! ("idFrom", UINT), ! ("code", UINT)] --- 78,83 ---- class NMHDR(Structure): _fields_=[("hwndFrom", HWND), ! ("idFrom", UINT), ! ("code", UINT)] *************** *** 167,176 **** - #r0 = RECT(10, 10, 20, 20) - #r1 = RECT(15, 15, 30, 30) - - #r3 = r0.offset(10, 3) - - #************************************************ class POINT(POINT): --- 159,162 ---- *************** *** 187,196 **** raise "could not convert coordinates" - #rc= RECT(0, 0, 30, 30) - #pt=POINT(3, 4) - #************************************************************************************* class MEASUREITEMSTRUCT(Structure): _fields_ = [("CtlType", UINT), --- 173,184 ---- raise "could not convert coordinates" #************************************************************************************* + class COPYDATASTRUCT(Structure): + _fields_ = [("dwData", c_ulong), + ("cbData", c_ulong), + ("lpData", c_void_p)] + class MEASUREITEMSTRUCT(Structure): _fields_ = [("CtlType", UINT), *************** *** 314,324 **** # ...and the test if it works ! # some message box would be nice here ! result=DllGetVersion(comctl32) ! VER_COMCTL =result.dwMajorVersion, result.dwMinorVersion if VER_COMCTL < (4, 71): from wnd.api.msgbox import Msg ! msg= '''Sorry, at least comctl32.dll version 4.71 is required. ! Found version %s.%s'''.replace('\t', '') Msg(0, msg % VER_COMCTL, 'wnd-module', 'ok', 'systemmodal') --- 302,312 ---- # ...and the test if it works ! result = DllGetVersion(comctl32) ! VER_COMCTL = result.dwMajorVersion, result.dwMinorVersion if VER_COMCTL < (4, 71): from wnd.api.msgbox import Msg ! msg= '''Sorry ! At least comctl32.dll ver 4.71 is required ! Found ver %s.%s on your system'''.replace('\t', '') Msg(0, msg % VER_COMCTL, 'wnd-module', 'ok', 'systemmodal') Index: __init__.py =================================================================== RCS file: /cvsroot/wnd/wnd/wnd/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** __init__.py 2 Jul 2005 08:50:35 -0000 1.4 --- __init__.py 23 Jul 2005 19:10:17 -0000 1.5 *************** *** 1,5 **** """Framework entry... """ ! __version__= "0.1.12" --- 1,5 ---- """Framework entry... """ ! __version__= "0.1.20" |