diff --git a/TODO.txt b/TODO.txt index 625477f4..75f6f3ba 100644 --- a/TODO.txt +++ b/TODO.txt @@ -127,7 +127,6 @@ other dev stuff * axbase (ActiveX. Need to figure out best ways to do MSW-only items...) * check that all items in _functions.i and _misc.i have been wrapped * joystick - * power * overlay * PseudoDC diff --git a/etg/_core.py b/etg/_core.py index bb646bcb..6e910874 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -178,6 +178,7 @@ INCLUDES = [ # core 'mdi', # misc + 'power', 'utils', 'process', 'uiaction', diff --git a/etg/power.py b/etg/power.py new file mode 100644 index 00000000..a6efaacd --- /dev/null +++ b/etg/power.py @@ -0,0 +1,79 @@ +#--------------------------------------------------------------------------- +# Name: etg/power.py +# Author: Robin Dunn +# +# Created: 18-May-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "power" # 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 = [ "wxPowerEvent", + ] + +#--------------------------------------------------------------------------- + +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 ') + + module.addHeaderCode("""\ + #ifndef wxHAS_POWER_EVENTS + // Dummy class and other definitions for platforms that don't have power events + + class wxPowerEvent : public wxEvent + { + public: + wxPowerEvent() {} + wxPowerEvent(wxEventType evtType) : wxEvent(wxID_NONE, evtType) {} + void Veto() {} + bool IsVetoed() const { return false; } + virtual wxEvent *Clone() const { return new wxPowerEvent(*this); } + }; + + enum { + wxEVT_POWER_SUSPENDING, + wxEVT_POWER_SUSPENDED, + wxEVT_POWER_SUSPEND_CANCEL, + wxEVT_POWER_RESUME, + }; + #endif + """) + + + c = module.find('wxPowerEvent') + assert isinstance(c, etgtools.ClassDef) + tools.fixEventClass(c) + + c.addPyCode("""\ + EVT_POWER_SUSPENDING = wx.PyEventBinder( wxEVT_POWER_SUSPENDING , 1 ) + EVT_POWER_SUSPENDED = wx.PyEventBinder( wxEVT_POWER_SUSPENDED , 1 ) + EVT_POWER_SUSPEND_CANCEL = wx.PyEventBinder( wxEVT_POWER_SUSPEND_CANCEL , 1 ) + EVT_POWER_RESUME = wx.PyEventBinder( wxEVT_POWER_RESUME , 1 ) + """) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/utils.py b/etg/utils.py index 511a819b..3d882f48 100644 --- a/etg/utils.py +++ b/etg/utils.py @@ -18,7 +18,6 @@ DOCSTRING = "" # The classes and/or the basename of the Doxygen XML files to be processed by # this script. ITEMS = [ 'utils_8h.xml', - 'power_8h.xml', 'wxWindowDisabler', 'wxBusyCursor', 'wxVersionInfo', diff --git a/unittests/test_power.py b/unittests/test_power.py new file mode 100644 index 00000000..c3509e5c --- /dev/null +++ b/unittests/test_power.py @@ -0,0 +1,37 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class power_Tests(wtc.WidgetTestCase): + + def test_power1(self): + wx.POWER_SOCKET + wx.POWER_BATTERY + wx.POWER_UNKNOWN + + wx.BATTERY_NORMAL_STATE + wx.BATTERY_LOW_STATE + wx.BATTERY_CRITICAL_STATE + wx.BATTERY_SHUTDOWN_STATE + wx.BATTERY_UNKNOWN_STATE + + wx.wxEVT_POWER_SUSPENDING + wx.wxEVT_POWER_SUSPENDED + wx.wxEVT_POWER_SUSPEND_CANCEL + wx.wxEVT_POWER_RESUME + + wx.EVT_POWER_SUSPENDING + wx.EVT_POWER_SUSPENDED + wx.EVT_POWER_SUSPEND_CANCEL + wx.EVT_POWER_RESUME + + wx.PowerEvent + + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()