Merge pull request #845 from RobinD42/fix-issue811

Enable wrapping wxGraphicsContext::Create(metaFileDC)
(cherry picked from commit 6c3ce18e17)
This commit is contained in:
Robin Dunn
2018-05-05 22:13:24 -07:00
parent a429e7cdbe
commit f32cb4669f
7 changed files with 58 additions and 9 deletions

View File

@@ -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.

View File

@@ -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.",

View File

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

View File

@@ -92,6 +92,7 @@ INCLUDES = [ # base and core stuff
'dcprint',
'dcps',
'dcsvg',
'metafile',
'graphics',
'imaglist',
'overlay',

View File

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

View File

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

View File

@@ -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 <wx/metafile.h>')
module.addHeaderCode(stubCode)
c = module.find('wxMetafile')
c.addPrivateCopyCtor()