mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 01:30:07 +01:00
Reorder the SetPropertyValue overloads and constrain the bool and double overloads.
This avoids choosing the int overload for anything that can be implicitly converted to an integer.
This commit is contained in:
@@ -110,11 +110,24 @@ def run():
|
||||
if m.type == 'wxPropertyGridConstIterator':
|
||||
m.ignore()
|
||||
|
||||
c.find('SetPropertyValue').findOverload('int value').ignore()
|
||||
c.find('SetPropertyValue').findOverload('bool value').ignore()
|
||||
c.find('SetPropertyValue').findOverload('wxLongLong_t value').ignore()
|
||||
c.find('SetPropertyValue').findOverload('wxULongLong_t value').ignore()
|
||||
c.find('SetPropertyValue').findOverload('wxObject *value').ignore()
|
||||
spv = c.find('SetPropertyValue')
|
||||
spv.findOverload('int value').ignore()
|
||||
spv.findOverload('wxLongLong_t value').ignore()
|
||||
spv.findOverload('wxULongLong_t value').ignore()
|
||||
spv.findOverload('wxObject *value').ignore()
|
||||
|
||||
# Reorder SetPropertyValue overloads so the one taking a long int is not
|
||||
# first. Mark others that could be auto-converted from int as
|
||||
# "constrained" so they will only be used for that specific type. This
|
||||
# should result in SetPropertyValue(id, double) only used for floats and
|
||||
# not ints, opr other things that can convert to int.
|
||||
spv.findOverload('bool value').find('value').constrained = True
|
||||
spv.findOverload('double value').find('value').constrained = True
|
||||
spv_long = spv.findOverload('long value')
|
||||
spv_long.ignore()
|
||||
spv.reorderOverloads() # Ensures an ignored item is not first,
|
||||
spv_long.ignore(False) # and then we can unignore it.
|
||||
|
||||
|
||||
c.find('Append.property').transfer = True
|
||||
c.find('AppendIn.newProperty').transfer = True
|
||||
|
||||
@@ -16,6 +16,19 @@ class propgridiface_Tests(wtc.WidgetTestCase):
|
||||
iface = pg.PropertyGridInterface()
|
||||
|
||||
|
||||
def test_propgridiface03(self):
|
||||
# Ensure SetPropertyValue doesn't truncate floats
|
||||
pgrid = pg.PropertyGrid(self.frame)
|
||||
pgrid.Append(pg.FloatProperty('Float', value=123.456))
|
||||
|
||||
value = pgrid.GetPropertyValue('Float')
|
||||
assert type(value) is float
|
||||
assert value == 123.456
|
||||
|
||||
pgrid.SetPropertyValue('Float', 654.321)
|
||||
value = pgrid.GetPropertyValue('Float')
|
||||
assert type(value) is float
|
||||
assert value == 654.321
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user