// ----------------------------------------------------------------------------
#ifdef __GNUG__
- #pragma implementation "dataobj.h"
+ #pragma implementation "dataobj.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
- #pragma hdrstop
+ #pragma hdrstop
#endif
+
+#if defined(__WIN32__) && !defined(__GNUWIN32_OLD__)
+
#ifndef WX_PRECOMP
-#include "wx/intl.h"
+ #include "wx/intl.h"
+ #include "wx/log.h"
#endif
-#include "wx/defs.h"
-#if defined(__WIN32__) && !defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS)
-
-#include "wx/log.h"
#include "wx/dataobj.h"
-#include <windows.h>
+#include "wx/msw/private.h" // includes <windows.h>
+
#ifdef wxUSE_NORLANDER_HEADERS
#include <ole2.h>
#endif
#include <shlobj.h>
-#include "wx/msw/ole/oleutils.h"
+#include "wx/msw/ole/oleutils.h"
+
+#include "wx/msw/dib.h"
// ----------------------------------------------------------------------------
// functions
#define GetTymedName(tymed) ""
#endif // Debug/!Debug
-// to be moved into wx/msw/bitmap.h
-extern size_t wxConvertBitmapToDIB(BITMAPINFO *pbi, const wxBitmap& bitmap);
-extern wxBitmap wxConvertDIBToBitmap(const BITMAPINFO *bmi);
-
// ----------------------------------------------------------------------------
// wxIEnumFORMATETC interface implementation
// ----------------------------------------------------------------------------
bool m_mustDelete;
};
-// ----------------------------------------------------------------------------
-// small helper class for getting screen DC (we're working with bitmaps and
-// DIBs here)
-// ----------------------------------------------------------------------------
-
-class ScreenHDC
-{
-public:
- ScreenHDC() { m_hdc = GetDC(NULL); }
- ~ScreenHDC() { ReleaseDC(NULL, m_hdc); }
- operator HDC() const { return m_hdc; }
-
-private:
- HDC m_hdc;
-};
-
// ============================================================================
// implementation
// ============================================================================
break;
case wxDF_METAFILE:
+ pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
+ sizeof(METAFILEPICT));
+ if ( !pmedium->hGlobal ) {
+ wxLogLastError("GlobalAlloc");
+ return E_OUTOFMEMORY;
+ }
pmedium->tymed = TYMED_MFPICT;
break;
hr = GetDataHere(pformatetcIn, pmedium);
if ( FAILED(hr) ) {
// free resources we allocated
- if ( pmedium->tymed == TYMED_HGLOBAL ) {
+ if ( pmedium->tymed & (TYMED_HGLOBAL | TYMED_MFPICT) ) {
GlobalFree(pmedium->hGlobal);
}
break;
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:
{
// copy data
break;
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:
{
wxDataFormat format = pformatetc->cfFormat;
size = 0;
break;
+ case CF_METAFILEPICT:
+ size = sizeof(METAFILEPICT);
+ break;
+
default:
{
// we suppose that the size precedes the data
}
if ( fRelease ) {
- // we own the medium, so we must release it - but do *not* free the
- // bitmap handle fi we have it because we have copied it elsewhere
- if ( pmedium->tymed == TYMED_GDI )
+ // we own the medium, so we must release it - but do *not* free any
+ // data we pass by handle because we have copied it elsewhere
+ switch ( pmedium->tymed )
{
- pmedium->hBitmap = 0;
+ case TYMED_GDI:
+ pmedium->hBitmap = 0;
+ break;
+
+ case TYMED_MFPICT:
+ pmedium->hMetaFilePict = 0;
+ break;
}
ReleaseStgMedium(pmedium);
bool wxBitmapDataObject::GetDataHere(void *buf) const
{
- return wxConvertBitmapToDIB((BITMAPINFO *)buf, GetBitmap()) != 0;
+ return wxConvertBitmapToDIB((LPBITMAPINFO)buf, GetBitmap()) != 0;
}
bool wxBitmapDataObject::SetData(size_t len, const void *buf)
{
- wxBitmap bitmap(wxConvertDIBToBitmap((const BITMAPINFO *)buf));
+ wxBitmap bitmap(wxConvertDIBToBitmap((const LPBITMAPINFO)buf));
if ( !bitmap.Ok() ) {
wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
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;
}
}
-size_t wxConvertBitmapToDIB(BITMAPINFO *pbi, const wxBitmap& bitmap)
+size_t wxConvertBitmapToDIB(LPBITMAPINFO pbi, const wxBitmap& bitmap)
{
wxASSERT_MSG( bitmap.Ok(), wxT("invalid bmp can't be converted to DIB") );
return dwLen + bi.biSizeImage;
}
-wxBitmap wxConvertDIBToBitmap(const BITMAPINFO *pbmi)
+wxBitmap wxConvertDIBToBitmap(const LPBITMAPINFO pbmi)
{
// here we get BITMAPINFO struct followed by the actual bitmap bits and
// BITMAPINFO starts with BITMAPINFOHEADER followed by colour info