mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-08 04:50:07 +01:00
Just make wx.SearchCtrl look like it derives directly from wx.Control, and then add declarations for all the TextCtrl and TextEntry methods to it and let C++ sort it all out properly.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73618 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -35,7 +35,6 @@ def run():
|
||||
|
||||
c = module.find('wxSearchCtrl')
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
|
||||
module.addGlobalStr('wxSearchCtrlNameStr', c)
|
||||
|
||||
c.find('SetMenu.menu').transfer = True
|
||||
@@ -62,14 +61,49 @@ def run():
|
||||
#endif
|
||||
""")
|
||||
|
||||
# Not using autoProperties here because some getters use 'Is'
|
||||
c.addProperty('Menu GetMenu SetMenu')
|
||||
c.addProperty('SearchButtonVisible IsSearchButtonVisible ShowSearchButton')
|
||||
c.addProperty('CancelButtonVisible IsCancelButtonVisible ShowCancelButton')
|
||||
c.addProperty('DescriptiveText GetDescriptiveText SetDescriptiveText')
|
||||
|
||||
tools.fixWindowClass(c)
|
||||
searchCtrl = c
|
||||
|
||||
|
||||
# The safest way to reconcile the differences in the class hierachy
|
||||
# between the native wxSearchCtrl on Mac and the generic one on the other
|
||||
# platforms is to just say that this class derives directly from
|
||||
# wxControl (the first common ancestor) instead of wxTextCtrl, and then
|
||||
# redeclare all the wxTextEntry and/or wxTextCtrlIface methods that we
|
||||
# are interested in having here. That way the C++ compiler can sort out
|
||||
# the proper way to call those methods and avoid calling the wrong
|
||||
# implementations like would happen if try to force it another way...
|
||||
searchCtrl.bases = ['wxControl']
|
||||
|
||||
# Instead of duplicating those declarations here, let's use the parser
|
||||
# and tweakers we already have and then just transplant those MethodDefs
|
||||
# into this ClassDef. That will then preserve things like the
|
||||
# documentation and custom tweaks that would be real tedious to duplicate
|
||||
# and maintain.
|
||||
import textentry
|
||||
mod = textentry.parseAndTweakModule()
|
||||
klass = mod.find('wxTextEntry')
|
||||
searchCtrl.items.extend(klass.items)
|
||||
|
||||
# Do the same with wxTextCtrl, but also remove things like the
|
||||
# Constructors and Create methods first.
|
||||
import textctrl
|
||||
mod = textctrl.parseAndTweakModule()
|
||||
klass = mod.find('wxTextCtrl')
|
||||
# get just the methods that are not ctors, dtor or Create
|
||||
items = [item for item in klass.items if isinstance(item, etgtools.MethodDef) and
|
||||
not item.isCtor and
|
||||
not item.isDtor and
|
||||
item.name != 'Create']
|
||||
searchCtrl.items.extend(items)
|
||||
|
||||
|
||||
|
||||
# Add some properties that autoProperties would not see because they are
|
||||
# not using 'Get' and 'Set'
|
||||
searchCtrl.addProperty('SearchButtonVisible IsSearchButtonVisible ShowSearchButton')
|
||||
searchCtrl.addProperty('CancelButtonVisible IsCancelButtonVisible ShowCancelButton')
|
||||
searchCtrl.addAutoProperties()
|
||||
tools.fixWindowClass(searchCtrl)
|
||||
|
||||
module.addPyCode("""\
|
||||
EVT_SEARCHCTRL_CANCEL_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1)
|
||||
|
||||
@@ -22,7 +22,7 @@ ITEMS = [ 'wxTextAttr', 'wxTextCtrl', ]
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def run():
|
||||
def parseAndTweakModule():
|
||||
# Parse the XML file(s) building a collection of Extractor objects
|
||||
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
|
||||
etgtools.parseDoxyXML(module, ITEMS)
|
||||
@@ -34,9 +34,9 @@ def run():
|
||||
c = module.find('wxTextAttr')
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
c.find('operator=').ignore()
|
||||
|
||||
c.find('SetFont').pyArgsString = '(font, flags=TEXT_ATTR_FONT & ~TEXT_ATTR_FONT_PIXEL_SIZE)'
|
||||
|
||||
|
||||
c = module.find('wxTextCtrl')
|
||||
module.addGlobalStr('wxTextCtrlNameStr', c)
|
||||
|
||||
@@ -58,9 +58,15 @@ def run():
|
||||
for op in c.findAll('operator<<'):
|
||||
op.ignore()
|
||||
|
||||
c.find('OnDropFiles').ignore()
|
||||
|
||||
tools.fixWindowClass(c)
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
return module
|
||||
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
def run():
|
||||
module = parseAndTweakModule()
|
||||
tools.doCommonTweaks(module)
|
||||
tools.runGenerators(module)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ ITEMS = [ "wxTextEntry", ]
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def run():
|
||||
def parseAndTweakModule():
|
||||
# Parse the XML file(s) building a collection of Extractor objects
|
||||
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING, False)
|
||||
etgtools.parseDoxyXML(module, ITEMS)
|
||||
@@ -45,9 +45,12 @@ def run():
|
||||
c.find('Replace.to').name = 'to_'
|
||||
c.find('SetSelection.from').name = 'from_'
|
||||
c.find('SetSelection.to').name = 'to_'
|
||||
|
||||
return module
|
||||
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
#-----------------------------------------------------------------
|
||||
def run():
|
||||
module = parseAndTweakModule()
|
||||
tools.doCommonTweaks(module)
|
||||
tools.runGenerators(module)
|
||||
|
||||
|
||||
@@ -36,6 +36,29 @@ class srchctrl_Tests(wtc.WidgetTestCase):
|
||||
t.SetValue('Hello')
|
||||
self.assertEqual(t.GetValue(), 'Hello')
|
||||
self.assertEqual(t.Value, 'Hello')
|
||||
|
||||
|
||||
def test_srchctrlHasTextCtrlMethods(self):
|
||||
# Just ensure that the common TextCtrl methods are present. This is
|
||||
# done because although the C++ class either derives from wxTextCtrl
|
||||
# or from wxTextCtrlIface, we have to kludge it up a bit since the
|
||||
# actual class hierarchies are different between platforms. See
|
||||
# etg/srchctrl.py for details.
|
||||
|
||||
t = wx.SearchCtrl(self.frame)
|
||||
t.Cut
|
||||
t.CanCut
|
||||
t.DiscardEdits
|
||||
t.GetDefaultStyle
|
||||
t.GetNumberOfLines
|
||||
t.GetStyle
|
||||
t.IsModified
|
||||
t.HitTest
|
||||
t.AppendText
|
||||
t.WriteText
|
||||
t.ChangeValue
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user