From bdc847d0f0454e2a6b2721dfd57a38a47977d535 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 30 Nov 2012 22:29:48 +0000 Subject: [PATCH] Fix both cases of SetStatusWidths to just use a wxArrayInt mapped type instead of a plain C array and size. Add unit tests for it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73073 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/frame.py | 13 +++++++++++-- etg/statusbar.py | 13 +++++++++++-- unittests/test_statusbar.py | 23 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/etg/frame.py b/etg/frame.py index 1435b6ef..d1d218ff 100644 --- a/etg/frame.py +++ b/etg/frame.py @@ -38,8 +38,17 @@ def run(): c.find('SetMenuBar.menuBar').transfer = True - c.find('SetStatusWidths.n').arraySize = True - c.find('SetStatusWidths.widths_field').array = True + # We already have a MappedType for wxArrayInt, so just tweak the + # interface to use that instead of an array size and a const int pointer. + m = c.find('SetStatusWidths') + m.find('n').ignore() + m.find('widths_field').type = 'const wxArrayInt&' + m.find('widths_field').name = 'widths' + m.argsString = '(int n, const wxArrayInt& widths)' + m.setCppCode("""\ + const int* ptr = &widths->front(); + self->SetStatusWidths(widths->size(), ptr); + """) c.addProperty('MenuBar GetMenuBar SetMenuBar') c.addProperty('StatusBar GetStatusBar SetStatusBar') diff --git a/etg/statusbar.py b/etg/statusbar.py index 514a78f7..c841f3d3 100644 --- a/etg/statusbar.py +++ b/etg/statusbar.py @@ -34,8 +34,17 @@ def run(): tools.fixWindowClass(c) module.addGlobalStr('wxStatusBarNameStr', c) - c.find('SetStatusWidths.n').arraySize = True - c.find('SetStatusWidths.widths_field').array = True + # We already have a MappedType for wxArrayInt, so just tweak the + # interface to use that instead of an array size and a const int pointer. + m = c.find('SetStatusWidths') + m.find('n').ignore() + m.find('widths_field').type = 'const wxArrayInt&' + m.find('widths_field').name = 'widths' + m.argsString = '(int n, const wxArrayInt& widths)' + m.setCppCode("""\ + const int* ptr = &widths->front(); + self->SetStatusWidths(widths->size(), ptr); + """) #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/unittests/test_statusbar.py b/unittests/test_statusbar.py index 2360f261..591f5464 100644 --- a/unittests/test_statusbar.py +++ b/unittests/test_statusbar.py @@ -66,6 +66,29 @@ class statusbar_Tests(wtc.WidgetTestCase): pane.Text + def test_statusbarWidths1(self): + sb = wx.StatusBar(self.frame) + sb.SetFieldsCount(3) + sb.SetStatusWidths([200, -1, 100]) + self.frame.SetStatusBar(sb) + + self.frame.SendSizeEvent() + self.myYield() + + widths = [sb.GetStatusWidth(i) for i in range(sb.GetFieldsCount())] + self.assertEqual(widths, [200, -1, 100]) + + + def test_statusbarWidths2(self): + sb = self.frame.CreateStatusBar(3) + self.frame.SetStatusWidths([200, -1, 100]) + + self.frame.SendSizeEvent() + self.myYield() + + widths = [sb.GetStatusWidth(i) for i in range(sb.GetFieldsCount())] + self.assertEqual(widths, [200, -1, 100]) + #---------------------------------------------------------------------------