1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
///////////////////////////////////////////////////////////////////////////////
// Name: wx/palmos/enhmeta.h
// Purpose: wxEnhMetaFile class for PalmOS
// Author: William Osborne - minimal working wxPalmOS port
// Modified by:
// Created: 10/13/04
// RCS-ID: $Id: enhmeta.h 41751 2006-10-08 21:56:55Z VZ $
// Copyright: (c) William Osborne
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PALMOS_ENHMETA_H_
#define _WX_PALMOS_ENHMETA_H_
#include "wx/dc.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dataobj.h"
#endif
// ----------------------------------------------------------------------------
// wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxEnhMetaFile : public wxObject
{
public:
wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file)
{ Init(); }
wxEnhMetaFile(const wxEnhMetaFile& metafile)
{ Init(); Assign(metafile); }
wxEnhMetaFile& operator=(const wxEnhMetaFile& metafile)
{ Free(); Assign(metafile); return *this; }
virtual ~wxEnhMetaFile()
{ Free(); }
// display the picture stored in the metafile on the given DC
bool Play(wxDC *dc, wxRect *rectBound = (wxRect *)NULL);
// accessors
bool Ok() const { return IsOk(); }
bool IsOk() const { return m_hMF != 0; }
wxSize GetSize() const;
int GetWidth() const { return GetSize().x; }
int GetHeight() const { return GetSize().y; }
const wxString& GetFileName() const { return m_filename; }
// copy the metafile to the clipboard: the width and height parameters are
// for backwards compatibility (with wxMetaFile) only, they are ignored by
// this method
bool SetClipboard(int width = 0, int height = 0);
// implementation
WXHANDLE GetHENHMETAFILE() const { return m_hMF; }
void SetHENHMETAFILE(WXHANDLE hMF) { Free(); m_hMF = hMF; }
protected:
void Init() { m_hMF = 0; }
void Free();
void Assign(const wxEnhMetaFile& mf);
private:
wxString m_filename;
WXHANDLE m_hMF;
DECLARE_DYNAMIC_CLASS(wxEnhMetaFile)
};
// ----------------------------------------------------------------------------
// wxEnhMetaFileDC: allows to create a wxEnhMetaFile
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxEnhMetaFileDC : public wxDC
{
public:
// the ctor parameters specify the filename (empty for memory metafiles),
// the metafile picture size and the optional description/comment
wxEnhMetaFileDC(const wxString& filename = wxEmptyString,
int width = 0, int height = 0,
const wxString& description = wxEmptyString);
virtual ~wxEnhMetaFileDC();
// obtain a pointer to the new metafile (caller should delete it)
wxEnhMetaFile *Close();
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC)
};
#if wxUSE_DRAG_AND_DROP
// ----------------------------------------------------------------------------
// wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile
// ----------------------------------------------------------------------------
// notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and
// so we derive from wxDataObject and not from wxDataObjectSimple
class WXDLLEXPORT wxEnhMetaFileDataObject : public wxDataObject
{
public:
// ctors
wxEnhMetaFileDataObject() { }
wxEnhMetaFileDataObject(const wxEnhMetaFile& metafile)
: m_metafile(metafile) { }
// virtual functions which you may override if you want to provide data on
// demand only - otherwise, the trivial default versions will be used
virtual void SetMetafile(const wxEnhMetaFile& metafile)
{ m_metafile = metafile; }
virtual wxEnhMetaFile GetMetafile() const
{ return m_metafile; }
// implement base class pure virtuals
virtual wxDataFormat GetPreferredFormat(Direction dir) const;
virtual size_t GetFormatCount(Direction dir) const;
virtual void GetAllFormats(wxDataFormat *formats, Direction dir) const;
virtual size_t GetDataSize(const wxDataFormat& format) const;
virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
virtual bool SetData(const wxDataFormat& format, size_t len,
const void *buf);
protected:
wxEnhMetaFile m_metafile;
DECLARE_NO_COPY_CLASS(wxEnhMetaFileDataObject)
};
// ----------------------------------------------------------------------------
// wxEnhMetaFileSimpleDataObject does derive from wxDataObjectSimple which
// makes it more convenient to use (it can be used with wxDataObjectComposite)
// at the price of not supoprting any more CF_METAFILEPICT but only
// CF_ENHMETAFILE
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple
{
public:
// ctors
wxEnhMetaFileSimpleDataObject() : wxDataObjectSimple(wxDF_ENHMETAFILE) { }
wxEnhMetaFileSimpleDataObject(const wxEnhMetaFile& metafile)
: wxDataObjectSimple(wxDF_ENHMETAFILE), m_metafile(metafile) { }
// virtual functions which you may override if you want to provide data on
// demand only - otherwise, the trivial default versions will be used
virtual void SetEnhMetafile(const wxEnhMetaFile& metafile)
{ m_metafile = metafile; }
virtual wxEnhMetaFile GetEnhMetafile() const
{ return m_metafile; }
// implement base class pure virtuals
virtual size_t GetDataSize() const;
virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t len, const void *buf);
virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
{ return GetDataSize(); }
virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
void *buf) const
{ return GetDataHere(buf); }
virtual bool SetData(const wxDataFormat& WXUNUSED(format),
size_t len, const void *buf)
{ return SetData(len, buf); }
protected:
wxEnhMetaFile m_metafile;
DECLARE_NO_COPY_CLASS(wxEnhMetaFileSimpleDataObject)
};
#endif // wxUSE_DRAG_AND_DROP
#endif // _WX_PALMOS_ENHMETA_H_
|