attempts at providing clipboard/dnd support for metafiles - unsuccessful
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5283 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,39 +1,42 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: metafile.h
|
// Name: wx/msw/metafile.h
|
||||||
// Purpose: wxMetaFile, wxMetaFileDC classes
|
// Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by: VZ 07.01.00: implemented wxMetaFileDataObject
|
||||||
// Created: 01/02/97
|
// Created: 01/02/97
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WX_METAFIILE_H_
|
#ifndef _WX_METAFIILE_H_
|
||||||
#define _WX_METAFIILE_H_
|
#define _WX_METAFIILE_H_
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "metafile.h"
|
#pragma interface "metafile.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
|
|
||||||
#if wxUSE_METAFILE
|
#if wxUSE_METAFILE
|
||||||
|
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/gdiobj.h"
|
#include "wx/gdiobj.h"
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
#include "wx/dataobj.h"
|
#include "wx/dataobj.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
// provide synonyms for all metafile classes
|
||||||
* Metafile and metafile device context classes
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define wxMetaFile wxMetafile
|
#define wxMetaFile wxMetafile
|
||||||
#define wxMetaFileDC wxMetafileDC
|
#define wxMetaFileDC wxMetafileDC
|
||||||
|
#define wxMetaFileDataObject wxMetafileDataObject
|
||||||
|
|
||||||
|
#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Metafile and metafile device context classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxMetafile;
|
class WXDLLEXPORT wxMetafile;
|
||||||
|
|
||||||
@@ -41,53 +44,59 @@ class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
|
|||||||
{
|
{
|
||||||
friend class WXDLLEXPORT wxMetafile;
|
friend class WXDLLEXPORT wxMetafile;
|
||||||
public:
|
public:
|
||||||
wxMetafileRefData(void);
|
wxMetafileRefData();
|
||||||
~wxMetafileRefData(void);
|
~wxMetafileRefData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WXHANDLE m_metafile;
|
WXHANDLE m_metafile;
|
||||||
int m_windowsMappingMode;
|
int m_windowsMappingMode;
|
||||||
|
int m_width, m_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
|
#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
|
||||||
|
|
||||||
class WXDLLEXPORT wxMetafile: public wxGDIObject
|
class WXDLLEXPORT wxMetafile: public wxGDIObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMetafile)
|
public:
|
||||||
public:
|
wxMetafile(const wxString& file = wxEmptyString);
|
||||||
// Copy constructor
|
wxMetafile(const wxMetafile& metafile) { Ref(metafile); }
|
||||||
inline wxMetafile(const wxMetafile& metafile)
|
virtual ~wxMetafile();
|
||||||
{ Ref(metafile); }
|
|
||||||
|
|
||||||
wxMetafile(const wxString& file = "");
|
|
||||||
~wxMetafile(void);
|
|
||||||
|
|
||||||
// After this is called, the metafile cannot be used for anything
|
// After this is called, the metafile cannot be used for anything
|
||||||
// since it is now owned by the clipboard.
|
// since it is now owned by the clipboard.
|
||||||
virtual bool SetClipboard(int width = 0, int height = 0);
|
virtual bool SetClipboard(int width = 0, int height = 0);
|
||||||
|
|
||||||
virtual bool Play(wxDC *dc);
|
virtual bool Play(wxDC *dc);
|
||||||
inline bool Ok(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
|
bool Ok() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
|
||||||
|
|
||||||
|
// set/get the size of metafile for clipboard operations
|
||||||
|
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
|
// Implementation
|
||||||
inline WXHANDLE GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; }
|
WXHANDLE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; }
|
||||||
void SetHMETAFILE(WXHANDLE mf) ;
|
void SetHMETAFILE(WXHANDLE mf) ;
|
||||||
inline int GetWindowsMappingMode(void) { return M_METAFILEDATA->m_windowsMappingMode; }
|
int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; }
|
||||||
void SetWindowsMappingMode(int mm);
|
void SetWindowsMappingMode(int mm);
|
||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
inline wxMetafile& operator = (const wxMetafile& metafile) { if (*this == metafile) return (*this); Ref(metafile); return *this; }
|
wxMetafile& operator=(const wxMetafile& metafile)
|
||||||
inline bool operator == (const wxMetafile& metafile) { return m_refData == metafile.m_refData; }
|
{ if (*this != metafile) Ref(metafile); return *this; }
|
||||||
inline bool operator != (const wxMetafile& metafile) { return m_refData != metafile.m_refData; }
|
bool operator==(const wxMetafile& metafile) const
|
||||||
|
{ return m_refData == metafile.m_refData; }
|
||||||
|
bool operator!=(const wxMetafile& metafile) const
|
||||||
|
{ return m_refData != metafile.m_refData; }
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxMetafile)
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxMetafileDC: public wxDC
|
class WXDLLEXPORT wxMetafileDC: public wxDC
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMetafileDC)
|
public:
|
||||||
|
|
||||||
public:
|
|
||||||
// Don't supply origin and extent
|
// Don't supply origin and extent
|
||||||
// Supply them to wxMakeMetaFilePlaceable instead.
|
// Supply them to wxMakeMetaFilePlaceable instead.
|
||||||
wxMetafileDC(const wxString& file = "");
|
wxMetafileDC(const wxString& file = "");
|
||||||
@@ -96,24 +105,27 @@ class WXDLLEXPORT wxMetafileDC: public wxDC
|
|||||||
// Then don't need to supply them to wxMakeMetaFilePlaceable.
|
// Then don't need to supply them to wxMakeMetaFilePlaceable.
|
||||||
wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
|
wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
|
||||||
|
|
||||||
~wxMetafileDC(void);
|
virtual ~wxMetafileDC();
|
||||||
|
|
||||||
// Should be called at end of drawing
|
// Should be called at end of drawing
|
||||||
virtual wxMetafile *Close(void);
|
virtual wxMetafile *Close();
|
||||||
virtual void SetMapMode(int mode);
|
virtual void SetMapMode(int mode);
|
||||||
virtual void GetTextExtent(const wxString& string, long *x, long *y,
|
virtual void GetTextExtent(const wxString& string, long *x, long *y,
|
||||||
long *descent = NULL, long *externalLeading = NULL,
|
long *descent = NULL, long *externalLeading = NULL,
|
||||||
wxFont *theFont = NULL, bool use16bit = FALSE) const;
|
wxFont *theFont = NULL, bool use16bit = FALSE) const;
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
|
wxMetafile *GetMetaFile() const { return m_metaFile; }
|
||||||
inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
|
void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
|
||||||
inline int GetWindowsMappingMode(void) const { return m_windowsMappingMode; }
|
int GetWindowsMappingMode() const { return m_windowsMappingMode; }
|
||||||
inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
|
void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_windowsMappingMode;
|
int m_windowsMappingMode;
|
||||||
wxMetafile* m_metaFile;
|
wxMetafile* m_metaFile;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxMetafileDC)
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -124,7 +136,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// No origin or extent
|
// No origin or extent
|
||||||
#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
|
|
||||||
bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
|
bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
|
||||||
|
|
||||||
// Optional origin and extent
|
// Optional origin and extent
|
||||||
@@ -134,44 +145,34 @@ bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y
|
|||||||
// wxMetafileDataObject is a specialization of wxDataObject for metafile data
|
// 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
|
#if wxUSE_DRAG_AND_DROP
|
||||||
class WXDLLEXPORT wxMetafileDataObject : public wxDataObject
|
|
||||||
|
class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctors
|
// ctors
|
||||||
wxMetafileDataObject() { m_width = 0; m_height = 0; };
|
wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE)
|
||||||
wxMetafileDataObject(const wxMetafile& metafile, int width = 0, int height = 0):
|
{ }
|
||||||
m_metafile(metafile), m_width(width), m_height(height) { }
|
wxMetafileDataObject(const wxMetafile& metafile)
|
||||||
|
: wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
|
||||||
|
|
||||||
void SetMetafile(const wxMetafile& metafile, int w = 0, int h = 0)
|
// virtual functions which you may override if you want to provide data on
|
||||||
{ m_metafile = metafile; m_width = w; m_height = h; }
|
// demand only - otherwise, the trivial default versions will be used
|
||||||
wxMetafile GetMetafile() const { return m_metafile; }
|
virtual void SetMetafile(const wxMetafile& metafile)
|
||||||
int GetWidth() const { return m_width; }
|
{ m_metafile = metafile; }
|
||||||
int GetHeight() const { return m_height; }
|
virtual wxMetafile GetMetafile() const
|
||||||
|
{ return m_metafile; }
|
||||||
|
|
||||||
virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
|
|
||||||
|
|
||||||
/* ??
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual wxDataFormat GetPreferredFormat() const
|
virtual size_t GetDataSize() const;
|
||||||
{ return (wxDataFormat) wxDataObject::Text; }
|
virtual bool GetDataHere(void *buf) const;
|
||||||
virtual bool IsSupportedFormat(wxDataFormat format) const
|
virtual bool SetData(size_t len, const void *buf);
|
||||||
{ 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()); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
wxMetafile m_metafile;
|
wxMetafile m_metafile;
|
||||||
int m_width;
|
|
||||||
int m_height;
|
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
#endif // wxUSE_METAFILE
|
#endif // wxUSE_METAFILE
|
||||||
#endif
|
#endif
|
||||||
|
@@ -670,7 +670,6 @@ bool wxClipboard::GetData( wxDataObject& data )
|
|||||||
formatEtc.ptd = NULL;
|
formatEtc.ptd = NULL;
|
||||||
formatEtc.dwAspect = DVASPECT_CONTENT;
|
formatEtc.dwAspect = DVASPECT_CONTENT;
|
||||||
formatEtc.lindex = -1;
|
formatEtc.lindex = -1;
|
||||||
formatEtc.tymed = TYMED_HGLOBAL;
|
|
||||||
|
|
||||||
size_t nSupportedFormats = supportedFormats.GetCount();
|
size_t nSupportedFormats = supportedFormats.GetCount();
|
||||||
for ( size_t n = 0; !result && (n < nSupportedFormats); n++ )
|
for ( size_t n = 0; !result && (n < nSupportedFormats); n++ )
|
||||||
@@ -678,6 +677,21 @@ bool wxClipboard::GetData( wxDataObject& data )
|
|||||||
STGMEDIUM medium;
|
STGMEDIUM medium;
|
||||||
formatEtc.cfFormat = supportedFormats[n];
|
formatEtc.cfFormat = supportedFormats[n];
|
||||||
|
|
||||||
|
// use the appropriate tymed
|
||||||
|
switch ( formatEtc.cfFormat )
|
||||||
|
{
|
||||||
|
case CF_BITMAP:
|
||||||
|
formatEtc.tymed = TYMED_GDI;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CF_METAFILEPICT:
|
||||||
|
formatEtc.tymed = TYMED_MFPICT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
formatEtc.tymed = TYMED_HGLOBAL;
|
||||||
|
}
|
||||||
|
|
||||||
// try to get data
|
// try to get data
|
||||||
hr = pDataObject->GetData(&formatEtc, &medium);
|
hr = pDataObject->GetData(&formatEtc, &medium);
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
|
@@ -1,34 +1,42 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: metafile.cpp
|
// Name: msw/metafile.cpp
|
||||||
// Purpose: wxMetafileDC etc.
|
// Purpose: wxMetafileDC etc.
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by: VZ 07.01.00: implemented wxMetaFileDataObject
|
||||||
// Created: 04/01/98
|
// Created: 04/01/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
// Copyright: (c) Julian Smart and Markus Holzem
|
||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "metafile.h"
|
#pragma implementation "metafile.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_METAFILE
|
#if wxUSE_METAFILE
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/metafile.h"
|
#include "wx/metafile.h"
|
||||||
@@ -38,24 +46,35 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern bool wxClipboardIsOpen;
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxWin macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
|
IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxMetafileRefData
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Metafiles
|
* Metafiles
|
||||||
* Currently, the only purpose for making a metafile is to put
|
* Currently, the only purpose for making a metafile is to put
|
||||||
* it on the clipboard.
|
* it on the clipboard.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wxMetafileRefData::wxMetafileRefData(void)
|
wxMetafileRefData::wxMetafileRefData()
|
||||||
{
|
{
|
||||||
m_metafile = 0;
|
m_metafile = 0;
|
||||||
m_windowsMappingMode = wxMM_ANISOTROPIC;
|
m_windowsMappingMode = wxMM_ANISOTROPIC;
|
||||||
|
m_width = m_height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMetafileRefData::~wxMetafileRefData(void)
|
wxMetafileRefData::~wxMetafileRefData()
|
||||||
{
|
{
|
||||||
if (m_metafile)
|
if (m_metafile)
|
||||||
{
|
{
|
||||||
@@ -64,6 +83,10 @@ wxMetafileRefData::~wxMetafileRefData(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxMetafile
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxMetafile::wxMetafile(const wxString& file)
|
wxMetafile::wxMetafile(const wxString& file)
|
||||||
{
|
{
|
||||||
m_refData = new wxMetafileRefData;
|
m_refData = new wxMetafileRefData;
|
||||||
@@ -74,7 +97,7 @@ wxMetafile::wxMetafile(const wxString& file)
|
|||||||
M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
|
M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMetafile::~wxMetafile(void)
|
wxMetafile::~wxMetafile()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,15 +106,18 @@ bool wxMetafile::SetClipboard(int width, int height)
|
|||||||
if (!m_refData)
|
if (!m_refData)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
bool alreadyOpen=wxClipboardOpen();
|
bool alreadyOpen = wxClipboardOpen();
|
||||||
if (!alreadyOpen)
|
if (!alreadyOpen)
|
||||||
{
|
{
|
||||||
wxOpenClipboard();
|
wxOpenClipboard();
|
||||||
if (!wxEmptyClipboard()) return FALSE;
|
if (!wxEmptyClipboard())
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
|
bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
|
||||||
if (!alreadyOpen) wxCloseClipboard();
|
if (!alreadyOpen)
|
||||||
return (bool) success;
|
wxCloseClipboard();
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMetafile::Play(wxDC *dc)
|
bool wxMetafile::Play(wxDC *dc)
|
||||||
@@ -102,7 +128,7 @@ bool wxMetafile::Play(wxDC *dc)
|
|||||||
dc->BeginDrawing();
|
dc->BeginDrawing();
|
||||||
|
|
||||||
if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
|
if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
|
||||||
PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile);
|
PlayMetaFile(GetHdcOf(*dc), (HMETAFILE) M_METAFILEDATA->m_metafile);
|
||||||
|
|
||||||
dc->EndDrawing();
|
dc->EndDrawing();
|
||||||
|
|
||||||
@@ -111,7 +137,7 @@ bool wxMetafile::Play(wxDC *dc)
|
|||||||
|
|
||||||
void wxMetafile::SetHMETAFILE(WXHANDLE mf)
|
void wxMetafile::SetHMETAFILE(WXHANDLE mf)
|
||||||
{
|
{
|
||||||
if (m_refData)
|
if (!m_refData)
|
||||||
m_refData = new wxMetafileRefData;
|
m_refData = new wxMetafileRefData;
|
||||||
|
|
||||||
M_METAFILEDATA->m_metafile = mf;
|
M_METAFILEDATA->m_metafile = mf;
|
||||||
@@ -119,16 +145,15 @@ void wxMetafile::SetHMETAFILE(WXHANDLE mf)
|
|||||||
|
|
||||||
void wxMetafile::SetWindowsMappingMode(int mm)
|
void wxMetafile::SetWindowsMappingMode(int mm)
|
||||||
{
|
{
|
||||||
if (m_refData)
|
if (!m_refData)
|
||||||
m_refData = new wxMetafileRefData;
|
m_refData = new wxMetafileRefData;
|
||||||
|
|
||||||
M_METAFILEDATA->m_windowsMappingMode = mm;
|
M_METAFILEDATA->m_windowsMappingMode = mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// ----------------------------------------------------------------------------
|
||||||
* Metafile device context
|
// Metafile device context
|
||||||
*
|
// ----------------------------------------------------------------------------
|
||||||
*/
|
|
||||||
|
|
||||||
// Original constructor that does not takes origin and extent. If you use this,
|
// Original constructor that does not takes origin and extent. If you use this,
|
||||||
// *DO* give origin/extent arguments to wxMakeMetafilePlaceable.
|
// *DO* give origin/extent arguments to wxMakeMetafilePlaceable.
|
||||||
@@ -139,7 +164,7 @@ wxMetafileDC::wxMetafileDC(const wxString& file)
|
|||||||
m_minY = 10000;
|
m_minY = 10000;
|
||||||
m_maxX = -10000;
|
m_maxX = -10000;
|
||||||
m_maxY = -10000;
|
m_maxY = -10000;
|
||||||
// m_title = NULL;
|
// m_title = NULL;
|
||||||
|
|
||||||
if (!file.IsNull() && wxFileExists(file))
|
if (!file.IsNull() && wxFileExists(file))
|
||||||
wxRemoveFile(file);
|
wxRemoveFile(file);
|
||||||
@@ -165,7 +190,8 @@ wxMetafileDC::wxMetafileDC(const wxString& file, int xext, int yext, int xorg, i
|
|||||||
m_minY = 10000;
|
m_minY = 10000;
|
||||||
m_maxX = -10000;
|
m_maxX = -10000;
|
||||||
m_maxY = -10000;
|
m_maxY = -10000;
|
||||||
if (file != wxT("") && wxFileExists(file)) wxRemoveFile(file);
|
if ( !!file && wxFileExists(file))
|
||||||
|
wxRemoveFile(file);
|
||||||
m_hDC = (WXHDC) CreateMetaFile(file);
|
m_hDC = (WXHDC) CreateMetaFile(file);
|
||||||
|
|
||||||
m_ok = TRUE;
|
m_ok = TRUE;
|
||||||
@@ -179,7 +205,7 @@ wxMetafileDC::wxMetafileDC(const wxString& file, int xext, int yext, int xorg, i
|
|||||||
SetMapMode(wxMM_TEXT); // NOTE: does not set HDC mapmode (this is correct)
|
SetMapMode(wxMM_TEXT); // NOTE: does not set HDC mapmode (this is correct)
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMetafileDC::~wxMetafileDC(void)
|
wxMetafileDC::~wxMetafileDC()
|
||||||
{
|
{
|
||||||
m_hDC = 0;
|
m_hDC = 0;
|
||||||
}
|
}
|
||||||
@@ -210,7 +236,7 @@ void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
|
|||||||
*externalLeading = tm.tmExternalLeading;
|
*externalLeading = tm.tmExternalLeading;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMetafile *wxMetafileDC::Close(void)
|
wxMetafile *wxMetafileDC::Close()
|
||||||
{
|
{
|
||||||
SelectOldObjects(m_hDC);
|
SelectOldObjects(m_hDC);
|
||||||
HANDLE mf = CloseMetaFile((HDC) m_hDC);
|
HANDLE mf = CloseMetaFile((HDC) m_hDC);
|
||||||
@@ -229,10 +255,10 @@ void wxMetafileDC::SetMapMode(int mode)
|
|||||||
{
|
{
|
||||||
m_mappingMode = mode;
|
m_mappingMode = mode;
|
||||||
|
|
||||||
// int pixel_width = 0;
|
// int pixel_width = 0;
|
||||||
// int pixel_height = 0;
|
// int pixel_height = 0;
|
||||||
// int mm_width = 0;
|
// int mm_width = 0;
|
||||||
// int mm_height = 0;
|
// int mm_height = 0;
|
||||||
|
|
||||||
float mm2pixelsX = 10.0;
|
float mm2pixelsX = 10.0;
|
||||||
float mm2pixelsY = 10.0;
|
float mm2pixelsY = 10.0;
|
||||||
@@ -275,6 +301,10 @@ void wxMetafileDC::SetMapMode(int mode)
|
|||||||
m_windowExtY = 100;
|
m_windowExtY = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxMakeMetafilePlaceable
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
struct RECT32
|
struct RECT32
|
||||||
{
|
{
|
||||||
@@ -413,5 +443,45 @@ bool wxMakeMetafilePlaceable(const wxString& filename, int x1, int y1, int x2, i
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxMetafileDataObject
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
size_t wxMetafileDataObject::GetDataSize() const
|
||||||
|
{
|
||||||
|
return sizeof(METAFILEPICT);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxMetafileDataObject::GetDataHere(void *buf) const
|
||||||
|
{
|
||||||
|
METAFILEPICT *mfpict = (METAFILEPICT *)buf;
|
||||||
|
const wxMetafile mf = GetMetafile();
|
||||||
|
mfpict->mm = mf.GetWindowsMappingMode();
|
||||||
|
mfpict->xExt = mf.GetWidth();
|
||||||
|
mfpict->yExt = mf.GetHeight();
|
||||||
|
mfpict->hMF = (HMETAFILE)mf.GetHMETAFILE();
|
||||||
|
|
||||||
|
wxCHECK_MSG( mfpict->hMF, FALSE, _T("copying invalid metafile") );
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxMetafileDataObject::SetData(size_t WXUNUSED(len), const void *buf)
|
||||||
|
{
|
||||||
|
const METAFILEPICT *mfpict = (const METAFILEPICT *)buf;
|
||||||
|
|
||||||
|
wxMetafile mf;
|
||||||
|
mf.SetWindowsMappingMode(mfpict->mm);
|
||||||
|
mf.SetWidth(mfpict->xExt);
|
||||||
|
mf.SetHeight(mfpict->yExt);
|
||||||
|
mf.SetHMETAFILE((WXHANDLE)mfpict->hMF);
|
||||||
|
|
||||||
|
wxCHECK_MSG( mfpict->hMF, FALSE, _T("pasting invalid metafile") );
|
||||||
|
|
||||||
|
SetMetafile(mf);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_METAFILE
|
#endif // wxUSE_METAFILE
|
||||||
|
|
||||||
|
@@ -298,6 +298,12 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case wxDF_METAFILE:
|
case wxDF_METAFILE:
|
||||||
|
pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
|
||||||
|
sizeof(METAFILEPICT));
|
||||||
|
if ( !pmedium->hGlobal ) {
|
||||||
|
wxLogLastError("GlobalAlloc");
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
pmedium->tymed = TYMED_MFPICT;
|
pmedium->tymed = TYMED_MFPICT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -334,7 +340,7 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
|
|||||||
hr = GetDataHere(pformatetcIn, pmedium);
|
hr = GetDataHere(pformatetcIn, pmedium);
|
||||||
if ( FAILED(hr) ) {
|
if ( FAILED(hr) ) {
|
||||||
// free resources we allocated
|
// free resources we allocated
|
||||||
if ( pmedium->tymed == TYMED_HGLOBAL ) {
|
if ( pmedium->tymed & (TYMED_HGLOBAL | TYMED_MFPICT) ) {
|
||||||
GlobalFree(pmedium->hGlobal);
|
GlobalFree(pmedium->hGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,11 +364,6 @@ STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TYMED_MFPICT:
|
case TYMED_MFPICT:
|
||||||
// this should be copied on bitmaps - but I don't have time for
|
|
||||||
// this now
|
|
||||||
wxFAIL_MSG(wxT("TODO - no support for metafiles in wxDataObject"));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYMED_HGLOBAL:
|
case TYMED_HGLOBAL:
|
||||||
{
|
{
|
||||||
// copy data
|
// copy data
|
||||||
@@ -409,11 +410,6 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TYMED_MFPICT:
|
case TYMED_MFPICT:
|
||||||
// this should be copied on bitmaps - but I don't have time for
|
|
||||||
// this now
|
|
||||||
wxFAIL_MSG(wxT("TODO - no support for metafiles in wxDataObject"));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYMED_HGLOBAL:
|
case TYMED_HGLOBAL:
|
||||||
{
|
{
|
||||||
wxDataFormat format = pformatetc->cfFormat;
|
wxDataFormat format = pformatetc->cfFormat;
|
||||||
@@ -467,6 +463,10 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
|
|||||||
size = 0;
|
size = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CF_METAFILEPICT:
|
||||||
|
size = sizeof(METAFILEPICT);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// we suppose that the size precedes the data
|
// we suppose that the size precedes the data
|
||||||
@@ -491,11 +491,17 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( fRelease ) {
|
if ( fRelease ) {
|
||||||
// we own the medium, so we must release it - but do *not* free the
|
// we own the medium, so we must release it - but do *not* free any
|
||||||
// bitmap handle fi we have it because we have copied it elsewhere
|
// data we pass by handle because we have copied it elsewhere
|
||||||
if ( pmedium->tymed == TYMED_GDI )
|
switch ( pmedium->tymed )
|
||||||
{
|
{
|
||||||
|
case TYMED_GDI:
|
||||||
pmedium->hBitmap = 0;
|
pmedium->hBitmap = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYMED_MFPICT:
|
||||||
|
pmedium->hMetaFilePict = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseStgMedium(pmedium);
|
ReleaseStgMedium(pmedium);
|
||||||
@@ -759,7 +765,7 @@ bool wxBitmapDataObject2::GetDataHere(void *pBuf) const
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapDataObject2::SetData(size_t len, const void *pBuf)
|
bool wxBitmapDataObject2::SetData(size_t WXUNUSED(len), const void *pBuf)
|
||||||
{
|
{
|
||||||
HBITMAP hbmp = *(HBITMAP *)pBuf;
|
HBITMAP hbmp = *(HBITMAP *)pBuf;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user