diff --git a/etg/_core.py b/etg/_core.py index 52d57383..dab73bc4 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -51,6 +51,7 @@ INCLUDES = [ 'defs', 'gdiobj', 'bitmap', 'font', + 'fontutil', 'pen', 'brush', 'region', diff --git a/etg/font.py b/etg/font.py index 0a27228d..fd0fb6e2 100644 --- a/etg/font.py +++ b/etg/font.py @@ -36,28 +36,11 @@ def run(): assert isinstance(c, etgtools.ClassDef) tools.removeVirtuals(c) - # EXPERIMENTAL: See alternate implementation below that we can do when - # the wxObject dtor is not marked virtual. - ## 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; - # """) - c.addCppCtor("""(int pointSize, wxFontFamily family, int flags = wxFONTFLAG_DEFAULT, const wxString& faceName = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT )""", + wxFontEncoding encoding = wxFONTENCODING_DEFAULT)""", body="""\ wxFont* font = wxFont::New(pointSize, family, flags, *faceName, encoding); return font; @@ -66,10 +49,10 @@ def run(): # 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 )""", + 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; @@ -93,6 +76,11 @@ def run(): # property of the same name. #c.addProperty('Underlined GetUnderlined SetUnderlined') + c.addCppMethod('int', '__nonzero__', '()', """\ + return self->IsOk(); + """) + + # The stock Font items are documented as simple pointers, but in reality # they are macros that evaluate to a function call that returns a font @@ -114,6 +102,9 @@ def run(): # it is delay-initialized, see stockgdi.sip module.find('wxTheFontList').ignore() + module.find('wxFromString').ignore() + module.find('wxToString').ignore() + #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module) diff --git a/etg/fontutil.py b/etg/fontutil.py new file mode 100644 index 00000000..397cc3c3 --- /dev/null +++ b/etg/fontutil.py @@ -0,0 +1,56 @@ +#--------------------------------------------------------------------------- +# Name: etg/fontutil.py +# Author: Robin Dunn +# +# Created: 8-Oct-2011 +# Copyright: (c) 2011 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "fontutil" # 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 = [ 'wxNativeFontInfo', + ] + +#--------------------------------------------------------------------------- + +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('wxNativeFontInfo') + assert isinstance(c, etgtools.ClassDef) + c.addCppMethod('wxString*', '__str__', '()', """\ + return new wxString(self->ToString()); + """) + + # linker errors on all but MSW... + c.find('GetPixelSize').ignore() + c.find('SetPixelSize').ignore() + + c.addGetterSetterProps() + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() +