diff --git a/TODO.txt b/TODO.txt index a93eb3e2..31a5ae26 100644 --- a/TODO.txt +++ b/TODO.txt @@ -131,7 +131,6 @@ other dev stuff * taskbar * print (as in print framework classes) - * filectrl * axbase (ActiveX. Need to figure out best ways to do MSW-only items...) * tipdlg * check that all items in _functions.i and _misc.i have been wrapped diff --git a/etg/_core.py b/etg/_core.py index 8d748a54..846e863a 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -154,6 +154,7 @@ INCLUDES = [ # core 'treeitemdata', 'treectrl', 'pickers', + 'filectrl', # toplevel and dialogs 'nonownedwnd', diff --git a/etg/filectrl.py b/etg/filectrl.py new file mode 100644 index 00000000..1887dc4f --- /dev/null +++ b/etg/filectrl.py @@ -0,0 +1,85 @@ +#--------------------------------------------------------------------------- +# Name: etg/filectrl.py +# Author: Robin Dunn +# +# Created: 12-Apr-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "filectrl" # 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 = [ "wxFileCtrl", + "wxFileCtrlEvent", + ] + +#--------------------------------------------------------------------------- + +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 ') + + c = module.find('wxFileCtrl') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + + module.addGlobalStr('wxFileCtrlNameStr', c) + + c.find('GetFilenames').ignore() + c.addCppMethod('wxArrayString*', 'GetFilenames', '()', doc="""\ + Returns a list of filenames selected in the control. This function + should only be used with controls which have the wx.FC_MULTIPLE style, + use GetFilename for the others.""", + body="""\ + wxArrayString* arr = new wxArrayString; + self->GetFilenames(*arr); + return arr;""", + factory=True) + + c.find('GetPaths').ignore() + c.addCppMethod('wxArrayString*', 'GetPaths', '()', doc="""\ + Returns a list of the full paths (directory and filename) of the files + chosen. This function should only be used with controlss which have + the wx.FC_MULTIPLE style, use GetPath for the others. + """, + body="""\ + wxArrayString* arr = new wxArrayString; + self->GetPaths(*arr); + return arr;""", + factory=True) + + + + c = module.find('wxFileCtrlEvent') + tools.fixEventClass(c) + c.addPyCode("""\ + EVT_FILECTRL_SELECTIONCHANGED = wx.PyEventBinder( wxEVT_FILECTRL_SELECTIONCHANGED, 1) + EVT_FILECTRL_FILEACTIVATED = wx.PyEventBinder( wxEVT_FILECTRL_FILEACTIVATED, 1) + EVT_FILECTRL_FOLDERCHANGED = wx.PyEventBinder( wxEVT_FILECTRL_FOLDERCHANGED, 1) + EVT_FILECTRL_FILTERCHANGED = wx.PyEventBinder( wxEVT_FILECTRL_FILTERCHANGED, 1) + """) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/test_filectrl.py b/unittests/test_filectrl.py new file mode 100644 index 00000000..1e33324c --- /dev/null +++ b/unittests/test_filectrl.py @@ -0,0 +1,62 @@ +import imp_unittest, unittest +import wtc +import wx +import os + +#--------------------------------------------------------------------------- + +class filectrl_Tests(wtc.WidgetTestCase): + + def test_filectrl1(self): + fc = wx.FileCtrl(self.frame) + + def test_filectrl2(self): + fc = wx.FileCtrl() + fc.Create(self.frame) + + def test_filectrl3(self): + wx.FC_OPEN + wx.FC_SAVE + wx.FC_MULTIPLE + wx.FC_NOSHOWHIDDEN + wx.FC_DEFAULT_STYLE + + wx.wxEVT_FILECTRL_SELECTIONCHANGED + wx.wxEVT_FILECTRL_FILEACTIVATED + wx.wxEVT_FILECTRL_FOLDERCHANGED + wx.wxEVT_FILECTRL_FILTERCHANGED + wx.EVT_FILECTRL_SELECTIONCHANGED + wx.EVT_FILECTRL_FILEACTIVATED + wx.EVT_FILECTRL_FOLDERCHANGED + wx.EVT_FILECTRL_FILTERCHANGED + wx.FileCtrlEvent + + + def test_filectrl4(self): + fc = wx.FileCtrl(self.frame, + defaultDirectory=os.path.dirname(__file__), + defaultFilename=os.path.basename(__file__), + style=wx.FC_OPEN) + + self.assertEqual(fc.GetFilename(), os.path.basename(__file__)) + self.assertEqual(fc.GetPath(), __file__) + self.assertEqual(fc.Filename, os.path.basename(__file__)) + self.assertEqual(fc.Path, __file__) + + + def test_filectrl5(self): + fc = wx.FileCtrl(self.frame, + defaultDirectory=os.path.dirname(__file__), + defaultFilename=os.path.basename(__file__), + style=wx.FC_OPEN|wx.FC_MULTIPLE) + + self.assertEqual(fc.GetFilenames(), [os.path.basename(__file__)]) + self.assertEqual(fc.GetPaths(), [__file__]) + self.assertEqual(fc.Filenames, [os.path.basename(__file__)]) + self.assertEqual(fc.Paths, [__file__]) + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()