Add wxIcon, wxIconBundle, wxIconLocation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69777 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2011-11-17 03:29:37 +00:00
parent e422e4d2cc
commit 7944d9464f
8 changed files with 290 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ INCLUDES = [ 'defs',
'image',
'gdiobj',
'bitmap',
'icon', 'iconloc', 'iconbndl',
'font',
'fontutil',
'pen',

69
etg/icon.py Normal file
View File

@@ -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()

45
etg/iconbndl.py Normal file
View File

@@ -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()

72
etg/iconloc.py Normal file
View File

@@ -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()

BIN
unittests/mondrian.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

37
unittests/test_icon.py Normal file
View File

@@ -0,0 +1,37 @@
import imp_unittest, unittest
import wtc
import wx
import os
icoFile = os.path.join(os.path.dirname(__file__), 'mondrian.ico')
pngFile = os.path.join(os.path.dirname(__file__), 'pointy.png')
#---------------------------------------------------------------------------
class icon_Tests(wtc.WidgetTestCase):
def test_icon1(self):
i1 = wx.Icon(icoFile)
i2 = wx.Icon(i1)
def test_icon2(self):
i = wx.Icon()
i.CopyFromBitmap(wx.Bitmap(pngFile))
def test_icon3(self):
i = wx.Icon(icoFile)
i.Depth
i.Width
i.Height
i.Handle
i.SetDepth(32)
i.SetWidth(32)
i.SetHeight(32)
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,40 @@
import imp_unittest, unittest
import wtc
import wx
import os
icoFile = os.path.join(os.path.dirname(__file__), 'mondrian.ico')
pngFile = os.path.join(os.path.dirname(__file__), 'pointy.png')
#---------------------------------------------------------------------------
class iconbndl_Tests(wtc.WidgetTestCase):
def test_iconbndl1(self):
ib = wx.IconBundle()
ib.AddIcon(icoFile)
ib.AddIcon(wx.Icon(icoFile))
i = ib.GetIcon()
def test_iconbndl2(self):
ib = wx.IconBundle(icoFile)
ib2 = wx.IconBundle(ib)
def test_iconbndl3(self):
ib = wx.IconBundle(wx.Icon(icoFile))
def test_iconbndl4(self):
ib = wx.IconBundle()
ib.Icon
ib.IconCount
wx.NullIconBundle
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

26
unittests/test_iconloc.py Normal file
View File

@@ -0,0 +1,26 @@
import imp_unittest, unittest
import wtc
import wx
import os
icoFile = os.path.join(os.path.dirname(__file__), 'mondrian.ico')
pngFile = os.path.join(os.path.dirname(__file__), 'pointy.png')
#---------------------------------------------------------------------------
class iconloc_Tests(wtc.WidgetTestCase):
def test_iconloc1(self):
loc = wx.IconLocation(icoFile)
i = wx.Icon(loc)
def test_iconloc2(self):
loc = wx.IconLocation()
loc.SetFileName(icoFile)
i = wx.Icon(loc)
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()