#include "wx/intl.h"
#endif //WX_PRECOMP
+#include "wx/dc.h"
+#include "wx/msw/dc.h"
+
#include "wx/metafile.h"
#include "wx/clipbrd.h"
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxEnhMetaFile, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC)
// ----------------------------------------------------------------------------
// macros
// wxEnhMetaFile
// ----------------------------------------------------------------------------
+wxGDIRefData *wxEnhMetaFile::CreateGDIRefData() const
+{
+ wxFAIL_MSG( _T("must be implemented if used") );
+
+ return NULL;
+}
+
+wxGDIRefData *
+wxEnhMetaFile::CloneGDIRefData(const wxGDIRefData *WXUNUSED(data)) const
+{
+ wxFAIL_MSG( _T("must be implemented if used") );
+
+ return NULL;
+}
+
void wxEnhMetaFile::Init()
{
if ( m_filename.empty() )
rect.bottom = size.y;
}
- if ( !::PlayEnhMetaFile(GetHdcOf(*dc), GetEMF(), &rect) )
+ wxDCImpl *impl = dc->GetImpl();
+ wxMSWDCImpl *msw_impl = wxDynamicCast( impl, wxMSWDCImpl );
+ if (!msw_impl)
+ return false;
+
+ if ( !::PlayEnhMetaFile(GetHdcOf(*msw_impl), GetEMF(), &rect) )
{
wxLogLastError(_T("PlayEnhMetaFile"));
}
// ----------------------------------------------------------------------------
-// wxEnhMetaFileDC
+// wxEnhMetaFileDCImpl
// ----------------------------------------------------------------------------
-wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
+class wxEnhMetaFileDCImpl : public wxMSWDCImpl
+{
+public:
+ wxEnhMetaFileDCImpl( wxEnhMetaFileDC *owner,
+ const wxString& filename, int width, int height,
+ const wxString& description );
+ virtual ~wxEnhMetaFileDCImpl();
+
+ // obtain a pointer to the new metafile (caller should delete it)
+ wxEnhMetaFile *Close();
+
+protected:
+ virtual void DoGetSize(int *width, int *height) const;
+
+private:
+ // size passed to ctor and returned by DoGetSize()
+ int m_width,
+ m_height;
+};
+
+
+wxEnhMetaFileDCImpl::wxEnhMetaFileDCImpl( wxEnhMetaFileDC* owner,
+ const wxString& filename,
int width, int height,
- const wxString& description)
+ const wxString& description )
+ : wxMSWDCImpl( owner )
{
m_width = width;
m_height = height;
}
}
-void wxEnhMetaFileDC::DoGetSize(int *width, int *height) const
+void wxEnhMetaFileDCImpl::DoGetSize(int *width, int *height) const
{
if ( width )
*width = m_width;
*height = m_height;
}
-wxEnhMetaFile *wxEnhMetaFileDC::Close()
+wxEnhMetaFile *wxEnhMetaFileDCImpl::Close()
{
- wxCHECK_MSG( Ok(), NULL, _T("invalid wxEnhMetaFileDC") );
+ wxCHECK_MSG( IsOk(), NULL, _T("invalid wxEnhMetaFileDC") );
HENHMETAFILE hMF = ::CloseEnhMetaFile(GetHdc());
if ( !hMF )
return mf;
}
-wxEnhMetaFileDC::~wxEnhMetaFileDC()
+wxEnhMetaFileDCImpl::~wxEnhMetaFileDCImpl()
{
// avoid freeing it in the base class dtor
m_hDC = 0;
}
+// ----------------------------------------------------------------------------
+// wxEnhMetaFileDC
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC)
+
+wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
+ int width, int height,
+ const wxString& description)
+ : wxDC(new wxEnhMetaFileDCImpl(this,
+ filename,
+ width, height,
+ description))
+{
+}
+
+wxEnhMetaFile *wxEnhMetaFileDC::Close()
+{
+ wxEnhMetaFileDCImpl * const
+ impl = wx_static_cast(wxEnhMetaFileDCImpl *, GetImpl());
+ wxCHECK_MSG( impl, NULL, _T("no wxEnhMetaFileDC implementation") );
+
+ return impl->Close();
+}
+
#if wxUSE_DRAG_AND_DROP
// ----------------------------------------------------------------------------