Add wxEnhMetaFile::Detach().

Allow getting the handle from this class, this is useful if it needs to be
passed to some other library, for example.

Closes #15706.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-03-11 16:04:22 +00:00
parent 9a61ced717
commit 61e323ad37
3 changed files with 14 additions and 4 deletions

View File

@@ -51,6 +51,7 @@ wxMSW:
- Fix loading of bitmap with non-pre-multiplied alpha (Artur Wieczorek).
- Support multiline strings in wxDC::DrawRotatedText() (Artur Wieczorek).
- Fix stretchable spacers in vertical toolbars (Artur Wieczorek).
- Add wxEnhMetaFile::Detach() (Luca Bacci).
wxOSX/Cocoa:

View File

@@ -52,13 +52,21 @@ public:
// this method
bool SetClipboard(int width = 0, int height = 0);
// Detach the HENHMETAFILE from this object, i.e. don't delete the handle
// in the dtor -- the caller is now responsible for doing this, e.g. using
// Free() method below.
WXHANDLE Detach() { WXHANDLE h = m_hMF; m_hMF = 0; return h; }
// Destroy the given HENHMETAFILE object.
static void Free(WXHANDLE handle);
// implementation
WXHANDLE GetHENHMETAFILE() const { return m_hMF; }
void SetHENHMETAFILE(WXHANDLE hMF) { Free(); m_hMF = hMF; }
protected:
void Init();
void Free();
void Free() { Free(m_hMF); }
void Assign(const wxEnhMetaFile& mf);
// we don't use these functions (but probably should) but have to implement

View File

@@ -120,11 +120,12 @@ void wxEnhMetaFile::Assign(const wxEnhMetaFile& mf)
}
}
void wxEnhMetaFile::Free()
/* static */
void wxEnhMetaFile::Free(WXHANDLE handle)
{
if ( m_hMF )
if ( handle )
{
if ( !::DeleteEnhMetaFile(GetEMF()) )
if ( !::DeleteEnhMetaFile((HENHMETAFILE) handle) )
{
wxLogLastError(wxT("DeleteEnhMetaFile"));
}