1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
#---------------------------------------------------------------------------
# Name: etg/srchctrl.py
# Author: Kevin Ollivier
# Robin Dunn
#
# Created: 9-Sept-2011
# Copyright: (c) 2011 by Kevin Ollivier
# Copyright: (c) 2011-2020 by Total Control Software
# License: wxWindows License
#---------------------------------------------------------------------------
import etgtools
import etgtools.tweaker_tools as tools
PACKAGE = "wx"
MODULE = "_core"
NAME = "srchctrl" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxSearchCtrl' ]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
module.addHeaderCode('#include <wx/srchctrl.h>')
c = module.find('wxSearchCtrl')
assert isinstance(c, etgtools.ClassDef)
module.addGlobalStr('wxSearchCtrlNameStr', c)
c.find('SetMenu.menu').transfer = True
c.addCppMethod('void', 'SetSearchBitmap', '(const wxBitmap* bmp)',
"""\
#if wxUSE_NATIVE_SEARCH_CONTROL
#else
self->SetSearchBitmap(*bmp);
#endif
""")
c.addCppMethod('void', 'SetSearchMenuBitmap', '(const wxBitmap* bmp)',
"""\
#if wxUSE_NATIVE_SEARCH_CONTROL
#else
self->SetSearchMenuBitmap(*bmp);
#endif
""")
c.addCppMethod('void', 'SetCancelBitmap', '(const wxBitmap* bmp)',
"""\
#if wxUSE_NATIVE_SEARCH_CONTROL
#else
self->SetCancelBitmap(*bmp);
#endif
""")
searchCtrl = c
# The safest way to reconcile the differences in the class hierarchy
# 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)
# 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_SEARCH_CANCEL = wx.PyEventBinder( wxEVT_SEARCH_CANCEL, 1)
EVT_SEARCH = wx.PyEventBinder( wxEVT_SEARCH, 1)
# deprecated wxEVT aliases
wxEVT_SEARCHCTRL_CANCEL_BTN = wxEVT_SEARCH_CANCEL
wxEVT_SEARCHCTRL_SEARCH_BTN = wxEVT_SEARCH
wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN = wxEVT_SEARCHCTRL_CANCEL_BTN
wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN = wxEVT_SEARCHCTRL_SEARCH_BTN
EVT_SEARCHCTRL_CANCEL_BTN = wx.PyEventBinder( wxEVT_SEARCHCTRL_CANCEL_BTN, 1)
EVT_SEARCHCTRL_SEARCH_BTN = wx.PyEventBinder( wxEVT_SEARCHCTRL_SEARCH_BTN, 1)
""")
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()
|