]>
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 IMPLEMENT_DYNAMIC_CLASS(wxMetafile
, wxObject
) 
  43 IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC
, wxDC
) 
  47  * Currently, the only purpose for making a metafile is to put 
  48  * it on the clipboard. 
  51 wxMetafileRefData::wxMetafileRefData(void) 
  56 wxMetafileRefData::~wxMetafileRefData(void) 
  60                                 KillPicture( m_metafile 
) ; 
  65 wxMetaFile::wxMetaFile(const wxString
& file
) 
  67     m_refData 
= new wxMetafileRefData
; 
  70     M_METAFILEDATA
->m_metafile 
= 0; 
  71     wxASSERT_MSG( file
.IsEmpty() , "no file based metafile support yet") ; 
  73     if (!file.IsNull() && (file.Cmp("") == 0)) 
  74         M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file); 
  78 wxMetaFile::~wxMetaFile() 
  82 bool wxMetaFile::SetClipboard(int width
, int height
) 
  87     bool alreadyOpen=wxClipboardOpen(); 
  91         if (!wxEmptyClipboard()) return FALSE; 
  93     bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height); 
  94     if (!alreadyOpen) wxCloseClipboard(); 
  95     return (bool) success; 
 100 bool wxMetaFile::Play(wxDC 
*dc
) 
 108         dc
->MacVerifySetup() ; 
 111                 PicHandle pict 
= GetHMETAFILE() ; 
 112                 DrawPicture( pict 
, &(**pict
).picFrame 
) ; 
 120     if (dc->GetHDC() && M_METAFILEDATA->m_metafile) 
 121         PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile); 
 129  * Metafile device context 
 133 // Original constructor that does not takes origin and extent. If you use this, 
 134 // *DO* give origin/extent arguments to wxMakeMetaFilePlaceable. 
 135 wxMetaFileDC::wxMetaFileDC(const wxString
& file
) 
 143   wxASSERT_MSG( file
.IsEmpty() , "no file based metafile support yet") ; 
 145         m_metaFile 
= new wxMetaFile("") ; 
 146         Rect r
={0,0,100,100} ; 
 148         m_metaFile
->SetHMETAFILE( OpenPicture( &r 
) ) ; 
 149         ::GetPort( &m_macPort 
) ;        
 152   SetMapMode(wxMM_TEXT
);  
 155 // New constructor that takes origin and extent. If you use this, don't 
 156 // give origin/extent arguments to wxMakeMetaFilePlaceable. 
 158 wxMetaFileDC::wxMetaFileDC(const wxString
& file
, int xext
, int yext
, int xorg
, int yorg
) 
 165   wxASSERT_MSG( file
.IsEmpty() , "no file based metafile support yet") ; 
 167         m_metaFile 
= new wxMetaFile("") ; 
 168         Rect r
={yorg
,xorg
,yorg
+yext
,xorg
+xext
} ; 
 170         m_metaFile
->SetHMETAFILE( OpenPicture( &r 
) ) ; 
 171         ::GetPort( &m_macPort 
) ;        
 174   SetMapMode(wxMM_TEXT
);  
 177 wxMetaFileDC::~wxMetaFileDC() 
 181 wxMetaFile 
*wxMetaFileDC::Close()