diff --git a/CHANGES.rst b/CHANGES.rst index 83667fed..53096cb9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -110,6 +110,12 @@ Changes in this release include the following: * Change wx.TextCompleterSimple.GetCompletions to send the list of strings as a return value, rather than a parameter that gets filled. (#836) +* Enabled the wx.GraphicsContext.Create(metaFileDC) wrapper (#811) + +* Metafile support is also available on OSX, so wx.msw.Metafile and + wx.msw.MetafileDC have been moved to the core wx module. So they can now be + accessed as wx.Metafile and wx.MetafileDC. + diff --git a/docs/sphinx/itemToModuleMap.json b/docs/sphinx/itemToModuleMap.json index 70a43fce..dab71915 100644 --- a/docs/sphinx/itemToModuleMap.json +++ b/docs/sphinx/itemToModuleMap.json @@ -2306,7 +2306,7 @@ "MOUSE_WHEEL_HORIZONTAL":"wx.", "MOUSE_WHEEL_VERTICAL":"wx.", "MacThemeColour":"wx.", -"MakeMetafilePlaceable":"wx.msw.", +"MakeMetafilePlaceable":"wx.", "MappingMode":"wx.", "Mask":"wx.", "Matrix2D":"wx.", @@ -2325,8 +2325,8 @@ "MessageBoxCaptionStr":"wx.", "MessageDialog":"wx.", "MessageParameters":"wx.FileType.", -"Metafile":"wx.msw.", -"MetafileDC":"wx.msw.", +"Metafile":"wx.", +"MetafileDC":"wx.", "MicroSleep":"wx.", "MilliSleep":"wx.", "MimeTypesManager":"wx.", diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/wx.Metafile.SetClipboard.1.py b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.Metafile.SetClipboard.1.py new file mode 100644 index 00000000..ee6db261 --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.Metafile.SetClipboard.1.py @@ -0,0 +1,8 @@ + + dc = wx.MetafileDC() + if dc.IsOk(): + self.Draw(dc) + mf = dc.Close() + if mf: + mf.SetClipboard(dc.MaxX() + 10, dc.MaxY() + 10) + diff --git a/etg/_core.py b/etg/_core.py index bb6f919a..f7a3ceff 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -92,6 +92,7 @@ INCLUDES = [ # base and core stuff 'dcprint', 'dcps', 'dcsvg', + 'metafile', 'graphics', 'imaglist', 'overlay', diff --git a/etg/_msw.py b/etg/_msw.py index 116472e0..5681b02a 100644 --- a/etg/_msw.py +++ b/etg/_msw.py @@ -29,7 +29,7 @@ ITEMS = [] # remove it from this list of Includes, and change the MODULE value in the # promoted script to be the same as its NAME. -INCLUDES = ['metafile', +INCLUDES = [#'metafile', 'axbase', ] @@ -67,4 +67,4 @@ def run(): # --------------------------------------------------------------------------- if __name__ == '__main__': - run() \ No newline at end of file + run() diff --git a/etg/graphics.py b/etg/graphics.py index 9e36c299..a86eae18 100644 --- a/etg/graphics.py +++ b/etg/graphics.py @@ -80,9 +80,18 @@ def run(): if 'DC' in p.name or p.name == 'image': p.keepReference = True - - # FIXME: Handle wxEnhMetaFileDC? - c.find('Create').findOverload('wxEnhMetaFileDC').ignore() + m = c.find('Create').findOverload('wxEnhMetaFileDC') + m.find('metaFileDC').type = 'const wxMetafileDC&' + m.argsString = '(const wxMetafileDC& metaFileDC)' + m.setCppCode("""\ + #ifdef __WXMSW__ + #if wxUSE_ENH_METAFILE + return wxGraphicsContext::Create(*metaFileDC); + #endif + #endif + wxPyRaiseNotImplemented(); + return NULL; + """) c.find('GetSize.width').out = True c.find('GetSize.height').out = True diff --git a/etg/metafile.py b/etg/metafile.py index 5e5eeaea..dcc5f914 100644 --- a/etg/metafile.py +++ b/etg/metafile.py @@ -12,7 +12,7 @@ import etgtools import etgtools.tweaker_tools as tools PACKAGE = "wx" -MODULE = "_msw" +MODULE = "_core" NAME = "metafile" # Base name of the file to generate to for this script DOCSTRING = "" @@ -22,7 +22,29 @@ ITEMS = [ 'wxMetafile', 'wxMetafileDC', ] +stubCode = """\ +#if !wxUSE_METAFILE +class wxMetafile : public wxObject +{ +public: + wxMetafile(const wxString& filename = wxEmptyString) { wxPyRaiseNotImplemented(); } + ~wxMetafile() {} + bool IsOk() { return false; } + bool Play(wxDC* dc) { return false; } + bool SetClipboard(int width = 0, int height = 0) { return false; } +}; + +class wxMetafileDC : public wxMemoryDC +{ +public: + wxMetafileDC(const wxString& filename = wxEmptyString) { wxPyRaiseNotImplemented(); } + ~wxMetafileDC() {} + wxMetafile* Close() { return NULL; } +}; + +#endif +""" #--------------------------------------------------------------------------- def run(): @@ -34,6 +56,9 @@ def run(): # Tweak the parsed meta objects in the module object as needed for # customizing the generated code and docstrings. + module.addHeaderCode('#include ') + module.addHeaderCode(stubCode) + c = module.find('wxMetafile') c.addPrivateCopyCtor()