Better implementation to ensure all window classes have a GetClassDefaultAttributes and that they are marked mustHaveApp

This commit is contained in:
Robin Dunn
2019-04-13 13:54:34 -07:00
parent c0d3c2d4e7
commit 877c4f7642
2 changed files with 19 additions and 7 deletions

View File

@@ -46,7 +46,6 @@ def run():
c = module.find('wxProgressDialog')
tools.fixWindowClass(c)
# Copy methods from the generic to the native class. This is needed
# because none of the methods are declared in the interface files, and
@@ -59,6 +58,7 @@ def run():
not item.isDtor):
c.addItem(copy.deepcopy(item))
tools.fixWindowClass(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -261,17 +261,27 @@ def fixWindowClass(klass, hideVirtuals=True, ignoreProtected=True):
removeVirtuals(klass)
addWindowVirtuals(klass)
if not klass.findItem('GetClassDefaultAttributes'):
klass.addItem(extractors.WigCode("""\
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
"""))
if not ignoreProtected:
for item in klass.allItems():
if isinstance(item, extractors.MethodDef) and item.protection == 'protected':
item.ignore(False)
fixDefaultAttributesMethods(klass)
def fixDefaultAttributesMethods(klass):
if not klass.findItem('GetClassDefaultAttributes'):
m = extractors.MethodDef(
type='wxVisualAttributes', name='GetClassDefaultAttributes',
isStatic=True, protection='public',
items=[extractors.ParamDef(
type='wxWindowVariant', name='variant', default='wxWINDOW_VARIANT_NORMAL')]
)
klass.addItem(m)
if klass.findItem('GetDefaultAttributes'):
klass.find('GetDefaultAttributes').mustHaveApp()
klass.find('GetClassDefaultAttributes').mustHaveApp()
def fixTopLevelWindowClass(klass, hideVirtuals=True, ignoreProtected=True):
@@ -308,6 +318,8 @@ def fixTopLevelWindowClass(klass, hideVirtuals=True, ignoreProtected=True):
if isinstance(item, extractors.MethodDef) and item.protection == 'protected':
item.ignore(False)
fixDefaultAttributesMethods(klass)
def fixSizerClass(klass):