[Wnd-commit] wnd/wnd/gdi icon.py,1.1.1.1,1.2
Status: Alpha
Brought to you by:
jurner
|
From: jürgen u. <cer...@us...> - 2005-05-15 09:39:57
|
Update of /cvsroot/wnd/wnd/wnd/gdi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3737 Modified Files: icon.py Log Message: bugfixes Index: icon.py =================================================================== RCS file: /cvsroot/wnd/wnd/wnd/gdi/icon.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** icon.py 29 Apr 2005 15:24:33 -0000 1.1.1.1 --- icon.py 15 May 2005 09:39:35 -0000 1.2 *************** *** 17,24 **** ! __all__= ("GetShellIconSize", "GetShellSmallIconSize", "SYSTEM_ICONS", "IconFromHandle", "DisposableIcon", "IconFromFile", "FileIcon", "SystemIcon", "IconFromBytes") #********************************************* # functions ! #------------------------------------------------------------------------------------------------ --- 17,45 ---- ! __all__= ("GetShellIconSize", "GetShellSmallIconSize", "SYSTEM_ICONS", "IconFromHandle", "DisposableIcon", "IconFromFile", "FileIcon", "SystemIcon", "IconFromBytes", "GetSysIconIndex") ! ! ! SYSTEM_ICONS = { ! 'application' : 32512, ! 'error' : 32513, ! 'hand' : 32513, ! 'question' : 32514, ! 'exclamation' : 32515, ! 'warning' : 32515, ! 'asterisk' : 32516, ! 'information' : 32516, ! 'winlogo' : 32517} ! ! FILEINFO_FLAGS={'linkoverlay' : 32768, ! 'selected' : 65536, ! 'largeicon' : 0, ! 'smallicon' : 1, ! 'openicon' : 2, ! 'shelliconsize' : 4} #'sysiconindex' : 4096 ! ! #********************************************* # functions ! #********************************************* *************** *** 52,55 **** --- 73,98 ---- return w.value, h.value + def GetSysIconIndex(path, *flags): + flag = 256|4096 # SHGFI_ICON|SHGFI_SYSICONINDEX + for i in flags: + try: flag |= FILEINFO_FLAGS[i] + except: raise ValueError("invalid flag: %s" % i) + + fileattributes = 0 + if path[0]=='*': + fileattributes = 128 # FILE_ATTRIBUTE_NORMAL + flag |= 16 # SHGFI_USEFILEATTRIBUTES + + if path=='directory': + fileattributes = 16 # FILE_ATTRIBUTE_DIRECTORY + flag |= 16 # SHGFI_USEFILEATTRIBUTES + + fi = SHFILEINFO() + if not shell32.SHGetFileInfoA(path, fileattributes, byref(fi), sizeof(SHFILEINFO), flag): + raise RuntimeError("could not retrieve icon") + user32.DestroyIcon(fi.hIcon) + return fi.iIcon + + #************************************************** *************** *** 60,83 **** - SYSTEM_ICONS = { - 'application' : 32512, - 'error' : 32513, - 'hand' : 32513, - 'question' : 32514, - 'exclamation' : 32515, - 'warning' : 32515, - 'asterisk' : 32516, - 'information' : 32516, - 'winlogo' : 32517} - - FILEINFO_FLAGS={'linkoverlay' : 32768, - 'selected' : 65536, - 'largeicon' : 0, - 'smallicon' : 1, - 'openicon' : 2, - 'shelliconsize' : 4} #'sysiconindex' : 4096 - - - class IconFromHandle(object): --- 103,106 ---- *************** *** 196,201 **** - - def Copy(self, w=None, h=None): flag = 0 --- 219,222 ---- *************** *** 209,213 **** - def Draw(self, dc, x, y): if not user32.DrawIcon(dc.handle, x, y, self.handle): --- 230,233 ---- *************** *** 274,278 **** #************************************************** ! class IconFromInstance(IconFromHandle): def __init__(self, instance, resname, w=0, h=0): --- 294,298 ---- #************************************************** ! class IconFromInstance(DisposableIcon): def __init__(self, instance, resname, w=0, h=0): *************** *** 295,299 **** # your processes imageist. ! class FileIcon(IconFromHandle): def __init__(self, path, *flags): --- 315,319 ---- # your processes imageist. ! class FileIcon(DisposableIcon): def __init__(self, path, *flags): *************** *** 301,305 **** flag = 256 # SHGFI_ICON for i in flags: - i = i.lower() try: flag |= FILEINFO_FLAGS[i] except: raise ValueError("invalid flag: %s" % i) --- 321,324 ---- *************** *** 314,322 **** flag |= 16 # SHGFI_USEFILEATTRIBUTES fi = SHFILEINFO() if not shell32.SHGetFileInfoA(path, fileattributes, byref(fi), sizeof(SHFILEINFO), flag): raise RuntimeError("could not retrieve icon") if not fi.hIcon: raise RuntimeError("could not retrieve icon") ! IconFromHandle.__init__(self, fi.hIcon) #************************************************ --- 333,342 ---- flag |= 16 # SHGFI_USEFILEATTRIBUTES + fi = SHFILEINFO() if not shell32.SHGetFileInfoA(path, fileattributes, byref(fi), sizeof(SHFILEINFO), flag): raise RuntimeError("could not retrieve icon") if not fi.hIcon: raise RuntimeError("could not retrieve icon") ! DisposableIcon.__init__(self, fi.hIcon) #************************************************ |