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
This commit is contained in:
Robin Dunn
2012-11-30 22:29:48 +00:00
parent a33098471a
commit bdc847d0f0
3 changed files with 45 additions and 4 deletions

View File

@@ -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')

View File

@@ -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)

View File

@@ -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])
#---------------------------------------------------------------------------