]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/metafile.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMetaFile, wxMetaFileDC etc. These classes are optional.
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "metafile.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
34 #include "wx/metafile.h"
35 #include "wx/clipbrd.h"
40 extern bool wxClipboardIsOpen
;
42 #if !USE_SHARED_LIBRARY
43 IMPLEMENT_DYNAMIC_CLASS(wxMetafile
, wxObject
)
44 IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC
, wxDC
)
49 * Currently, the only purpose for making a metafile is to put
50 * it on the clipboard.
53 wxMetafileRefData::wxMetafileRefData(void)
58 wxMetafileRefData::~wxMetafileRefData(void)
62 KillPicture( m_metafile
) ;
67 wxMetaFile::wxMetaFile(const wxString
& file
)
69 m_refData
= new wxMetafileRefData
;
72 M_METAFILEDATA
->m_metafile
= 0;
73 wxASSERT_MSG( file
.IsEmpty() , "no file based metafile support yet") ;
75 if (!file.IsNull() && (file.Cmp("") == 0))
76 M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
80 wxMetaFile::~wxMetaFile()
84 bool wxMetaFile::SetClipboard(int width
, int height
)
89 bool alreadyOpen
=wxClipboardOpen();
93 if (!wxEmptyClipboard()) return FALSE
;
95 bool success
= wxSetClipboardData(wxDF_METAFILE
, this, width
,height
);
96 if (!alreadyOpen
) wxCloseClipboard();
97 return (bool) success
;
102 void wxMetafile::SetHMETAFILE(PicHandle mf
)
105 m_refData
= new wxMetafileRefData
;
107 M_METAFILEDATA
->m_metafile
= mf
;
110 bool wxMetaFile::Play(wxDC
*dc
)
118 dc
->MacVerifySetup() ;
121 PicHandle pict
= GetHMETAFILE() ;
122 DrawPicture( pict
, &(**pict
).picFrame
) ;
130 if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
131 PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile);
139 * Metafile device context
143 // Original constructor that does not takes origin and extent. If you use this,
144 // *DO* give origin/extent arguments to wxMakeMetaFilePlaceable.
145 wxMetaFileDC::wxMetaFileDC(const wxString
& file
)
153 wxASSERT_MSG( file
.IsEmpty() , "no file based metafile support yet") ;
155 m_metaFile
= new wxMetaFile("") ;
156 Rect r
={0,0,1000,1000} ;
158 m_metaFile
->SetHMETAFILE( OpenPicture( &r
) ) ;
159 ::GetPort( &m_macPort
) ;
162 SetMapMode(wxMM_TEXT
);
165 // New constructor that takes origin and extent. If you use this, don't
166 // give origin/extent arguments to wxMakeMetaFilePlaceable.
168 wxMetaFileDC::wxMetaFileDC(const wxString
& file
, int xext
, int yext
, int xorg
, int yorg
)
175 wxASSERT_MSG( file
.IsEmpty() , "no file based metafile support yet") ;
177 m_metaFile
= new wxMetaFile("") ;
178 Rect r
={yorg
,xorg
,yorg
+yext
,xorg
+xext
} ;
180 m_metaFile
->SetHMETAFILE( OpenPicture( &r
) ) ;
181 ::GetPort( &m_macPort
) ;
184 SetMapMode(wxMM_TEXT
);
187 wxMetaFileDC::~wxMetaFileDC()
191 wxMetaFile
*wxMetaFileDC::Close()