From a1d0be9044c9fd4b7dd8188932c41b6c28cf014e Mon Sep 17 00:00:00 2001 From: DietmarSchwertberger Date: Sun, 6 Dec 2015 21:27:59 +0100 Subject: [PATCH 1/4] Add MediaCtrl. --- etg/_media.py | 76 ++++++++++++++++++++++++++++++++++++++ etg/mediactrl.py | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 etg/_media.py create mode 100644 etg/mediactrl.py diff --git a/etg/_media.py b/etg/_media.py new file mode 100644 index 00000000..b79fff0e --- /dev/null +++ b/etg/_media.py @@ -0,0 +1,76 @@ +#--------------------------------------------------------------------------- +# Name: etg/_media.py +# Author: Dietmar Schwertberger +# +# Created: 13-Nov-2015 +# Copyright: (c) 2015 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + + +import etgtools +import etgtools.tweaker_tools as tools +from etgtools import PyFunctionDef, PyCodeDef, PyPropertyDef + +PACKAGE = "wx" +MODULE = "_media" +NAME = "_media" # 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 = [ ] + + + +# The list of other ETG scripts and back-end generator modules that are +# included as part of this module. These items are in their own etg scripts +# for easier maintainability, but their class and function definitions are +# intended to be part of this module, not their own module. This also makes it +# easier to promote one of these to module status later if desired, simply +# remove it from this list of Includes, and change the MODULE value in the +# promoted script to be the same as its NAME. + +INCLUDES = [ 'mediactrl', + #'mediaevent' + ] + + +# Separate the list into those that are generated from ETG scripts and the +# rest. These lists can be used from the build scripts to get a list of +# sources and/or additional dependencies when building this extension module. +ETGFILES = ['etg/%s.py' % NAME] + tools.getEtgFiles(INCLUDES) +DEPENDS = tools.getNonEtgFiles(INCLUDES) +OTHERDEPS = [ ] + + +#--------------------------------------------------------------------------- + +def run(): + # Parse the XML file(s) building a collection of Extractor objects + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) + etgtools.parseDoxyXML(module, ITEMS) + module.check4unittest = False + + #----------------------------------------------------------------- + # Tweak the parsed meta objects in the module object as needed for + # customizing the generated code and docstrings. + + module.addHeaderCode('#include ') + module.addImport('_core') + module.addPyCode('import wx', order=10) + module.addInclude(INCLUDES) + + + #----------------------------------------------------------------- + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + run() diff --git a/etg/mediactrl.py b/etg/mediactrl.py new file mode 100644 index 00000000..d8862fac --- /dev/null +++ b/etg/mediactrl.py @@ -0,0 +1,95 @@ +#--------------------------------------------------------------------------- +# Name: etg/metafile.py +# Author: Robin Dunn +# Dietmar Schwertberger +# +# Created: 24-Nov-2015 +# Copyright: (c) 2015 by Wide Open Technologies +# License: wxWindows License +#--------------------------------------------------------------------------- + +import sys +sys.path.insert(0, r"C:\Program Files (x86)\Wing IDE 5.1" ) +import wingdbstub + + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_media" +NAME = "mediactrl" # 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 = [ 'wxMediaCtrl', + 'wxMediaEvent'] + + +#--------------------------------------------------------------------------- + +def run(): + # Parse the XML file(s) building a collection of Extractor objects + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) + etgtools.parseDoxyXML(module, ITEMS) + module.addHeaderCode('#include "wx/mediactrl.h"') + #module.addHeaderCode('#include "wx/mediaevent.h"') + + #----------------------------------------------------------------- + # Tweak the parsed meta objects in the module object as needed for + # customizing the generated code and docstrings. + + c = module.find('wxMediaCtrl') + c.addPrivateCopyCtor() + + # the C++ class has three overloaded Load(...) methods + # for now we ignore all than the first one for loading a filename + for item in c.findAll("Load"): + if not "fileName" in item.argsString: + # ignore e.g. the Load with args '(const wxURI &uri)' + # keep e.g. '(const wxString &fileName)' + item.ignore() + + + # this is from old SWIG, do we still need it? + #%pythoncode { LoadFromURI = LoadURI } + + + c = module.find('wxMediaEvent') + tools.fixEventClass(c) + + c.addPyCode("""\ + EVT_MEDIA_LOADED = wx.PyEventBinder( wxEVT_MEDIA_LOADED ) + EVT_MEDIA_STOP = wx.PyEventBinder( wxEVT_MEDIA_STOP ) + EVT_MEDIA_FINISHED = wx.PyEventBinder( wxEVT_MEDIA_FINISHED ) + EVT_MEDIA_STATECHANGED = wx.PyEventBinder( wxEVT_MEDIA_STATECHANGED ) + EVT_MEDIA_PLAY = wx.PyEventBinder( wxEVT_MEDIA_PLAY ) + EVT_MEDIA_PAUSE = wx.PyEventBinder( wxEVT_MEDIA_PAUSE ) + """) + # do we need such as well? + # # The same as above but with the ability to specify an identifier + # EVT_GRID_CMD_CELL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_CLICK, 1 ) + + + # the following is in mediactrl.h: + # #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend") + # not sure whether there would be a better way than just defining these strings here: + module.addPyCode("""\ + MEDIABACKEND_DIRECTSHOW = "wxAMMediaBackend" + MEDIABACKEND_MCI = "wxMCIMediaBackend" + MEDIABACKEND_QUICKTIME = "wxQTMediaBackend" + MEDIABACKEND_GSTREAMER = "wxGStreamerMediaBackend" + MEDIABACKEND_REALPLAYER = "wxRealPlayerMediaBackend" + MEDIABACKEND_WMP10 = "wxWMP10MediaBackend" + """) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + From c5952165cb0d9d6ddf5acbc555d44b70563d76ac Mon Sep 17 00:00:00 2001 From: DietmarSchwertberger Date: Sun, 6 Dec 2015 21:30:31 +0100 Subject: [PATCH 2/4] add _media module with MediaCtrl --- wscript | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wscript b/wscript index 83aba8a4..e242bfee 100644 --- a/wscript +++ b/wscript @@ -134,6 +134,10 @@ def configure(conf): _copyEnvGroup(conf.env, '_WX', '_WXRICHTEXT') conf.env.LIB_WXRICHTEXT += cfg.makeLibName('richtext') + _copyEnvGroup(conf.env, '_WX', '_WXMEDIA') + conf.env.LIB_WXMEDIA += cfg.makeLibName('media') + + # ** Add code for new modules here (and below for non-MSW) # tweak the PYEXT compile and link flags if making a --debug build @@ -561,6 +565,14 @@ def build(bld): ) makeExtCopyRule(bld, '_richtext') + etg = loadETG('etg/_media.py') + bld(features = 'c cxx cxxshlib pyext', + target = makeTargetName(bld, '_media'), + source = getEtgSipCppFiles(etg) + rc, + uselib = 'WX WXPY WXMEDIA', + ) + makeExtCopyRule(bld, '_media') + # ** Add code for new modules here From 34fb823cd40e460d48278af8d588e0ec89feecb2 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 27 Feb 2016 23:51:16 -0800 Subject: [PATCH 3/4] Add unit tests for MediaCtrl and MediaEvent. --- unittests/test_mediactrl.py | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 unittests/test_mediactrl.py diff --git a/unittests/test_mediactrl.py b/unittests/test_mediactrl.py new file mode 100644 index 00000000..be371aac --- /dev/null +++ b/unittests/test_mediactrl.py @@ -0,0 +1,55 @@ +import imp_unittest, unittest +import wtc +import wx +import wx.media + +#--------------------------------------------------------------------------- + +class mediactrl_Tests(wtc.WidgetTestCase): + + def test_mediactrl1(self): + wx.media.MEDIASTATE_STOPPED + wx.media.MEDIASTATE_PAUSED + wx.media.MEDIASTATE_PLAYING + wx.media.MEDIACTRLPLAYERCONTROLS_NONE + wx.media.MEDIACTRLPLAYERCONTROLS_STEP + wx.media.MEDIACTRLPLAYERCONTROLS_VOLUME + wx.media.MEDIACTRLPLAYERCONTROLS_DEFAULT + + wx.media.MEDIABACKEND_DIRECTSHOW + wx.media.MEDIABACKEND_MCI + wx.media.MEDIABACKEND_QUICKTIME + wx.media.MEDIABACKEND_GSTREAMER + wx.media.MEDIABACKEND_REALPLAYER + wx.media.MEDIABACKEND_WMP10 + + def test_mediactrl2(self): + mc = wx.media.MediaCtrl() + mc.Create(self.frame) + + def test_mediactrl3(self): + mc = wx.media.MediaCtrl(self.frame) + + + def test_mediactrl4(self): + evt = wx.media.MediaEvent() + + def test_mediactrl5(self): + wx.media.wxEVT_MEDIA_LOADED + wx.media.wxEVT_MEDIA_STOP + wx.media.wxEVT_MEDIA_FINISHED + wx.media.wxEVT_MEDIA_STATECHANGED + wx.media.wxEVT_MEDIA_PLAY + wx.media.wxEVT_MEDIA_PAUSE + + wx.media.EVT_MEDIA_LOADED + wx.media.EVT_MEDIA_STOP + wx.media.EVT_MEDIA_FINISHED + wx.media.EVT_MEDIA_STATECHANGED + wx.media.EVT_MEDIA_PLAY + wx.media.EVT_MEDIA_PAUSE + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main() From 1d5576d79451444aee620c8b158cfa6d3e8bc9ba Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 27 Feb 2016 23:52:50 -0800 Subject: [PATCH 4/4] MediaCtrl tweaks and cleanup. Update wxWidgets tag --- etg/_media.py | 1 - etg/mediactrl.py | 18 ++++-------------- ext/wxWidgets | 2 +- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/etg/_media.py b/etg/_media.py index b79fff0e..fa99aa57 100644 --- a/etg/_media.py +++ b/etg/_media.py @@ -32,7 +32,6 @@ ITEMS = [ ] # promoted script to be the same as its NAME. INCLUDES = [ 'mediactrl', - #'mediaevent' ] diff --git a/etg/mediactrl.py b/etg/mediactrl.py index d8862fac..7a23f762 100644 --- a/etg/mediactrl.py +++ b/etg/mediactrl.py @@ -8,10 +8,6 @@ # License: wxWindows License #--------------------------------------------------------------------------- -import sys -sys.path.insert(0, r"C:\Program Files (x86)\Wing IDE 5.1" ) -import wingdbstub - import etgtools import etgtools.tweaker_tools as tools @@ -34,7 +30,6 @@ def run(): module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) etgtools.parseDoxyXML(module, ITEMS) module.addHeaderCode('#include "wx/mediactrl.h"') - #module.addHeaderCode('#include "wx/mediaevent.h"') #----------------------------------------------------------------- # Tweak the parsed meta objects in the module object as needed for @@ -43,6 +38,9 @@ def run(): c = module.find('wxMediaCtrl') c.addPrivateCopyCtor() + c.find('wxMediaCtrl.id').default = '-1' + c.find('Create.id').default = '-1' + # the C++ class has three overloaded Load(...) methods # for now we ignore all than the first one for loading a filename for item in c.findAll("Load"): @@ -52,9 +50,6 @@ def run(): item.ignore() - # this is from old SWIG, do we still need it? - #%pythoncode { LoadFromURI = LoadURI } - c = module.find('wxMediaEvent') tools.fixEventClass(c) @@ -67,14 +62,9 @@ def run(): EVT_MEDIA_PLAY = wx.PyEventBinder( wxEVT_MEDIA_PLAY ) EVT_MEDIA_PAUSE = wx.PyEventBinder( wxEVT_MEDIA_PAUSE ) """) - # do we need such as well? - # # The same as above but with the ability to specify an identifier - # EVT_GRID_CMD_CELL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_CLICK, 1 ) - # the following is in mediactrl.h: - # #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend") - # not sure whether there would be a better way than just defining these strings here: + # See mediactrl.h: module.addPyCode("""\ MEDIABACKEND_DIRECTSHOW = "wxAMMediaBackend" MEDIABACKEND_MCI = "wxMCIMediaBackend" diff --git a/ext/wxWidgets b/ext/wxWidgets index 3d7d7aae..b010793e 160000 --- a/ext/wxWidgets +++ b/ext/wxWidgets @@ -1 +1 @@ -Subproject commit 3d7d7aaea6b4078abdffbd72e74cdfab7b438856 +Subproject commit b010793ea84807697f270a3feddc4da78aa5cb0f