]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/enhmeta.cpp
add virtual DoGetTextExtent() to allow calling the overloaded wxWindowBase::GetTextEx...
[wxWidgets.git] / src / msw / enhmeta.cpp
index a3931c976fe80d1a8f5faa5eaae53505bce301fe..fd2e73ac75e16e09d4a650250b4aad0a34bd31b3 100644 (file)
@@ -218,6 +218,10 @@ public:
     wxEnhMetaFileDCImpl( wxEnhMetaFileDC *owner,
                          const wxString& filename, int width, int height,
                          const wxString& description );
+    wxEnhMetaFileDCImpl( wxEnhMetaFileDC *owner,
+                         const wxDC& referenceDC,
+                         const wxString& filename, int width, int height,
+                         const wxString& description );
     virtual ~wxEnhMetaFileDCImpl();
 
     // obtain a pointer to the new metafile (caller should delete it)
@@ -227,6 +231,10 @@ protected:
     virtual void DoGetSize(int *width, int *height) const;
 
 private:
+    void Create(HDC hdcRef,
+                const wxString& filename, int width, int height,
+                const wxString& description);
+
     // size passed to ctor and returned by DoGetSize()
     int m_width,
         m_height;
@@ -238,6 +246,24 @@ wxEnhMetaFileDCImpl::wxEnhMetaFileDCImpl( wxEnhMetaFileDC* owner,
                                  int width, int height,
                                  const wxString& description )
                    : wxMSWDCImpl( owner )
+{
+    Create(ScreenHDC(), filename, width, height, description);
+}
+
+wxEnhMetaFileDCImpl::wxEnhMetaFileDCImpl( wxEnhMetaFileDC* owner,
+                                 const wxDC& referenceDC,
+                                 const wxString& filename,
+                                 int width, int height,
+                                 const wxString& description )
+                   : wxMSWDCImpl( owner )
+{
+    Create(GetHdcOf(referenceDC), filename, width, height, description);
+}
+
+void wxEnhMetaFileDCImpl::Create(HDC hdcRef,
+                                 const wxString& filename,
+                                 int width, int height,
+                                 const wxString& description)
 {
     m_width = width;
     m_height = height;
@@ -252,7 +278,7 @@ wxEnhMetaFileDCImpl::wxEnhMetaFileDCImpl( wxEnhMetaFileDC* owner,
         rect.bottom = height;
 
         // CreateEnhMetaFile() wants them in HIMETRIC
-        PixelToHIMETRIC(&rect.right, &rect.bottom);
+        PixelToHIMETRIC(&rect.right, &rect.bottom, hdcRef);
 
         pRect = ▭
     }
@@ -262,7 +288,6 @@ wxEnhMetaFileDCImpl::wxEnhMetaFileDCImpl( wxEnhMetaFileDC* owner,
         pRect = (LPRECT)NULL;
     }
 
-    ScreenHDC hdcRef;
     m_hDC = (WXHDC)::CreateEnhMetaFile(hdcRef, GetMetaFileName(filename),
                                        pRect, description.wx_str());
     if ( !m_hDC )
@@ -318,10 +343,22 @@ wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
 {
 }
 
+wxEnhMetaFileDC::wxEnhMetaFileDC(const wxDC& referenceDC,
+                                 const wxString& filename,
+                                 int width, int height,
+                                 const wxString& description)
+               : wxDC(new wxEnhMetaFileDCImpl(this,
+                                              referenceDC,
+                                              filename,
+                                              width, height,
+                                              description))
+{
+}
+
 wxEnhMetaFile *wxEnhMetaFileDC::Close()
 {
     wxEnhMetaFileDCImpl * const
-        impl = wx_static_cast(wxEnhMetaFileDCImpl *, GetImpl());
+        impl = static_cast<wxEnhMetaFileDCImpl *>(GetImpl());
     wxCHECK_MSG( impl, NULL, _T("no wxEnhMetaFileDC implementation") );
 
     return impl->Close();