]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/enhmeta.cpp
remove MSVC warnings about DLL-exported class inheriting from non DLL-exported one...
[wxWidgets.git] / src / msw / enhmeta.cpp
index cf6e758b69745442ffa8e8729a5d9f0c63c59c04..82d4adf106c93c072ef8a265ed75a63c4e21422e 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        msw/enhmeta.cpp
+// Name:        src/msw/enhmeta.cpp
 // Purpose:     implementation of wxEnhMetaFileXXX classes
 // Author:      Vadim Zeitlin
 // Modified by:
@@ -32,6 +32,9 @@
     #include "wx/intl.h"
 #endif //WX_PRECOMP
 
+#include "wx/dc.h"
+#include "wx/msw/dc.h"
+
 #include "wx/metafile.h"
 #include "wx/clipbrd.h"
 
@@ -42,7 +45,6 @@
 // ----------------------------------------------------------------------------
 
 IMPLEMENT_DYNAMIC_CLASS(wxEnhMetaFile, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC)
 
 // ----------------------------------------------------------------------------
 // macros
@@ -57,7 +59,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC)
 
 // we must pass NULL if the string is empty to metafile functions
 static inline const wxChar *GetMetaFileName(const wxString& fn)
-    { return !fn ? (wxChar *)NULL : fn.c_str(); }
+    { return !fn ? (const wxChar *)NULL : (const wxChar*)fn.wx_str(); }
 
 // ============================================================================
 // implementation
@@ -67,6 +69,21 @@ static inline const wxChar *GetMetaFileName(const wxString& fn)
 // 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() )
@@ -75,7 +92,7 @@ void wxEnhMetaFile::Init()
     }
     else // have valid file name, load metafile from it
     {
-        m_hMF = GetEnhMetaFile(m_filename);
+        m_hMF = (WXHANDLE)::GetEnhMetaFile(m_filename.fn_str());
         if ( !m_hMF )
             wxLogSysError(_("Failed to load metafile from file \"%s\"."),
                           m_filename.c_str());
@@ -136,7 +153,12 @@ bool wxEnhMetaFile::Play(wxDC *dc, wxRect *rectBound)
         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"));
 
@@ -187,12 +209,35 @@ bool wxEnhMetaFile::SetClipboard(int WXUNUSED(width), int WXUNUSED(height))
 }
 
 // ----------------------------------------------------------------------------
-// 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;
@@ -219,14 +264,14 @@ wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
 
     ScreenHDC hdcRef;
     m_hDC = (WXHDC)::CreateEnhMetaFile(hdcRef, GetMetaFileName(filename),
-                                       pRect, description);
+                                       pRect, description.wx_str());
     if ( !m_hDC )
     {
         wxLogLastError(_T("CreateEnhMetaFile"));
     }
 }
 
-void wxEnhMetaFileDC::DoGetSize(int *width, int *height) const
+void wxEnhMetaFileDCImpl::DoGetSize(int *width, int *height) const
 {
     if ( width )
         *width = m_width;
@@ -234,9 +279,9 @@ void wxEnhMetaFileDC::DoGetSize(int *width, int *height) const
         *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 )
@@ -251,12 +296,37 @@ wxEnhMetaFile *wxEnhMetaFileDC::Close()
     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 = static_cast<wxEnhMetaFileDCImpl *>(GetImpl());
+    wxCHECK_MSG( impl, NULL, _T("no wxEnhMetaFileDC implementation") );
+
+    return impl->Close();
+}
+
 #if wxUSE_DRAG_AND_DROP
 
 // ----------------------------------------------------------------------------