X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6670f56440ae9209b3e2e51e06acf3bc5aaf1905..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/os2/metafile.cpp diff --git a/src/os2/metafile.cpp b/src/os2/metafile.cpp index cb3d8541db..04ac44c04a 100644 --- a/src/os2/metafile.cpp +++ b/src/os2/metafile.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: metafile.cpp +// Name: src/os2/metafile.cpp // Purpose: wxMetaFile, wxMetaFileDC etc. These classes are optional. // Author: David Webster // Modified by: @@ -12,15 +12,11 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifndef WX_PRECOMP -#include "wx/setup.h" -#endif - #if wxUSE_METAFILE #ifndef WX_PRECOMP -#include "wx/utils.h" -#include "wx/app.h" + #include "wx/utils.h" + #include "wx/app.h" #endif #include "wx/metafile.h" @@ -44,7 +40,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC) wxMetafileRefData::wxMetafileRefData(void) { m_metafile = 0; - m_windowsMappingMode = wxMM_ANISOTROPIC; + m_windowsMappingMode = MM_ANISOTROPIC; } wxMetafileRefData::~wxMetafileRefData(void) @@ -60,9 +56,9 @@ wxMetafile::wxMetafile(const wxString& file) { m_refData = new wxMetafileRefData; - M_METAFILEDATA->m_windowsMappingMode = wxMM_ANISOTROPIC; + M_METAFILEDATA->m_windowsMappingMode = MM_ANISOTROPIC; M_METAFILEDATA->m_metafile = 0; - if (!file.IsNull() && (file.Cmp(wxT("")) == 0)) + if (!file.empty()) M_METAFILEDATA->m_metafile = (WXHANDLE)0; // TODO: GetMetaFile(file); } @@ -70,6 +66,16 @@ wxMetafile::~wxMetafile(void) { } +wxGDIRefData *wxMetafile::CreateGDIRefData() const +{ + return new wxMetafileRefData; +} + +wxGDIRefData *wxMetafile::CloneGDIRefData(const wxGDIRefData *data) const +{ + return new wxMetafileRefData(*static_cast(data)); +} + bool wxMetafile::SetClipboard(int width, int height) { #if !wxUSE_CLIPBOARD @@ -84,7 +90,7 @@ bool wxMetafile::SetClipboard(int width, int height) if (!alreadyOpen) { wxOpenClipboard(); - if (!wxEmptyClipboard()) return FALSE; + if (!wxEmptyClipboard()) return false; } bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height); if (!alreadyOpen) wxCloseClipboard(); @@ -95,15 +101,11 @@ bool wxMetafile::SetClipboard(int width, int height) bool wxMetafile::Play(wxDC *dc) { if (!m_refData) - return FALSE; - - dc->BeginDrawing(); + return false; // if (dc->GetHDC() && M_METAFILEDATA->m_metafile) // PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile); - dc->EndDrawing(); - return true; } @@ -130,7 +132,8 @@ void wxMetafile::SetWindowsMappingMode(int mm) // Original constructor that does not takes origin and extent. If you use this, // *DO* give origin/extent arguments to wxMakeMetafilePlaceable. -wxMetafileDC::wxMetafileDC(const wxString& file) +wxMetafileDCImpl::wxMetafileDCImpl(wxDC *owner, const wxString& file) + : wxPMDCImpl(owner) { m_metaFile = NULL; m_minX = 10000; @@ -139,12 +142,12 @@ wxMetafileDC::wxMetafileDC(const wxString& file) m_maxY = -10000; // m_title = NULL; - if (!file.IsNull() && wxFileExists(file)) + if ( wxFileExists(file) ) wxRemoveFile(file); // TODO /* - if (!file.IsNull() && (file != wxT(""))) + if (!file.empty()) m_hDC = (WXHDC) CreateMetaFile(file); else m_hDC = (WXHDC) CreateMetaFile(NULL); @@ -160,17 +163,18 @@ wxMetafileDC::wxMetafileDC(const wxString& file) // New constructor that takes origin and extent. If you use this, don't // give origin/extent arguments to wxMakeMetafilePlaceable. -wxMetafileDC::wxMetafileDC( const wxString& file, - int WXUNUSED(xext), - int WXUNUSED(yext), - int WXUNUSED(xorg), - int WXUNUSED(yorg) ) +wxMetafileDCImpl::wxMetafileDCImpl( wxDC *owner, const wxString& file, + int WXUNUSED(xext), + int WXUNUSED(yext), + int WXUNUSED(xorg), + int WXUNUSED(yorg) ) + : wxPMDCImpl(owner) { m_minX = 10000; m_minY = 10000; m_maxX = -10000; m_maxY = -10000; - if (file != wxT("") && wxFileExists(file)) + if (!file.empty() && wxFileExists(file)) wxRemoveFile(file); // m_hDC = (WXHDC) CreateMetaFile(file); @@ -181,27 +185,26 @@ wxMetafileDC::wxMetafileDC( const wxString& file, // ::SetWindowExtEx((HDC) m_hDC,xext,yext, NULL); // Actual Windows mapping mode, for future reference. - m_windowsMappingMode = wxMM_ANISOTROPIC; + m_windowsMappingMode = MM_ANISOTROPIC; SetMapMode(wxMM_TEXT); // NOTE: does not set HDC mapmode (this is correct) } -wxMetafileDC::~wxMetafileDC(void) +wxMetafileDCImpl::~wxMetafileDCImpl(void) { m_hDC = 0; } -void wxMetafileDC::GetTextExtent(const wxString& WXUNUSED(string), - long *WXUNUSED(x), - long *WXUNUSED(y), - long *WXUNUSED(descent), - long *WXUNUSED(externalLeading), - wxFont *theFont, - bool WXUNUSED(use16bit) ) const +void wxMetafileDCImpl::DoGetTextExtent(const wxString& WXUNUSED(string), + wxCoord *WXUNUSED(x), + wxCoord *WXUNUSED(y), + wxCoord *WXUNUSED(descent), + wxCoord *WXUNUSED(externalLeading), + const wxFont *theFont) const { - wxFont *fontToUse = theFont; + const wxFont *fontToUse = theFont; if (!fontToUse) - fontToUse = (wxFont*) &m_font; + fontToUse = &m_font; // TODO: /* @@ -225,7 +228,7 @@ void wxMetafileDC::GetTextExtent(const wxString& WXUNUSED(string), */ } -wxMetafile *wxMetafileDC::Close(void) +wxMetafile *wxMetafileDCImpl::Close(void) { SelectOldObjects(m_hDC); HANDLE mf = 0; // TODO: CloseMetaFile((HDC) m_hDC); @@ -240,7 +243,7 @@ wxMetafile *wxMetafileDC::Close(void) return NULL; } -void wxMetafileDC::SetMapMode(int mode) +void wxMetafileDCImpl::SetMapMode(wxMappingMode mode) { m_mappingMode = mode; @@ -362,13 +365,13 @@ bool wxMakeMetafilePlaceable(const wxString& WXUNUSED(filename), FILE *fd = fopen(filename.fn_str(), "rb"); if (!fd) - return FALSE; + return false; wxChar tempFileBuf[256]; wxGetTempFileName(wxT("mf"), tempFileBuf); FILE *fHandle = fopen(wxConvFile.cWX2MB(tempFileBuf), "wb"); if (!fHandle) - return FALSE; + return false; fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle); // Calculate origin and extent