1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-01-06 21:30:29 -05:00
|
|
|
// Name: wx/msw/metafile.h
|
|
|
|
// Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes
|
1998-05-20 10:12:05 -04:00
|
|
|
// Author: Julian Smart
|
2000-01-06 21:30:29 -05:00
|
|
|
// Modified by: VZ 07.01.00: implemented wxMetaFileDataObject
|
1998-05-20 10:12:05 -04:00
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 19:52:45 -04:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 19:52:45 -04:00
|
|
|
#ifndef _WX_METAFIILE_H_
|
|
|
|
#define _WX_METAFIILE_H_
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
#include "wx/dc.h"
|
1999-01-13 13:01:39 -05:00
|
|
|
#include "wx/gdiobj.h"
|
|
|
|
|
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2000-01-06 21:30:29 -05:00
|
|
|
#include "wx/dataobj.h"
|
1999-01-13 13:01:39 -05:00
|
|
|
#endif
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-06 21:30:29 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Metafile and metafile device context classes
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-01-13 13:01:39 -05:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxMetafile;
|
1999-01-13 13:01:39 -05:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
|
1998-05-20 10:12:05 -04:00
|
|
|
{
|
2007-07-09 06:09:52 -04:00
|
|
|
friend class WXDLLIMPEXP_FWD_CORE wxMetafile;
|
1999-01-13 13:01:39 -05:00
|
|
|
public:
|
2000-01-06 21:30:29 -05:00
|
|
|
wxMetafileRefData();
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxMetafileRefData();
|
1999-01-13 13:01:39 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
WXHANDLE m_metafile;
|
|
|
|
int m_windowsMappingMode;
|
2000-01-06 21:30:29 -05:00
|
|
|
int m_width, m_height;
|
1999-01-13 13:01:39 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxMetafile: public wxGDIObject
|
|
|
|
{
|
2000-01-06 21:30:29 -05:00
|
|
|
public:
|
|
|
|
wxMetafile(const wxString& file = wxEmptyString);
|
|
|
|
virtual ~wxMetafile();
|
|
|
|
|
|
|
|
// 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);
|
2006-10-08 17:56:55 -04:00
|
|
|
bool Ok() const { return IsOk(); }
|
|
|
|
bool IsOk() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
|
2000-01-06 21:30:29 -05:00
|
|
|
|
|
|
|
// set/get the size of metafile for clipboard operations
|
2000-01-13 18:39:48 -05:00
|
|
|
wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
|
2000-01-06 21:30:29 -05:00
|
|
|
int GetWidth() const { return M_METAFILEDATA->m_width; }
|
|
|
|
int GetHeight() const { return M_METAFILEDATA->m_height; }
|
|
|
|
|
|
|
|
void SetWidth(int width) { M_METAFILEDATA->m_width = width; }
|
|
|
|
void SetHeight(int height) { M_METAFILEDATA->m_height = height; }
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
WXHANDLE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; }
|
|
|
|
void SetHMETAFILE(WXHANDLE mf) ;
|
|
|
|
int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; }
|
|
|
|
void SetWindowsMappingMode(int mm);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMetafile)
|
1998-05-20 10:12:05 -04:00
|
|
|
};
|
|
|
|
|
1999-01-13 13:01:39 -05:00
|
|
|
class WXDLLEXPORT wxMetafileDC: public wxDC
|
1998-05-20 10:12:05 -04:00
|
|
|
{
|
2000-01-06 21:30:29 -05:00
|
|
|
public:
|
|
|
|
// Don't supply origin and extent
|
|
|
|
// Supply them to wxMakeMetaFilePlaceable instead.
|
2000-01-13 18:39:48 -05:00
|
|
|
wxMetafileDC(const wxString& file = wxEmptyString);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-06 21:30:29 -05:00
|
|
|
// Supply origin and extent (recommended).
|
|
|
|
// Then don't need to supply them to wxMakeMetaFilePlaceable.
|
|
|
|
wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-06 21:30:29 -05:00
|
|
|
virtual ~wxMetafileDC();
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-06 21:30:29 -05:00
|
|
|
// Should be called at end of drawing
|
|
|
|
virtual wxMetafile *Close();
|
|
|
|
virtual void SetMapMode(int mode);
|
2007-05-18 11:02:17 -04:00
|
|
|
virtual void DoGetTextExtent(const wxString& string,
|
|
|
|
wxCoord *x, wxCoord *y,
|
|
|
|
wxCoord *descent = NULL,
|
|
|
|
wxCoord *externalLeading = NULL,
|
|
|
|
const wxFont *theFont = NULL) const;
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-06 21:30:29 -05:00
|
|
|
// 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; }
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
protected:
|
2005-12-25 08:06:05 -05:00
|
|
|
virtual void DoGetSize(int *width, int *height) const;
|
|
|
|
|
2000-01-06 21:30:29 -05:00
|
|
|
int m_windowsMappingMode;
|
|
|
|
wxMetafile* m_metaFile;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMetafileDC)
|
1998-05-20 10:12:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass filename of existing non-placeable metafile, and bounding box.
|
|
|
|
* Adds a placeable metafile header, sets the mapping mode to anisotropic,
|
1999-02-05 18:55:04 -05:00
|
|
|
* and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
|
1998-05-20 10:12:05 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// No origin or extent
|
1999-01-13 13:01:39 -05:00
|
|
|
bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Optional origin and extent
|
2004-08-30 06:18:55 -04:00
|
|
|
bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-01-13 13:01:39 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxMetafileDataObject is a specialization of wxDataObject for metafile data
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2000-01-06 21:30:29 -05:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
|
1999-01-13 13:01:39 -05:00
|
|
|
{
|
|
|
|
public:
|
2000-01-06 21:30:29 -05:00
|
|
|
// ctors
|
|
|
|
wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE)
|
|
|
|
{ }
|
|
|
|
wxMetafileDataObject(const wxMetafile& metafile)
|
|
|
|
: wxDataObjectSimple(wxDF_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 wxMetafile& metafile)
|
|
|
|
{ m_metafile = metafile; }
|
|
|
|
virtual wxMetafile GetMetafile() 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);
|
1999-01-13 13:01:39 -05:00
|
|
|
|
2000-01-06 21:30:29 -05:00
|
|
|
protected:
|
|
|
|
wxMetafile m_metafile;
|
1999-01-13 13:01:39 -05:00
|
|
|
};
|
2000-01-06 21:30:29 -05:00
|
|
|
|
|
|
|
#endif // wxUSE_DRAG_AND_DROP
|
1999-01-13 13:01:39 -05:00
|
|
|
|
1998-05-20 10:12:05 -04:00
|
|
|
#endif
|
1998-08-07 19:52:45 -04:00
|
|
|
// _WX_METAFIILE_H_
|
1999-01-13 13:21:04 -05:00
|
|
|
|