From 50a6410c87057fae3671ee8bbf02410fef51d1f8 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 9 Feb 2018 14:30:49 -0800 Subject: [PATCH] Add deprecation wrappers for methods that have vanished from wxWidgets due to the 2.8 compatibility flag being turned off. --- etg/artprov.py | 3 +++ etg/combo.py | 6 ++++++ etg/event.py | 5 ++++- etg/menu.py | 5 +++++ etg/menuitem.py | 13 +++++++++++++ etg/propgridproperty.py | 12 ++++++++++++ etg/sizer.py | 3 +++ etg/utils.py | 4 ++++ etg/vscroll.py | 20 +++++++++++--------- 9 files changed, 61 insertions(+), 10 deletions(-) diff --git a/etg/artprov.py b/etg/artprov.py index 01d31950..48017c68 100644 --- a/etg/artprov.py +++ b/etg/artprov.py @@ -49,6 +49,9 @@ def run(): c.find('GetBitmap').mustHaveApp() c.find('GetIcon').mustHaveApp() + c.find('Insert').ignore() + c.addPyCode("ArtProvider.Insert = wx.deprecated(ArtProvider.PushBack, 'Use ArtProvider.PushBack instead')") + # Change the types of the art constants from wxString to const char* # since that is what they really are. artConsts = list() diff --git a/etg/combo.py b/etg/combo.py index fec4283c..7579bd3a 100644 --- a/etg/combo.py +++ b/etg/combo.py @@ -60,6 +60,12 @@ def run(): c.find('SetSelection.from').name = 'frm' + c.find('GetTextIndent').ignore() + c.find('SetTextIndent').ignore() + c.addPyCode("ComboCtrl.GetTextIndent = wx.deprecated(ComboCtrl.GetMargins, 'Use GetMargins instead.')") + c.addPyCode("ComboCtrl.SetTextIndent = wx.deprecated(ComboCtrl.SetMargins, 'Use SetMargins instead.')") + + #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module) diff --git a/etg/event.py b/etg/event.py index e20085f4..61bb0fcc 100644 --- a/etg/event.py +++ b/etg/event.py @@ -570,7 +570,10 @@ def run(): #--------------------------------------- # wxIconizeEvent - module.find('wxIconizeEvent.Iconized').deprecated = True + c = module.find('wxIconizeEvent') + c.find('Iconized').ignore() + c.addPyCode("IconizeEvent.Iconized = wx.deprecated(IconizeEvent.IsIconized, 'Use IsIconized instead')") + # Apply common fixups for all the event classes diff --git a/etg/menu.py b/etg/menu.py index b1e87e6a..23229f65 100644 --- a/etg/menu.py +++ b/etg/menu.py @@ -170,6 +170,11 @@ def run(): c.addPyProperty('Menus GetMenus SetMenus') + c.find('GetLabelTop').ignore() + c.find('SetLabelTop').ignore() + c.addPyCode("MenuBar.GetLabelTop = wx.deprecated(MenuBar.GetMenuLabelText, 'Use GetMenuLabelText instead')") + c.addPyCode("MenuBar.SetLabelTop = wx.deprecated(ManuBar.SetMenuLabel, 'Use SetMenuLabel instead')") + module.addItem(tools.wxListWrapperTemplate('wxMenuList', 'wxMenu', module)) #----------------------------------------------------------------- diff --git a/etg/menuitem.py b/etg/menuitem.py index cda9b8df..bbe3f674 100644 --- a/etg/menuitem.py +++ b/etg/menuitem.py @@ -38,6 +38,19 @@ def run(): c.find('SetSubMenu.menu').transfer = True + c.find('GetLabel').ignore() + c.find('GetName').ignore() + c.find('GetText').ignore() + c.find('SetText').ignore() + c.find('GetLabelFromText').ignore() + + c.addPyCode("MenuItem.GetLabel = wx.deprecated(MenuItem.GetItemLabelText, 'Use GetItemLabelText instead')") + c.addPyCode("MenuItem.GetName = wx.deprecated(MenuItem.GetItemLabelText, 'Use GetItemLabelText instead')") + c.addPyCode("MenuItem.GetText = wx.deprecated(MenuItem.GetItemLabel, 'Use GetItemLabel instead')") + c.addPyCode("MenuItem.SetText = wx.deprecated(MenuItem.SetItemLabel, 'Use SetItemLabel instead')") + c.addPyCode("MenuItem.GetLabelFromText = wx.deprecated(MenuItem.GetLabelText, 'Use GetLabelText instead')") + + # These are MSW only. Make them be empty stubs for the other ports c.find('GetBackgroundColour').type = 'wxColour*' c.find('GetBackgroundColour').setCppCode("""\ diff --git a/etg/propgridproperty.py b/etg/propgridproperty.py index cf27cd50..47e4d494 100644 --- a/etg/propgridproperty.py +++ b/etg/propgridproperty.py @@ -117,16 +117,28 @@ def run(): c.find('GetEditorDialog').factory = True + c.find('AddChild').ignore() + c.find('GetValueString').ignore() + c.addPyCode("PGProperty.AddChild = wx.deprecated(PGProperty.AddPrivateChild, 'Use AddPrivateChild instead')") + c.addPyCode("PGProperty.GetValueString = wx.deprecated(PGProperty.GetValueAsString, 'Use GetValueAsString instead')") + + + #--------------------------------------------------------- c = module.find('wxPGChoicesData') tools.ignoreConstOverloads(c) c.bases = ['wxRefCounter'] c.find('~wxPGChoicesData').ignore(False) + #--------------------------------------------------------- c = module.find('wxPGChoices') c.find('wxPGChoices').findOverload('wxChar **').ignore() tools.ignoreConstOverloads(c) c.find('operator[]').ignore() + c.find('GetId').type = 'wxIntPtr' + c.find('GetId').setCppCode_sip("""\ + sipRes = new ::wxIntPtr((wxIntPtr)sipCpp->GetId()); + """) c.addPyMethod('__getitem__', '(self, index)', doc="Returns a reference to a :class:PGChoiceEntry using Python list syntax.", diff --git a/etg/sizer.py b/etg/sizer.py index a5533eab..3bee2a4b 100644 --- a/etg/sizer.py +++ b/etg/sizer.py @@ -94,6 +94,9 @@ def run(): # Needs wxWin 2.6 compatibility c.find('Remove').findOverload('(wxWindow *window)').ignore() + c.find('SetVirtualSizeHints').ignore() + c.addPyCode("Sizer.SetVirtualSizeHints = wx.deprecated(Sizer.FitInside, 'Use FitInside instead')") + c.addPyMethod('AddMany', '(self, items)', doc="""\ :meth:`AddMany` is a convenience method for adding several items to a sizer diff --git a/etg/utils.py b/etg/utils.py index daff771e..db258a1b 100644 --- a/etg/utils.py +++ b/etg/utils.py @@ -63,6 +63,10 @@ def run(): module.find('wxSetDisplayName').ignore() module.find('wxPostDelete').ignore() + module.find('wxUsleep').ignore() + module.addPyCode("Usleep = deprecated(MilliSleep, 'Use MilliSleep instead.')") + + # ignore all the environment related functions for item in module.allItems(): if 'Env' in item.name: diff --git a/etg/vscroll.py b/etg/vscroll.py index ac842470..a458f521 100644 --- a/etg/vscroll.py +++ b/etg/vscroll.py @@ -119,47 +119,49 @@ def run(): c.addCppMethod('unsigned long', 'GetFirstVisibleLine', '()', doc="Deprecated compatibility helper.", deprecated='Use GetVisibleRowsBegin instead.', - body="return self->GetFirstVisibleLine();") + body="return self->GetVisibleRowsBegin();") c.addCppMethod('unsigned long', 'GetLastVisibleLine', '()', doc="Deprecated compatibility helper.", deprecated='Use GetVisibleRowsEnd instead.', - body="return self->GetLastVisibleLine();") + body="return self->GetVisibleRowsEnd();") c.addCppMethod('unsigned long', 'GetLineCount', '()', doc="Deprecated compatibility helper.", deprecated='Use GetRowCount instead.', - body="return self->GetLineCount();") + body="return self->GetRowCount();") c.addCppMethod('void', 'SetLineCount', '(unsigned long count)', doc="Deprecated compatibility helper.", deprecated='Use SetRowCount instead.', - body="self->SetLineCount(count);") + body="self->SetRowCount(count);") c.addCppMethod('void', 'RefreshLine', '(unsigned long line)', doc="Deprecated compatibility helper.", deprecated='Use RefreshRow instead.', - body="self->RefreshLine(line);") + body="self->RefreshRow(line);") c.addCppMethod('void', 'RefreshLines', '(unsigned long from_, unsigned long to_)', doc="Deprecated compatibility helper.", deprecated='Use RefreshRows instead.', - body="self->RefreshLines(from_, to_);") + body="self->RefreshRows(from_, to_);") c.addCppMethod('bool', 'ScrollToLine', '(unsigned long line)', doc="Deprecated compatibility helper.", deprecated='Use ScrollToRow instead.', - body="return self->ScrollToLine(line);") + body="return self->ScrollToRow(line);") c.addCppMethod('bool', 'ScrollLines', '(int lines)', doc="Deprecated compatibility helper.", deprecated='Use ScrollRows instead.', - body="return self->wxVarVScrollLegacyAdaptor::ScrollLines(lines);") + #body="return self->wxVarVScrollLegacyAdaptor::ScrollLines(lines);") + body="return self->ScrollRows(lines);") c.addCppMethod('bool', 'ScrollPages', '(int pages)', doc="Deprecated compatibility helper.", deprecated='Use ScrollRowPages instead.', - body="return self->wxVarVScrollLegacyAdaptor::ScrollPages(pages);") + #body="return self->wxVarVScrollLegacyAdaptor::ScrollPages(pages);") + body="return self->ScrollRowPages(pages);")