1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        wx/msw/enhmeta.h 
   3 // Purpose:     wxEnhMetaFile class for Win32 
   4 // Author:      Vadim Zeitlin 
   8 // Copyright:   (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> 
   9 // Licence:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 #ifndef _WX_MSW_ENHMETA_H_ 
  13 #define _WX_MSW_ENHMETA_H_ 
  16     #pragma interface "enhmeta.h" 
  21 #if wxUSE_DRAG_AND_DROP 
  22     #include "wx/dataobj.h" 
  25 // ---------------------------------------------------------------------------- 
  26 // wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE 
  27 // ---------------------------------------------------------------------------- 
  29 class WXDLLEXPORT wxEnhMetaFile 
: public wxObject
 
  32     wxEnhMetaFile(const wxString
& file 
= wxEmptyString
) : m_filename(file
) 
  34     wxEnhMetaFile(const wxEnhMetaFile
& metafile
) 
  35         { Init(); Assign(metafile
); } 
  36     wxEnhMetaFile
& operator=(const wxEnhMetaFile
& metafile
) 
  37         { Free(); Assign(metafile
); return *this; } 
  39     virtual ~wxEnhMetaFile() 
  42     // display the picture stored in the metafile on the given DC 
  43     bool Play(wxDC 
*dc
, wxRect 
*rectBound 
= (wxRect 
*)NULL
); 
  46     bool Ok() const { return m_hMF 
!= 0; } 
  48     wxSize 
GetSize() const; 
  49     int GetWidth() const { return GetSize().x
; } 
  50     int GetHeight() const { return GetSize().y
; } 
  52     const wxString
& GetFileName() const { return m_filename
; } 
  54     // copy the metafile to the clipboard: the width and height parameters are 
  55     // for backwards compatibility (with wxMetaFile) only, they are ignored by 
  57     bool SetClipboard(int width 
= 0, int height 
= 0); 
  60     WXHANDLE 
GetHENHMETAFILE() const { return m_hMF
; } 
  61     void SetHENHMETAFILE(WXHANDLE hMF
) { Free(); m_hMF 
= hMF
; } 
  64     void Init() { m_hMF 
= 0; } 
  66     void Assign(const wxEnhMetaFile
& mf
); 
  72     DECLARE_DYNAMIC_CLASS(wxEnhMetaFile
) 
  75 // ---------------------------------------------------------------------------- 
  76 // wxEnhMetaFileDC: allows to create a wxEnhMetaFile 
  77 // ---------------------------------------------------------------------------- 
  79 class WXDLLEXPORT wxEnhMetaFileDC 
: public wxDC
 
  82     // the ctor parameters specify the filename (empty for memory metafiles), 
  83     // the metafile picture size and the optional description/comment 
  84     wxEnhMetaFileDC(const wxString
& filename 
= wxEmptyString
, 
  85                     int width 
= 0, int height 
= 0, 
  86                     const wxString
& description 
= wxEmptyString
); 
  88     virtual ~wxEnhMetaFileDC(); 
  90     // obtain a pointer to the new metafile (caller should delete it) 
  91     wxEnhMetaFile 
*Close(); 
  94     DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC
) 
  97 #if wxUSE_DRAG_AND_DROP 
  99 // ---------------------------------------------------------------------------- 
 100 // wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile 
 101 // ---------------------------------------------------------------------------- 
 103 // notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and 
 104 // so we derive from wxDataObject and not from wxDataObjectSimple 
 105 class WXDLLEXPORT wxEnhMetaFileDataObject 
: public wxDataObject
 
 109     wxEnhMetaFileDataObject() { } 
 110     wxEnhMetaFileDataObject(const wxEnhMetaFile
& metafile
) 
 111         : m_metafile(metafile
) { } 
 113     // virtual functions which you may override if you want to provide data on 
 114     // demand only - otherwise, the trivial default versions will be used 
 115     virtual void SetMetafile(const wxEnhMetaFile
& metafile
) 
 116         { m_metafile 
= metafile
; } 
 117     virtual wxEnhMetaFile 
GetMetafile() const 
 118         { return m_metafile
; } 
 120     // implement base class pure virtuals 
 121     virtual wxDataFormat 
GetPreferredFormat(Direction dir
) const; 
 122     virtual size_t GetFormatCount(Direction dir
) const; 
 123     virtual void GetAllFormats(wxDataFormat 
*formats
, Direction dir
) const; 
 124     virtual size_t GetDataSize(const wxDataFormat
& format
) const; 
 125     virtual bool GetDataHere(const wxDataFormat
& format
, void *buf
) const; 
 126     virtual bool SetData(const wxDataFormat
& format
, size_t len
, 
 130     wxEnhMetaFile m_metafile
; 
 132     DECLARE_NO_COPY_CLASS(wxEnhMetaFileDataObject
) 
 136 // ---------------------------------------------------------------------------- 
 137 // wxEnhMetaFileSimpleDataObject does derive from wxDataObjectSimple which 
 138 // makes it more convenient to use (it can be used with wxDataObjectComposite) 
 139 // at the price of not supoprting any more CF_METAFILEPICT but only 
 141 // ---------------------------------------------------------------------------- 
 143 class WXDLLEXPORT wxEnhMetaFileSimpleDataObject 
: public wxDataObjectSimple
 
 147     wxEnhMetaFileSimpleDataObject() : wxDataObjectSimple(wxDF_ENHMETAFILE
) { } 
 148     wxEnhMetaFileSimpleDataObject(const wxEnhMetaFile
& metafile
) 
 149         : wxDataObjectSimple(wxDF_ENHMETAFILE
), m_metafile(metafile
) { } 
 151     // virtual functions which you may override if you want to provide data on 
 152     // demand only - otherwise, the trivial default versions will be used 
 153     virtual void SetEnhMetafile(const wxEnhMetaFile
& metafile
) 
 154         { m_metafile 
= metafile
; } 
 155     virtual wxEnhMetaFile 
GetEnhMetafile() const 
 156         { return m_metafile
; } 
 158     // implement base class pure virtuals 
 159     virtual size_t GetDataSize() const; 
 160     virtual bool GetDataHere(void *buf
) const; 
 161     virtual bool SetData(size_t len
, const void *buf
); 
 164     wxEnhMetaFile m_metafile
; 
 166     DECLARE_NO_COPY_CLASS(wxEnhMetaFileSimpleDataObject
) 
 169 #endif // wxUSE_DRAG_AND_DROP 
 171 #endif // _WX_MSW_ENHMETA_H_