mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 11:00:07 +01:00
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:
@@ -50,6 +50,7 @@ INCLUDES = [ 'defs',
|
|||||||
'image',
|
'image',
|
||||||
'gdiobj',
|
'gdiobj',
|
||||||
'bitmap',
|
'bitmap',
|
||||||
|
'icon', 'iconloc', 'iconbndl',
|
||||||
'font',
|
'font',
|
||||||
'fontutil',
|
'fontutil',
|
||||||
'pen',
|
'pen',
|
||||||
|
|||||||
69
etg/icon.py
Normal file
69
etg/icon.py
Normal 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
45
etg/iconbndl.py
Normal 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
72
etg/iconloc.py
Normal 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
BIN
unittests/mondrian.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 766 B |
37
unittests/test_icon.py
Normal file
37
unittests/test_icon.py
Normal 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()
|
||||||
40
unittests/test_iconbndl.py
Normal file
40
unittests/test_iconbndl.py
Normal 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
26
unittests/test_iconloc.py
Normal 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()
|
||||||
Reference in New Issue
Block a user