Add EnableSystemTheme method to the classes which support it

This commit is contained in:
Robin Dunn
2019-06-12 13:33:26 -07:00
parent 9f6fd03601
commit 54dc9ac457
5 changed files with 42 additions and 2 deletions

View File

@@ -20,7 +20,6 @@ Starting with this release wxPython has switched to tracking the wxWidgets
master branch for the wxWidgets source code, which wxPython is built upon, and
which is included in the wxPython source archives.
New and improved in this release:
* Added wrappers for the OSXEnableAutomaticQuoteSubstitution,
@@ -49,6 +48,13 @@ Other changes in this release:
* Fixed issue in wx.lib.agw.customtreectrl where label editor could remain
stuck forever (#1235).
* Grafted on a EnableSystemTheme method to the classes which support it. This
can be used to disable the default system theme on Windows for native widgets
like wx.ListCtrl, wx.TreeCtrl and wx.dataview.DataViewCtrl. It has no effect
on the other platforms.
4.0.6 "Applesauce"
------------------

View File

@@ -374,6 +374,8 @@ def run():
tools.fixWindowClass(c)
module.addGlobalStr('wxDataViewCtrlNameStr', c)
tools.addEnableSystemTheme(c, 'wx.dataview.DataViewCtrl')
c.find('AssociateModel.model').transfer = True
c.find('AssociateModel').pyName = '_AssociateModel'
c.addPyMethod('AssociateModel', '(self, model)',

View File

@@ -62,6 +62,7 @@ def run():
c.find(name).ignore(False)
c.find(name).isVirtual = True
tools.addEnableSystemTheme(c, 'wx.ListCtrl')
# Tweaks to allow passing and using a Python callable object for the sort
# compare function. First provide a sort callback function that can call the
@@ -108,7 +109,6 @@ def run():
c.find('SetItemPtrData').ignore()
# Change the semantics of GetColumn to return the item as the return
# value instead of through a parameter.
# bool GetColumn(int col, wxListItem& item) const;

View File

@@ -80,6 +80,7 @@ def run():
tools.fixWindowClass(c)
module.addGlobalStr('wxTreeCtrlNameStr', before=c)
tools.addEnableSystemTheme(c, 'wx.TreeCtrl')
# Set all wxTreeItemData parameters to transfer ownership. Is this still needed with MappedTypes?
for item in c.allItems():

View File

@@ -16,6 +16,7 @@ import etgtools as extractors
from .generators import textfile_open
import sys, os
import copy
import textwrap
PY3 = sys.version_info[0] == 3
@@ -656,6 +657,36 @@ def checkForUnitTestModule(module):
print('WARNING: Unittest module (%s) not found!' % pathname)
def addEnableSystemTheme(klass, klassName):
m = extractors.MethodDef(name='EnableSystemTheme', type='void',
items=[extractors.ParamDef(type='bool', name='enable', default='true')])
m.briefDoc = "Can be used to disable the system theme of controls using it by default."
m.detailedDoc = [textwrap.dedent("""\
On Windows there an alternative theme available for the list and list-like
controls since Windows Vista. This theme is used by Windows Explorer list
and tree view and so is arguably more familiar to the users than the standard
appearance of these controls. This class automatically uses the new theme,
but if that is not desired then this method can be used to turn it off.
Please note that this method should be called before the widget is
actually created, using the 2-phase create pattern. Something like this::
# This creates the object, but not the window
widget = {}()
# Disable the system theme
widget.EnableSystemTheme(False)
# Now create the window
widget.Create(parent, wx.ID_ANY)
This method has no effect on other platorms
""".format(klassName))]
klass.addItem(m)
#---------------------------------------------------------------------------
def addGetIMMethodTemplate(module, klass, fields):