From 54dc9ac4578d3ebc6c618d93d9e742c73caaa052 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 12 Jun 2019 13:33:26 -0700 Subject: [PATCH] Add EnableSystemTheme method to the classes which support it --- CHANGES.rst | 8 +++++++- etg/dataview.py | 2 ++ etg/listctrl.py | 2 +- etg/treectrl.py | 1 + etgtools/tweaker_tools.py | 31 +++++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 473f3b8a..961e11f2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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" ------------------ diff --git a/etg/dataview.py b/etg/dataview.py index 50724d49..4a84ecf6 100644 --- a/etg/dataview.py +++ b/etg/dataview.py @@ -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)', diff --git a/etg/listctrl.py b/etg/listctrl.py index ab0de8d7..78accc6a 100644 --- a/etg/listctrl.py +++ b/etg/listctrl.py @@ -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; diff --git a/etg/treectrl.py b/etg/treectrl.py index 4a06f97a..98b9411c 100644 --- a/etg/treectrl.py +++ b/etg/treectrl.py @@ -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(): diff --git a/etgtools/tweaker_tools.py b/etgtools/tweaker_tools.py index 8c713b41..ab70d359 100644 --- a/etgtools/tweaker_tools.py +++ b/etgtools/tweaker_tools.py @@ -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):