1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: metafile.h
|
|
|
|
// Purpose: wxMetaFile, wxMetaFileDC classes.
|
|
|
|
// This probably should be restricted to Windows platforms,
|
|
|
|
// but if there is an equivalent on your platform, great.
|
1999-10-10 22:49:06 -04:00
|
|
|
// Author: David Webster
|
1999-07-29 01:11:30 -04:00
|
|
|
// Modified by:
|
1999-10-10 22:49:06 -04:00
|
|
|
// Created: 10/10/99
|
1999-07-29 01:11:30 -04:00
|
|
|
// RCS-ID: $Id$
|
1999-10-10 22:49:06 -04:00
|
|
|
// Copyright: (c) David Webster
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _WX_METAFIILE_H_
|
|
|
|
#define _WX_METAFIILE_H_
|
|
|
|
|
1999-09-17 17:46:51 -04:00
|
|
|
#include "wx/dc.h"
|
1999-10-10 22:49:06 -04:00
|
|
|
#include "wx/gdiobj.h"
|
2008-01-12 10:05:15 -05:00
|
|
|
#include "wx/os2/dc.h"
|
1999-10-10 22:49:06 -04:00
|
|
|
|
|
|
|
#if wxUSE_DRAG_AND_DROP
|
|
|
|
#include "wx/dataobj.h"
|
|
|
|
#endif
|
1999-07-29 01:11:30 -04:00
|
|
|
|
|
|
|
/*
|
1999-10-10 22:49:06 -04:00
|
|
|
* Metafile and metafile device context classes
|
1999-07-29 01:11:30 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-10-10 22:49:06 -04:00
|
|
|
#define wxMetaFile wxMetafile
|
|
|
|
#define wxMetaFileDC wxMetafileDC
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxMetafile;
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMetafileRefData: public wxGDIRefData
|
1999-10-10 22:49:06 -04:00
|
|
|
{
|
2007-07-09 06:09:52 -04:00
|
|
|
friend class WXDLLIMPEXP_FWD_CORE wxMetafile;
|
1999-10-10 22:49:06 -04:00
|
|
|
public:
|
|
|
|
wxMetafileRefData(void);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxMetafileRefData(void);
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
virtual bool IsOk() const { return m_metafile != 0; }
|
|
|
|
|
1999-10-10 22:49:06 -04:00
|
|
|
public:
|
|
|
|
WXHANDLE m_metafile;
|
|
|
|
int m_windowsMappingMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMetafile: public wxGDIObject
|
1999-07-29 01:11:30 -04:00
|
|
|
{
|
2005-07-26 05:05:27 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxMetafile)
|
|
|
|
public:
|
|
|
|
wxMetafile(const wxString& file = wxEmptyString);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxMetafile(void);
|
2005-07-26 05:05:27 -04:00
|
|
|
|
|
|
|
// After this is called, the metafile cannot be used for anything
|
|
|
|
// since it is now owned by the clipboard.
|
|
|
|
virtual bool SetClipboard(int width = 0, int height = 0);
|
|
|
|
|
|
|
|
virtual bool Play(wxDC *dc);
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
inline WXHANDLE GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; }
|
|
|
|
void SetHMETAFILE(WXHANDLE mf) ;
|
|
|
|
inline int GetWindowsMappingMode(void) { return M_METAFILEDATA->m_windowsMappingMode; }
|
|
|
|
void SetWindowsMappingMode(int mm);
|
2008-01-12 10:05:15 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual wxGDIRefData *CreateGDIRefData() const;
|
|
|
|
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
1999-07-29 01:11:30 -04:00
|
|
|
};
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxPMDCImpl
|
1999-07-29 01:11:30 -04:00
|
|
|
{
|
2008-01-12 10:05:15 -05:00
|
|
|
public:
|
|
|
|
wxMetafileDCImpl(wxDC *owner, const wxString& file = wxEmptyString);
|
|
|
|
wxMetafileDCImpl(wxDC *owner, const wxString& file,
|
|
|
|
int xext, int yext, int xorg, int yorg);
|
|
|
|
virtual ~wxMetafileDCImpl();
|
|
|
|
|
|
|
|
virtual wxMetafile *Close();
|
2009-01-08 09:21:53 -05:00
|
|
|
virtual void SetMapMode(wxMappingMode mode);
|
2008-01-12 10:05:15 -05:00
|
|
|
virtual void DoGetTextExtent(const wxString& string,
|
|
|
|
wxCoord *x, wxCoord *y,
|
|
|
|
wxCoord *descent = NULL,
|
|
|
|
wxCoord *externalLeading = NULL,
|
|
|
|
const wxFont *theFont = NULL) const;
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
wxMetafile *GetMetaFile() const { return m_metaFile; }
|
|
|
|
void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
|
|
|
|
int GetWindowsMappingMode() const { return m_windowsMappingMode; }
|
|
|
|
void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void DoGetSize(int *width, int *height) const;
|
|
|
|
|
|
|
|
int m_windowsMappingMode;
|
|
|
|
wxMetafile* m_metaFile;
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-01-12 10:05:15 -05:00
|
|
|
private:
|
|
|
|
DECLARE_CLASS(wxMetafileDCImpl)
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl);
|
2008-01-12 10:05:15 -05:00
|
|
|
};
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC
|
2008-01-12 10:05:15 -05:00
|
|
|
{
|
2005-07-26 05:05:27 -04:00
|
|
|
public:
|
|
|
|
// Don't supply origin and extent
|
|
|
|
// Supply them to wxMakeMetaFilePlaceable instead.
|
2008-01-12 10:05:15 -05:00
|
|
|
wxMetafileDC(const wxString& file = wxEmptyString)
|
|
|
|
:wxDC(new wxMetafileDCImpl( this, file ))
|
|
|
|
{ }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2005-07-26 05:05:27 -04:00
|
|
|
// Supply origin and extent (recommended).
|
|
|
|
// Then don't need to supply them to wxMakeMetaFilePlaceable.
|
2008-01-12 10:05:15 -05:00
|
|
|
wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
|
2008-08-30 18:01:20 -04:00
|
|
|
: wxDC(new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg ))
|
2008-01-12 10:05:15 -05:00
|
|
|
{ }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-08-30 18:01:20 -04:00
|
|
|
wxMetafile *GetMetafile() const
|
2008-01-12 10:05:15 -05:00
|
|
|
{ return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-01-12 10:05:15 -05:00
|
|
|
virtual ~wxMetafileDC(void)
|
|
|
|
{ delete m_pimpl; }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-01-12 10:05:15 -05:00
|
|
|
// Should be called at end of drawing
|
|
|
|
virtual wxMetafile *Close(void)
|
|
|
|
{ return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2008-01-12 10:05:15 -05:00
|
|
|
inline void SetMetaFile(wxMetafile *mf)
|
|
|
|
{ ((wxMetafileDCImpl*)m_pimpl)->SetMetaFile(mf); }
|
1999-10-10 22:49:06 -04:00
|
|
|
|
|
|
|
private:
|
2008-01-12 10:05:15 -05:00
|
|
|
DECLARE_CLASS(wxMetafileDC)
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxMetafileDC);
|
1999-07-29 01:11:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass filename of existing non-placeable metafile, and bounding box.
|
|
|
|
* Adds a placeable metafile header, sets the mapping mode to anisotropic,
|
|
|
|
* and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// No origin or extent
|
1999-10-10 22:49:06 -04:00
|
|
|
#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
|
2008-03-26 11:06:00 -04:00
|
|
|
bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
|
1999-07-29 01:11:30 -04:00
|
|
|
|
|
|
|
// Optional origin and extent
|
2008-03-26 11:06:00 -04:00
|
|
|
bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable( const wxString& filename
|
2005-07-26 05:05:27 -04:00
|
|
|
,int x1
|
|
|
|
,int y1
|
|
|
|
,int x2
|
|
|
|
,int y2
|
|
|
|
,float scale = 1.0
|
|
|
|
,bool useOriginAndExtent = true
|
|
|
|
);
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-10-10 22:49:06 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxMetafileDataObject is a specialization of wxDataObject for metafile data
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// TODO: implement OLE side of things. At present, it's just for clipboard
|
|
|
|
// use.
|
|
|
|
|
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObject
|
1999-10-10 22:49:06 -04:00
|
|
|
{
|
|
|
|
public:
|
2005-07-26 05:05:27 -04:00
|
|
|
// ctors
|
|
|
|
wxMetafileDataObject() { m_width = 0; m_height = 0; };
|
|
|
|
wxMetafileDataObject(const wxMetafile& metafile, int width = 0,int height = 0)
|
|
|
|
:m_metafile(metafile)
|
|
|
|
,m_width(width)
|
|
|
|
,m_height(height) { }
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2005-07-26 05:05:27 -04:00
|
|
|
void SetMetafile(const wxMetafile& metafile, int w = 0, int h = 0)
|
|
|
|
{ m_metafile = metafile; m_width = w; m_height = h; }
|
|
|
|
wxMetafile GetMetafile() const { return m_metafile; }
|
|
|
|
int GetWidth() const { return m_width; }
|
|
|
|
int GetHeight() const { return m_height; }
|
1999-10-10 22:49:06 -04:00
|
|
|
|
2005-07-26 05:05:27 -04:00
|
|
|
virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
|
1999-10-10 22:49:06 -04:00
|
|
|
|
|
|
|
/* ??
|
2005-07-26 05:05:27 -04:00
|
|
|
// implement base class pure virtuals
|
|
|
|
virtual wxDataFormat GetPreferredFormat() const
|
|
|
|
{ return (wxDataFormat) wxDataObject::Text; }
|
|
|
|
virtual bool IsSupportedFormat(wxDataFormat format) const
|
|
|
|
{ return format == wxDataObject::Text || format == wxDataObject::Locale; }
|
|
|
|
virtual size_t GetDataSize() const
|
|
|
|
{ return m_strText.Len() + 1; } // +1 for trailing '\0'of course
|
|
|
|
virtual void GetDataHere(void *pBuf) const
|
|
|
|
{ memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
|
1999-10-10 22:49:06 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
private:
|
2005-07-26 05:05:27 -04:00
|
|
|
wxMetafile m_metafile;
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
1999-10-10 22:49:06 -04:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1999-07-29 01:11:30 -04:00
|
|
|
#endif
|
|
|
|
// _WX_METAFIILE_H_
|