Fix wxScrolledWindow wrapping, and remove workarounds

This commit is contained in:
Robin Dunn
2017-01-23 14:06:37 -08:00
parent a788be964d
commit 066a9fd80f
5 changed files with 37 additions and 44 deletions

View File

@@ -55,8 +55,6 @@ def run():
module.addPyCode('import wx', order=10)
module.addInclude(INCLUDES)
# TODO: Remove this when wxScrolledWindow inheritance is fixed
module.addHeaderCode('typedef wxScrolled<wxPanel> _ScrolledWindowBase;')
#-----------------------------------------------------------------

View File

@@ -58,9 +58,6 @@ def run():
module.addImport('_core')
module.addPyCode("import wx", order=10)
# TODO: Remove this when wxScrolledWindow inheritance is fixed
module.addHeaderCode('typedef wxScrolled<wxPanel> _ScrolledWindowBase;')
module.addInclude(INCLUDES)

View File

@@ -78,9 +78,6 @@ def run():
module.addPyCode("import wx", order=10)
module.addInclude(INCLUDES)
# TODO: Remove this when wxScrolledWindow inheritance is fixed
module.addHeaderCode('typedef wxScrolled<wxPanel> _ScrolledWindowBase;')
module.addCppCode("""\
#include <wx/html/htmlwin.h>
#include <wx/html/htmprint.h>

View File

@@ -60,9 +60,6 @@ def run():
module.addPyCode('import wx', order=10)
module.addInclude(INCLUDES)
# TODO: Remove this when wxScrolledWindow inheritance is fixed
module.addHeaderCode('typedef wxScrolled<wxPanel> _ScrolledWindowBase;')
#-----------------------------------------------------------------
#-----------------------------------------------------------------

View File

@@ -63,10 +63,9 @@ def run():
scrolled.find('GetSizeAvailableForScrollTarget').ignore(False)
scrolled.find('SendAutoScrollEvents').isVirtual = True
# The wxScrolledWindow and wxScrolledCanvas typedefs will be output
# normally and SIP will treat them like classes that have a
# wxScrolled mix-in as one of their base classes. Let's add some more
# info to them for the doc generators.
# The wxScrolledCanvas typedef will be output normally and SIP will treat
# it like a class that has a wxScrolled mix-in as one of the base classes.
# Let's add some more info to them for the doc generators.
docBase = """\
The :ref:`{name}` class is a combination of the :ref:`{base}` and
:ref:`Scrolled` classes, and manages scrolling for its client area,
@@ -74,12 +73,6 @@ def run():
and setting the scroll positions, thumb sizes and ranges according to
the area in view.
"""
item = module.find('wxScrolledWindow')
assert isinstance(item, etgtools.TypedefDef)
item.docAsClass = True
item.bases = ['wxPanel', 'wxScrolled']
item.briefDoc = docBase.format(name='ScrolledWindow', base='Panel')
item = module.find('wxScrolledCanvas')
item.docAsClass = True
item.bases = ['wxWindow', 'wxScrolled']
@@ -87,40 +80,51 @@ def run():
item.detailedDoc[0] = "This scrolled window is not intended to have children "\
"so it doesn't have special handling for TAB traversal "\
"or focus management."
module.items.remove(item)
# wxScrolledWindow is documented as a typedef but it's actually a class.
# So we need to implement it that way here too in order to keep
# static_casts happy.
# move it ahead of wxScrolledWindow
sw = module.find('wxScrolledWindow')
assert isinstance(sw, TypedefDef)
sw.name = '_ScrolledWindowBase'
module.items.remove(item)
module.insertItemBefore(sw, item)
# wxScrolledWindow is documented as a typedef but it's actually a class.
# So we need to implement it that way here too in order to keep
# static_casts and such happy.
assert isinstance(sw, TypedefDef)
# First, let's add a typedef to serve as the base class of
# wxScrolledWindow, since SIP doesn't yet understand using template
# instantiations as base classes. Setting noTypeName tells SIP to not use
# the typedef name in the actual generated code, but the typedef's type
# instead.
td = TypedefDef(name='_ScrolledWindowBase',
type='wxScrolled<wxPanel>',
noTypeName=True,
piIgnored=True)
module.insertItemAfter(sw, td)
module.addHeaderCode('typedef wxScrolled<wxPanel> _ScrolledWindowBase;')
sw.ignore()
# Now implement the class definition
klass = ClassDef(
name='wxScrolledWindow',
bases=['_ScrolledWindowBase'],
##bases=['wxScrolled<wxPanel>'],
piBases=['Window', 'Scrolled'],
briefDoc=sw.briefDoc, detailedDoc=sw.detailedDoc,
items=[
MethodDef(name='wxScrolledWindow', isCtor=True, items=[]),
MethodDef(name='wxScrolledWindow', isCtor=True, items=[
ParamDef(name='parent', type='wxWindow*'),
ParamDef(name='winid', type='wxWindowID', default='wxID_ANY'),
ParamDef(name='pos', type='const wxPoint&', default='wxDefaultPosition'),
ParamDef(name='size', type='const wxSize&', default='wxDefaultSize'),
ParamDef(name='style', type='long', default='wxScrolledWindowStyle'),
ParamDef(name='name', type='const wxString&', default='wxPanelNameStr'),
]),
MethodDef(name='wxScrolledWindow', isCtor=True, items=[],
overloads=[
MethodDef(name='wxScrolledWindow', isCtor=True, items=[
ParamDef(name='parent', type='wxWindow*'),
ParamDef(name='winid', type='wxWindowID', default='wxID_ANY'),
ParamDef(name='pos', type='const wxPoint&', default='wxDefaultPosition'),
ParamDef(name='size', type='const wxSize&', default='wxDefaultSize'),
ParamDef(name='style', type='long', default='wxScrolledWindowStyle'),
ParamDef(name='name', type='const wxString&', default='wxPanelNameStr'),
]),
]),
],
)
module.insertItemAfter(sw, klass)
##sw.ignore()
module.addHeaderCode('typedef wxScrolled<wxPanel> _ScrolledWindowBase;')
module.insertItemAfter(td, klass)
module.addPyCode("PyScrolledWindow = wx.deprecated(ScrolledWindow, 'Use ScrolledWindow instead.')")