mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 11:30:06 +01:00
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:
13
etg/frame.py
13
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')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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])
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user