From 7944d9464f95b07ac372034e08a3e81a4329f17b Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 17 Nov 2011 03:29:37 +0000 Subject: [PATCH] Add wxIcon, wxIconBundle, wxIconLocation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69777 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/_core.py | 1 + etg/icon.py | 69 +++++++++++++++++++++++++++++++++++ etg/iconbndl.py | 45 +++++++++++++++++++++++ etg/iconloc.py | 72 +++++++++++++++++++++++++++++++++++++ unittests/mondrian.ico | Bin 0 -> 766 bytes unittests/test_icon.py | 37 +++++++++++++++++++ unittests/test_iconbndl.py | 40 +++++++++++++++++++++ unittests/test_iconloc.py | 26 ++++++++++++++ 8 files changed, 290 insertions(+) create mode 100644 etg/icon.py create mode 100644 etg/iconbndl.py create mode 100644 etg/iconloc.py create mode 100644 unittests/mondrian.ico create mode 100644 unittests/test_icon.py create mode 100644 unittests/test_iconbndl.py create mode 100644 unittests/test_iconloc.py diff --git a/etg/_core.py b/etg/_core.py index 4dee2d80..1eedf726 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -50,6 +50,7 @@ INCLUDES = [ 'defs', 'image', 'gdiobj', 'bitmap', + 'icon', 'iconloc', 'iconbndl', 'font', 'fontutil', 'pen', diff --git a/etg/icon.py b/etg/icon.py new file mode 100644 index 00000000..5c3db72b --- /dev/null +++ b/etg/icon.py @@ -0,0 +1,69 @@ +#--------------------------------------------------------------------------- +# Name: etg/icon.py +# Author: Robin Dunn +# +# Created: 14-Nov-2011 +# Copyright: (c) 2011 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "icon" # 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 = [ "wxIcon", ] + +#--------------------------------------------------------------------------- + +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. + + c = module.find('wxIcon') + assert isinstance(c, etgtools.ClassDef) + tools.removeVirtuals(c) + + c.find('wxIcon').findOverload('*bits').ignore() + c.find('wxIcon').findOverload('bits[]').ignore() + c.find('wxIcon.type').default = 'wxBITMAP_TYPE_ANY' + + c.find('LoadFile.type').default = 'wxBITMAP_TYPE_ANY' + c.find('ConvertToDisabled').ignore() + + c.addCppMethod('int', '__nonzero__', '()', """\ + return self->IsOk();""") + + c.addCppMethod('long', 'GetHandle', '()', """\ + #ifdef __WXMSW__ + return self->GetHandle(); + #else + return 0; + #endif + """) + + c.addCppMethod('void', 'SetHandle', '(long handle)', """\ + #ifdef __WXMSW__ + self->SetHandle((WXHANDLE)long); + #endif + """) + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/iconbndl.py b/etg/iconbndl.py new file mode 100644 index 00000000..3cdcdefc --- /dev/null +++ b/etg/iconbndl.py @@ -0,0 +1,45 @@ +#--------------------------------------------------------------------------- +# Name: etg/iconbndl.py +# Author: Robin Dunn +# +# Created: 14-Nov-2011 +# Copyright: (c) 2011 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "iconbndl" # 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 = [ 'wxIconBundle', ] + +#--------------------------------------------------------------------------- + +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. + + c = module.find('wxIconBundle') + assert isinstance(c, etgtools.ClassDef) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/etg/iconloc.py b/etg/iconloc.py new file mode 100644 index 00000000..4af7dc00 --- /dev/null +++ b/etg/iconloc.py @@ -0,0 +1,72 @@ +#--------------------------------------------------------------------------- +# Name: etg/iconloc.py +# Author: Robin Dunn +# +# Created: 14-Nov-2011 +# Copyright: (c) 2011 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "iconloc" # 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 = [ 'wxIconLocation', ] + +#--------------------------------------------------------------------------- + +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. + + c = module.find('wxIconLocation') + assert isinstance(c, etgtools.ClassDef) + + c.addCppCtor('()', "return new wxIconLocation;") + + c.addCppCtor('(const wxString* filename, int num = 0)', """\ + #ifdef __WXMSW__ + return new wxIconLocation(*filename, num); + #else + return new wxIconLocation(*filename); + #endif + """) + + c.addCppMethod('int', '__nonzero__', '()', """\ + return self->IsOk();""") + + c.addCppMethod('int', 'GetIndex', '()', """\ + #ifdef __WXMSW__ + return self->GetIndex(); + #else + return -1; + #endif + """) + + c.addCppMethod('void', 'SetIndex', '(int num)', """\ + #ifdef __WXMSW__ + self->SetIndex(num); + #endif + """) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/mondrian.ico b/unittests/mondrian.ico new file mode 100644 index 0000000000000000000000000000000000000000..2310c5d275a87af295d5ea8dc79ea417a5e74c53 GIT binary patch literal 766 zcmZQzU<5)11px*Sc)`TLAO@s0fLH;D9e|jTfdxnc0Z