mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 19:40:12 +01:00
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@68978 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
105 lines
3.5 KiB
Python
105 lines
3.5 KiB
Python
#---------------------------------------------------------------------------
|
|
# Name: etg/font.py
|
|
# Author: Robin Dunn
|
|
#
|
|
# Created:
|
|
# Copyright: (c) 2011 by Total Control Software
|
|
# License: wxWindows License
|
|
#---------------------------------------------------------------------------
|
|
|
|
import etgtools
|
|
import etgtools.tweaker_tools as tools
|
|
|
|
PACKAGE = "wx"
|
|
MODULE = "_core"
|
|
NAME = "font" # 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 = [ 'wxFont',
|
|
'wxFontMetrics',
|
|
]
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
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.
|
|
|
|
|
|
# TODOs
|
|
module.find('wxTheFontList').ignore()
|
|
module.find('wxNORMAL_FONT').ignore()
|
|
module.find('wxSMALL_FONT').ignore()
|
|
module.find('wxITALIC_FONT').ignore()
|
|
module.find('wxSWISS_FONT').ignore()
|
|
|
|
|
|
c = module.find('wxFont')
|
|
assert isinstance(c, etgtools.ClassDef)
|
|
tools.removeVirtuals(c)
|
|
|
|
# TODO: Since the TypeCode is inserted before the derived class
|
|
# (sipwxFont) is defined, we can't use the new version of addCppCtor. Can
|
|
# this be fixed?
|
|
c.addCppCtor_sip("""(
|
|
int pointSize,
|
|
wxFontFamily family,
|
|
int flags = wxFONTFLAG_DEFAULT,
|
|
const wxString& faceName = wxEmptyString,
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT )""",
|
|
body="""\
|
|
wxFont* font = wxFont::New(pointSize, family, flags, *faceName, encoding);
|
|
sipCpp = new sipwxFont(*font);
|
|
delete font;
|
|
""")
|
|
|
|
# Same as the above, but as a factory function
|
|
module.addCppFunction('wxFont*', 'FFont', """(
|
|
int pointSize,
|
|
wxFontFamily family,
|
|
int flags = wxFONTFLAG_DEFAULT,
|
|
const wxString& faceName = wxEmptyString,
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT )""",
|
|
body="""\
|
|
wxFont* font = wxFont::New(pointSize, family, flags, *faceName, encoding);
|
|
return font;
|
|
""", factory=True)
|
|
|
|
|
|
for item in c.findAll('New'):
|
|
item.factory = True
|
|
|
|
c.addProperty('Encoding GetEncoding SetEncoding')
|
|
c.addProperty('FaceName GetFaceName SetFaceName')
|
|
c.addProperty('Family GetFamily SetFamily')
|
|
c.addProperty('NativeFontInfoDesc GetNativeFontInfoDesc SetNativeFontInfo')
|
|
c.addProperty('NativeFontInfoUserDesc GetNativeFontInfoUserDesc SetNativeFontInfoUserDesc')
|
|
c.addProperty('PointSize GetPointSize SetPointSize')
|
|
c.addProperty('PixelSize GetPixelSize SetPixelSize')
|
|
c.addProperty('Style GetStyle SetStyle')
|
|
c.addProperty('Weight GetWeight SetWeight')
|
|
|
|
# TODO, there is now a Underlined method so we can't have a
|
|
# property of the same name.
|
|
#c.addProperty('Underlined GetUnderlined SetUnderlined')
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------
|
|
tools.doCommonTweaks(module)
|
|
tools.runGenerators(module)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
if __name__ == '__main__':
|
|
run()
|
|
|