[Spambayes-checkins] spambayes/Outlook2000/dialogs/resources
rc2py.py, 1.2, 1.3 rcparser.py, 1.3, 1.4
Adam Walker
xenogeist at users.sourceforge.net
Thu Aug 14 15:12:00 EDT 2003
Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs/resources
In directory sc8-pr-cvs1:/tmp/cvs-serv9932/Outlook2000/dialogs/resources
Modified Files:
rc2py.py rcparser.py
Log Message:
Parse .h file. Allow parsing of picture boxes (static controls with a image), these controls require that the ids of the bitmaps match the .h file. Parse BITMAP clauses in the .rc and store the filenames in a dict member of RCParser called 'bitmaps'
Index: rc2py.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/resources/rc2py.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rc2py.py 10 Aug 2003 07:26:50 -0000 1.2
--- rc2py.py 14 Aug 2003 21:11:57 -0000 1.3
***************
*** 23,26 ****
--- 23,27 ----
out.write("\tids = "+repr(rcp.ids)+"\n")
out.write("\tnames = "+repr(rcp.names)+"\n")
+ out.write("\tbitmaps = "+repr(rcp.bitmaps)+"\n")
out.write("def ParseDialogs(s):\n")
out.write("\treturn FakeParser()\n")
Index: rcparser.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/resources/rcparser.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** rcparser.py 13 Aug 2003 19:31:10 -0000 1.3
--- rcparser.py 14 Aug 2003 21:11:57 -0000 1.4
***************
*** 8,11 ****
--- 8,12 ----
import sys, os, shlex
import win32con
+ #import win32gui
import commctrl
***************
*** 92,97 ****
class RCParser:
- ids = {"IDOK":1, "IDCANCEL":2, "IDC_STATIC": -1}
- names = {1:"IDOK", 2:"IDCANCEL", -1:"IDC_STATIC"}
next_id = 1001
dialogs = {}
--- 93,96 ----
***************
*** 100,103 ****
--- 99,107 ----
token = ""
+ def __init__(self):
+ self.ids = {"IDOK":1, "IDCANCEL":2, "IDC_STATIC": -1}
+ self.names = {1:"IDOK", 2:"IDCANCEL", -1:"IDC_STATIC"}
+ self.bitmaps = {}
+
def debug(self, *args):
if self.debugEnabled:
***************
*** 118,121 ****
--- 122,132 ----
The "names" member contains the dictionary of name->id
"""
+ hFileName = rcFileName[:-2]+"h"
+ try:
+ h = open(hFileName, "rU")
+ self.parseH(h)
+ h.close()
+ except:
+ print "No .h file. ignoring."
f = open(rcFileName)
self.open(f)
***************
*** 129,132 ****
--- 140,160 ----
self.lex.commenters = "//#"
+ def parseH(self, file):
+ lex = shlex.shlex(file)
+ lex.commenters = "//"
+ token = " "
+ while token is not None:
+ token = lex.get_token()
+ if token == "" or token is None:
+ token = None
+ else:
+ if token=='define':
+ n = lex.get_token()
+ i = int(lex.get_token())
+ self.ids[n] = i
+ self.names[i] = n
+ if self.next_id<=i:
+ self.next_id = i+1
+
def parse(self):
deep = 0
***************
*** 141,151 ****
elif "END" == self.token:
deep -= 1
! elif "IDD_" != self.token[:4]:
! self.getToken()
! else:
possibleDlgName = self.token
self.getToken()
if "DIALOG" == self.token or "DIALOGEX" == self.token:
self.dialog(possibleDlgName)
def addId(self, id_name):
--- 169,187 ----
elif "END" == self.token:
deep -= 1
! elif "IDD_" == self.token[:4]:
possibleDlgName = self.token
+ #print "possible dialog:", possibleDlgName
self.getToken()
if "DIALOG" == self.token or "DIALOGEX" == self.token:
self.dialog(possibleDlgName)
+ elif "IDB_" == self.token[:4]:
+ possibleBitmap = self.token
+ self.getToken()
+ if "BITMAP" == self.token:
+ self.getToken()
+ bmf = self.token[1:-1] # quotes
+ self.bitmaps[possibleBitmap] = bmf
+ print "BITMAP", possibleBitmap, bmf
+ #print win32gui.LoadImage(0, bmf, win32con.IMAGE_BITMAP,0,0,win32con.LR_DEFAULTCOLOR|win32con.LR_LOADFROMFILE)
def addId(self, id_name):
***************
*** 263,266 ****
--- 299,306 ----
if self.token[0:1]=='"':
control.label = self.token[1:-1]
+ self.getToken() # ,
+ self.getToken()
+ elif self.token.isdigit():
+ control.label = self.token
self.getToken() # ,
self.getToken()
More information about the Spambayes-checkins
mailing list