Update ETG scripts to support wxWidgets 3.1.6 functionality

Fixes #2136.
This commit is contained in:
Scott Talbert
2022-04-14 19:51:57 -04:00
parent cc4e5c313f
commit aa1ef7bd75
20 changed files with 238 additions and 9 deletions

View File

@@ -49,6 +49,7 @@ INCLUDES = [ # base and core stuff
'userdata',
'wxpybuffer',
'msgdlg_btnlabel',
'wxvector',
'stockgdi',
'longlong',
@@ -76,6 +77,7 @@ INCLUDES = [ # base and core stuff
'image',
'gdiobj',
'bitmap',
'bmpbndl',
'icon', 'iconloc', 'iconbndl',
'font',
'fontutil',

View File

@@ -152,6 +152,7 @@ def run():
tc_excludes = ['OSXEnableAutomaticQuoteSubstitution',
'OSXEnableAutomaticDashSubstitution',
'OSXDisableAllSmartSubstitutions',
'OSXEnableNewLineReplacement',
]
import textctrl
mod = textctrl.parseAndTweakModule()

View File

@@ -10,6 +10,7 @@
import etgtools
import etgtools.tweaker_tools as tools
from etgtools import PyFunctionDef, PyCodeDef, PyPropertyDef
import sys
PACKAGE = "wx"
MODULE = "_core"
@@ -206,6 +207,8 @@ def run():
c.addProperty('UseBestVisual GetUseBestVisual SetUseBestVisual')
c.addProperty('TopWindow GetTopWindow SetTopWindow')
if sys.platform != 'linux':
c.find('GTKSuppressDiagnostics').ignore()
#-------------------------------------------------------

58
etg/bmpbndl.py Normal file
View File

@@ -0,0 +1,58 @@
#---------------------------------------------------------------------------
# Name: etg/bmpbndl.py
# Author: Scott Talbert
#
# Created: 13-Apr-2022
# Copyright: (c) 2022 by Scott Talbert
# License: wxWindows License
#---------------------------------------------------------------------------
import etgtools
import etgtools.tweaker_tools as tools
from etgtools import MethodDef
PACKAGE = "wx"
MODULE = "_core"
NAME = "bmpbndl" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxBitmapBundle',
'wxBitmapBundleImpl',
]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
#module.addHeaderCode('#include <wx/some_header_file.h>')
c = module.find('wxBitmapBundle')
assert isinstance(c, etgtools.ClassDef)
c.find('FromSVG').findOverload('char *data, const wxSize &sizeDef').ignore()
c = module.find('wxBitmapBundleImpl')
assert isinstance(c, etgtools.ClassDef)
m = MethodDef(name='~wxBitmapBundleImpl', isDtor=True, isVirtual=True, protection='protected')
c.addItem(m)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

View File

@@ -45,6 +45,7 @@ def run():
c.find('wxCursor').findOverload('cursorName').find('type').default='wxBITMAP_TYPE_ANY'
# TODO: This ctor ^^ in Classic has a custom implementation for wxGTK that
# sets the hotspot. Is that still needed?
c.find('wxCursor').findOverload('(const char *const *xpmData)').ignore()
c.addCppMethod('int', '__nonzero__', '()', "return self->IsOk();")
c.addCppMethod('int', '__bool__', '()', "return self->IsOk();")

View File

@@ -344,7 +344,7 @@ def run():
c.addItem(etgtools.WigCode("""\
virtual void SetTitle(const wxString& title);
virtual wxString GetTitle() const;
virtual void SetBitmap(const wxBitmap& bitmap);
virtual void SetBitmap(const wxBitmapBundle& bitmap);
virtual wxBitmap GetBitmap() const;
virtual void SetWidth(int width);
virtual int GetWidth() const;

View File

@@ -110,6 +110,9 @@ def run():
module.addPyCode("ADJUST_MINSIZE = 0")
module.addPyCode("WS_EX_VALIDATE_RECURSIVELY = 0")
# This is only supported with C++14, so ignore it for now
module.find('wxDEPRECATED_ATTR').ignore()
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -100,6 +100,11 @@ def run():
#endif
""")
# Missing in 3.1.6
module.addItem(etgtools.WigCode("""\
wxEventType wxEVT_FULLSCREEN /PyName=wxEVT_FULLSCREEN/;
"""))
module.addPyClass('PyEventBinder', ['object'],
doc="""\

View File

@@ -155,6 +155,9 @@ def run():
c.find('operator*=').all() + \
c.find('operator/=').all():
f.ignore(False)
# Ignore these because they conflict with __imul__() and __itruediv__()
c.find('operator*=').findOverload('double').ignore()
c.find('operator/=').findOverload('double').ignore()
c.addCppMethod('bool', '__eq__', '(const wxSize& other)',
body="return *self == *other;")

View File

@@ -73,7 +73,7 @@ def run():
virtual wxWindow* GetHTMLWindow();
virtual wxColour GetHTMLBackgroundColour() const;
virtual void SetHTMLBackgroundColour(const wxColour& clr);
virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
virtual void SetHTMLBackgroundImage(const wxBitmapBundle& bmpBg);
virtual void SetHTMLStatusText(const wxString& text);
virtual wxCursor GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor type) const;
"""))

View File

@@ -79,6 +79,9 @@ def run():
#endif
""")
# Documented wrongly in 3.1.6
c.find('GetLogicalSize').type = 'wxSize'
# For compatibility:
module.addPyFunction('EmptyIcon', '()',

View File

@@ -333,6 +333,10 @@ def run():
#endif
""")
# Documented wrongly in 3.1.6
c.find('RemoveSortIndicator').type = 'void'
c.find('RemoveSortIndicator').isConst = False
#-------------------------------------------------------
c = module.find('wxListView')

View File

@@ -109,11 +109,12 @@ def run():
c.find('GetBitmap').type = 'const wxBitmap*'
c.find('GetBitmap').transferBack = True
c.find('GetBitmap').setCppCode("""\
#ifdef __WXMSW__
return &self->GetBitmap(checked);
return new wxBitmap(self->GetBitmap(checked));
#else
return &self->GetBitmap();
return new wxBitmap(self->GetBitmap());
#endif
""")
@@ -157,6 +158,10 @@ def run():
module.addItem(tools.wxListWrapperTemplate('wxMenuItemList', 'wxMenuItem', module))
# Documented wrongly in 3.1.6
c.find('AddExtraAccel.accel').isConst = True
c.find('AddExtraAccel.accel').type = 'wxAcceleratorEntry&'
#-----------------------------------------------------------------

View File

@@ -79,8 +79,6 @@ def run():
tools.wxArrayWrapperTemplate('wxRichTextVariantArray', 'wxVariant', module))
module.addItem(
tools.wxListWrapperTemplate('wxRichTextObjectList', 'wxRichTextObject', module))
module.addItem(
tools.wxListWrapperTemplate('wxRichTextLineList', 'wxRichTextLine', module))
# Can this even work? Apparently it does.
module.addItem(
@@ -319,6 +317,21 @@ def run():
fakeListClassName='wxRichTextObjectList_'))
c.find('MoveToList.list').type = 'wxRichTextObjectList_&'
c.find('MoveFromList.list').type = 'wxRichTextObjectList_&'
# TODO: figure out why wxvector.sip doesn't work for this
c.find('GetLines').type = 'PyObject*'
c.find('GetLines').setCppCode("""\
wxPyThreadBlocker blocker;
PyObject* result = PyList_New(0);
const wxRichTextLineVector& vector = self->GetLines();
for (size_t idx=0; idx < vector.size(); idx++) {{
PyObject* obj;
wxRichTextLine* item = new wxRichTextLine(*vector.at(idx));
obj = wxPyConstructObject((void*)item, "wxRichTextLine", true);
PyList_Append(result, obj);
Py_DECREF(obj);
}}
return result;
""")
#-------------------------------------------------------

View File

@@ -9,6 +9,8 @@
# License: wxWindows License
#---------------------------------------------------------------------------
import sys
import etgtools
import etgtools.tweaker_tools as tools
@@ -144,6 +146,15 @@ def parseAndTweakModule():
#endif
""")
# TODO: add support for wxTextProofOptions (only supported on MSW/GTK3)
# so will need stubs on other platforms.
c.find('EnableProofCheck').ignore()
c.find('GetProofCheckOptions').ignore()
# This function only exists on OSX
if sys.platform != 'darwin':
c.find('OSXEnableNewLineReplacement').ignore()
c = module.find('wxTextUrlEvent')

View File

@@ -150,7 +150,6 @@ def run():
# transfer imagelist ownership
c.find('AssignImageList.imageList').transfer = True
c.find('AssignStateImageList.imageList').transfer = True
c.find('AssignButtonsImageList.imageList').transfer = True

View File

@@ -91,6 +91,11 @@ def run():
# This tweak is needed only for the stub code
module.find('wxWebViewHandler.wxWebViewHandler').argsString = '(const wxString& scheme="")'
# Documented wrongly in 3.1.6 (needs to be fixed in stubs too)
c = module.find('wxWebViewFactory')
c.find('GetVersionInfo').argsString = '()'
c.find('GetVersionInfo').items = []
tools.generateStubs('wxUSE_WEBVIEW', module,
typeValMap={
'wxWebViewNavigationActionFlags': 'wxWEBVIEW_NAV_ACTION_NONE',
@@ -98,6 +103,13 @@ def run():
'wxVersionInfo': 'wxVersionInfo()',
})
# Missing in 3.1.6
module.addItem(etgtools.WigCode("""\
wxEventType wxEVT_WEBVIEW_FULLSCREEN_CHANGED /PyName=wxEVT_WEBVIEW_FULLSCREEN_CHANGED/;
wxEventType wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED /PyName=wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED/;
wxEventType wxEVT_WEBVIEW_SCRIPT_RESULT /PyName=wxEVT_WEBVIEW_SCRIPT_RESULT/;
"""))
c = module.find('wxWebView')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)