]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/metafile.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxMetaFile, wxMetaFileDC etc. These classes are optional. 
   4 // Author:      Stefan Csomor 
   8 // Copyright:   (c) Stefan Csomor 
   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" 
  37 #include "wx/mac/private.h" 
  42 extern bool wxClipboardIsOpen
; 
  44 #if !USE_SHARED_LIBRARY 
  45 IMPLEMENT_DYNAMIC_CLASS(wxMetafile
, wxObject
) 
  46 IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC
, wxDC
) 
  51  * Currently, the only purpose for making a metafile is to put 
  52  * it on the clipboard. 
  55 wxMetafileRefData::wxMetafileRefData(void) 
  60 wxMetafileRefData::~wxMetafileRefData(void) 
  64         KillPicture( (PicHandle
) m_metafile 
) ; 
  69 wxMetaFile::wxMetaFile(const wxString
& file
) 
  71     m_refData 
= new wxMetafileRefData
; 
  74     M_METAFILEDATA
->m_metafile 
= 0; 
  75     wxASSERT_MSG( file
.IsEmpty() , wxT("no file based metafile support yet") ) ; 
  77     if (!file.IsNull() && (file.Cmp("") == 0)) 
  78         M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file); 
  82 wxMetaFile::~wxMetaFile() 
  86 bool wxMetaFile::SetClipboard(int width
, int height
) 
  88 #if wxUSE_DRAG_AND_DROP 
  89     //TODO finishi this port , we need the data obj first 
  93     bool alreadyOpen
=wxTheClipboard
->IsOpened() ; 
  96         wxTheClipboard
->Open(); 
  97         wxTheClipboard
->Clear(); 
 100         new wxMetafileDataObject( *this) ; 
 101     bool success 
= wxTheClipboard
->SetData(data
); 
 103         wxTheClipboard
->Close(); 
 104     return (bool) success
; 
 109 void wxMetafile::SetHMETAFILE(WXHMETAFILE mf
) 
 112         m_refData 
= new wxMetafileRefData
; 
 114     M_METAFILEDATA
->m_metafile 
= mf
; 
 117 bool wxMetaFile::Play(wxDC 
*dc
) 
 126         wxMacPortSetter 
helper( dc 
) ; 
 127         PicHandle pict 
= (PicHandle
) GetHMETAFILE() ; 
 128         DrawPicture( pict 
, &(**pict
).picFrame 
) ; 
 134  * Metafile device context 
 138 // Original constructor that does not takes origin and extent. If you use this, 
 139 // *DO* give origin/extent arguments to wxMakeMetaFilePlaceable. 
 140 wxMetaFileDC::wxMetaFileDC(const wxString
& file
) 
 148     wxASSERT_MSG( file
.IsEmpty() , wxT("no file based metafile support yet") ) ; 
 150     m_metaFile 
= new wxMetaFile(wxEmptyString
) ; 
 151     Rect r
={0,0,1000,1000} ; 
 153     m_metaFile
->SetHMETAFILE( OpenPicture( &r 
) ) ; 
 154     ::GetPort( (GrafPtr
*) &m_macPort 
) ;     
 157     SetMapMode(wxMM_TEXT
);  
 160 // New constructor that takes origin and extent. If you use this, don't 
 161 // give origin/extent arguments to wxMakeMetaFilePlaceable. 
 163 wxMetaFileDC::wxMetaFileDC(const wxString
& file
, int xext
, int yext
, int xorg
, int yorg
) 
 170     wxASSERT_MSG( file
.IsEmpty() , wxT("no file based metafile support yet")) ; 
 172     m_metaFile 
= new wxMetaFile(wxEmptyString
) ; 
 173     Rect r
={yorg
,xorg
,yorg
+yext
,xorg
+xext
} ; 
 175     m_metaFile
->SetHMETAFILE( OpenPicture( &r 
) ) ; 
 176     ::GetPort( (GrafPtr
*) &m_macPort 
) ;     
 179     SetMapMode(wxMM_TEXT
);  
 182 wxMetaFileDC::~wxMetaFileDC() 
 186 wxMetaFile 
*wxMetaFileDC::Close() 
 193 size_t wxMetafileDataObject::GetDataSize() const 
 195     return GetHandleSize( (Handle
) (*((wxMetafile
*)&m_metafile
)).GetHMETAFILE() ) ; 
 198 bool wxMetafileDataObject::GetDataHere(void *buf
) const 
 200     memcpy( buf 
, (*(PicHandle
)(*((wxMetafile
*)&m_metafile
)).GetHMETAFILE()) , 
 201         GetHandleSize( (Handle
) (*((wxMetafile
*)&m_metafile
)).GetHMETAFILE() ) ) ; 
 205 bool wxMetafileDataObject::SetData(size_t len
, const void *buf
) 
 207     Handle handle 
= (Handle
) m_metafile
.GetHMETAFILE() ; 
 208     SetHandleSize( handle 
, len 
) ; 
 209     memcpy( *handle 
, buf 
, len 
) ;