Change wx.StatusBar.GetFieldRect to return the rectangle (for Pythonicity and Classic compatibility)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@76038 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2014-03-02 00:13:42 +00:00
parent cad18dd6f8
commit 726e75e766
3 changed files with 26 additions and 5 deletions

View File

@@ -75,11 +75,10 @@ class CustomStatusBar(wx.StatusBar):
# reposition the checkbox
def Reposition(self):
# sw0 = self.GetStatusWidth(0)
sw1 = self.GetStatusWidth(1)
sw2 = self.GetStatusWidth(2)
sz = self.GetSize()
self.cb.SetPosition((sz[0] - sw2 - sw1 - 25, 4))
rect = self.GetFieldRect(1)
rect.x += 1
rect.y += 1
self.cb.SetRect(rect)
self.sizeChanged = False

View File

@@ -31,6 +31,7 @@ def run():
# customizing the generated code and docstrings.
c = module.find('wxStatusBar')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)
module.addGlobalStr('wxStatusBarNameStr', c)
@@ -46,6 +47,17 @@ def run():
self->SetStatusWidths(widths->size(), ptr);
""")
# Change GetFieldRect to return the rectangle (for Pythonicity and Classic compatibility)
c.find('GetFieldRect').ignore()
c.addCppMethod('wxRect*', 'GetFieldRect', '(int i)',
doc="Returns the size and position of a field's internal bounding rectangle.",
body="""\
wxRect* r = new wxRect;
self->GetFieldRect(i, *r);
return r;
""")
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)

View File

@@ -89,6 +89,16 @@ class statusbar_Tests(wtc.WidgetTestCase):
widths = [sb.GetStatusWidth(i) for i in range(sb.GetFieldsCount())]
self.assertEqual(widths, [200, -1, 100])
def test_statusbarGetFielRect(self):
# Test that GetFieldRect has been tweaked to be compatible with Classic
sb = self.frame.CreateStatusBar(3)
self.frame.SetStatusWidths([200, -1, 100])
r = sb.GetFieldRect(1)
self.assertTrue(isinstance(r, wx.Rect))
#---------------------------------------------------------------------------