X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/41a499cd92710e3c954fa6e23ce3438cf26f5fcf..194323c7c0c16222a1c05e2d7f7c507439d7260f:/src/stc/gen_iface.py diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index f35fb2931b..2dfea4c444 100644 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -21,6 +21,7 @@ H_TEMPLATE = os.path.abspath('./stc.h.in') CPP_TEMPLATE = os.path.abspath('./stc.cpp.in') H_DEST = os.path.abspath('../../include/wx/stc/stc.h') CPP_DEST = os.path.abspath('./stc.cpp') +DOCSTR_DEST = os.path.abspath('../../../wxPython/contrib/stc/_stc_gendocs.i') # Value prefixes to convert @@ -36,16 +37,17 @@ valPrefixes = [('SCI_', ''), ] # Message function values that should have a CMD_ constant generated -cmdValues = [ (2300, 2349), - 2011, +cmdValues = [ 2011, 2013, (2176, 2180), + (2300, 2349), (2390, 2393), (2395, 2396), 2404, (2413, 2416), (2426, 2442), (2450, 2455), + 2518, ] @@ -202,6 +204,8 @@ methodOverrideMap = { // convert bmp to a xpm in a string wxMemoryOutputStream strm; wxImage img = bmp.ConvertToImage(); + if (img.HasAlpha()) + img.ConvertAlphaToMask(); img.SaveFile(strm, wxBITMAP_TYPE_XPM); size_t len = strm.GetSize(); char* buff = new char[len+1]; @@ -222,13 +226,30 @@ methodOverrideMap = { 'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0), 'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0), + + 'StyleGetFore' : ('StyleGetForeground', 0, 0, 0), + 'StyleGetBack' : ('StyleGetBackground', 0, 0, 0), 'StyleSetFore' : ('StyleSetForeground', 0, 0, 0), 'StyleSetBack' : ('StyleSetBackground', 0, 0, 0), 'SetSelFore' : ('SetSelForeground', 0, 0, 0), 'SetSelBack' : ('SetSelBackground', 0, 0, 0), 'SetCaretFore' : ('SetCaretForeground', 0, 0, 0), + 'StyleGetFont' : + ('StyleGetFaceName', + 'wxString %s(int style);', + '''wxString %s(int style) { + long msg = %s; + long len = SendMsg(msg, style, 0); + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, style, (long)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf);''', + ('Get the font facename of a style',)), 'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0), - + 'StyleSetCharacterSet' : (None, 0, 0, 0), + 'AssignCmdKey' : ('CmdKeyAssign', 'void %s(int key, int modifiers, int cmd);', @@ -262,7 +283,9 @@ methodOverrideMap = { 'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0), 'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0), 'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0), - + 'IndicSetUnder': ('IndicatorSetUnder', 0, 0, 0), + 'IndicGetUnder': ('IndicatorGetUnder', 0, 0, 0), + 'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0), 'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0), @@ -289,7 +312,12 @@ methodOverrideMap = { 'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0, 0), 'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0, 0), 'AutoCGetCurrent' : ('AutoCompGetCurrent', 0, 0, 0), - + 'AutoCSetMaxWidth' : ('AutoCompSetMaxWidth', 0, 0, 0), + 'AutoCGetMaxWidth' : ('AutoCompGetMaxWidth', 0, 0, 0), + 'AutoCSetMaxHeight' : ('AutoCompSetMaxHeight', 0, 0, 0), + 'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0), + 'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0), + 'RegisterImage' : (0, '''void %s(int type, const wxBitmap& bmp);''', @@ -297,6 +325,8 @@ methodOverrideMap = { // convert bmp to a xpm in a string wxMemoryOutputStream strm; wxImage img = bmp.ConvertToImage(); + if (img.HasAlpha()) + img.ConvertAlphaToMask(); img.SaveFile(strm, wxBITMAP_TYPE_XPM); size_t len = strm.GetSize(); char* buff = new char[len+1]; @@ -477,7 +507,11 @@ methodOverrideMap = { 'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0), 'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0), - + 'GetHotspotActiveFore' : ('GetHotspotActiveForeground', 0, 0, 0), + 'GetHotspotActiveBack' : ('GetHotspotActiveBackground', 0, 0, 0), + + 'GetCaretLineBack' : ('GetCaretLineBackground', 0, 0, 0), + 'SetCaretLineBack' : ('SetCaretLineBackground', 0, 0, 0), 'ReplaceTarget' : (0, @@ -513,7 +547,45 @@ methodOverrideMap = { 'TargetAsUTF8' : ( None, 0, 0, 0), 'SetLengthForEncode' : ( None, 0, 0, 0), 'EncodedFromUTF8' : ( None, 0, 0, 0), - + + + 'GetProperty' : + (0, + 'wxString %s(const wxString& key);', + + '''wxString %s(const wxString& key) { + int len = SendMsg(SCI_GETPROPERTY, (long)(const char*)wx2stc(key), 0); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(%s, (long)(const char*)wx2stc(key), (long)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf);''', + ("Retrieve a 'property' value previously set with SetProperty.",)), + + 'GetPropertyExpanded' : + (0, + 'wxString %s(const wxString& key);', + + '''wxString %s(const wxString& key) { + int len = SendMsg(SCI_GETPROPERTYEXPANDED, (long)(const char*)wx2stc(key), 0); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(%s, (long)(const char*)wx2stc(key), (long)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf);''', + ("Retrieve a 'property' value previously set with SetProperty,", + "with '$()' variable replacement on returned buffer.")), + + 'GetPropertyInt' : (0, 0, 0, + ("Retrieve a 'property' value previously set with SetProperty,", + "interpreted as an int AFTER any '$()' variable replacement.")), + 'GetDocPointer' : (0, @@ -575,6 +647,9 @@ methodOverrideMap = { 'LoadLexerLibrary' : (None, 0,0,0), + 'SetPositionCache' : ('SetPositionCacheSize', 0, 0, 0), + 'GetPositionCache' : ('GetPositionCacheSize', 0, 0, 0), + '' : ('', 0, 0, 0), @@ -582,7 +657,7 @@ methodOverrideMap = { #---------------------------------------------------------------------------- -def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest): +def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest, docstr_dest): curDocStrings = [] values = [] methods = [] @@ -629,7 +704,7 @@ def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest): data = {} data['VALUES'] = processVals(values) data['CMDS'] = processVals(cmds) - defs, imps = processMethods(methods) + defs, imps, docstrings = processMethods(methods) data['METHOD_DEFS'] = defs data['METHOD_IMPS'] = imps @@ -644,6 +719,7 @@ def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest): # write out destination files open(h_dest, 'w').write(h_text) open(cpp_dest, 'w').write(cpp_text) + open(docstr_dest, 'w').write(docstrings) @@ -664,6 +740,7 @@ def processVals(values): def processMethods(methods): defs = [] imps = [] + dstr = [] for retType, name, number, param1, param2, docs in methods: retType = retTypeMap.get(retType, retType) @@ -674,6 +751,11 @@ def processMethods(methods): if name is None: continue + # Build docstrings + st = 'DocStr(wxStyledTextCtrl::%s,\n' \ + '"%s", "");\n' % (name, '\n'.join(docs)) + dstr.append(st) + # Build the method definition for the .h file if docs: defs.append('') @@ -707,7 +789,7 @@ def processMethods(methods): imps.append(theImp) - return string.join(defs, '\n'), string.join(imps, '\n') + return '\n'.join(defs), '\n'.join(imps), '\n'.join(dstr) #---------------------------------------------------------------------------- @@ -827,7 +909,7 @@ def main(args): # TODO: parse command line args to replace default input/output files??? # Now just do it - processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST) + processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST, DOCSTR_DEST)