+
+// ----------------------------------------------------------------------------
+// wxBitmapDataObject supports CF_DIB format
+// ----------------------------------------------------------------------------
+
+// TODO: support CF_DIB under Windows CE as well
+
+size_t wxBitmapDataObject::GetDataSize() const
+{
+#if wxUSE_WXDIB && !defined(__WXWINCE__)
+ return wxDIB::ConvertFromBitmap(NULL, GetHbitmapOf(GetBitmap()));
+#else
+ return 0;
+#endif
+}
+
+bool wxBitmapDataObject::GetDataHere(void *buf) const
+{
+#if wxUSE_WXDIB && !defined(__WXWINCE__)
+ BITMAPINFO * const pbi = (BITMAPINFO *)buf;
+
+ return wxDIB::ConvertFromBitmap(pbi, GetHbitmapOf(GetBitmap())) != 0;
+#else
+ wxUnusedVar(buf);
+ return false;
+#endif
+}
+
+bool wxBitmapDataObject::SetData(size_t WXUNUSED(len), const void *buf)
+{
+#if wxUSE_WXDIB && !defined(__WXWINCE__)
+ const BITMAPINFO * const pbmi = (const BITMAPINFO *)buf;
+
+ HBITMAP hbmp = wxDIB::ConvertToBitmap(pbmi);
+
+ wxCHECK_MSG( hbmp, FALSE, wxT("pasting/dropping invalid bitmap") );
+
+ const BITMAPINFOHEADER * const pbmih = &pbmi->bmiHeader;
+ wxBitmap bitmap(pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount);
+ bitmap.SetHBITMAP((WXHBITMAP)hbmp);
+
+ // TODO: create wxPalette if the bitmap has any
+
+ SetBitmap(bitmap);
+
+ return true;
+#else
+ wxUnusedVar(buf);
+ return false;
+#endif
+}
+
+// ----------------------------------------------------------------------------
+// wxBitmapDataObject2 supports CF_BITMAP format
+// ----------------------------------------------------------------------------
+
+// the bitmaps aren't passed by value as other types of data (i.e. by copying
+// the data into a global memory chunk and passing it to the clipboard or
+// another application or whatever), but by handle, so these generic functions
+// don't make much sense to them.
+
+size_t wxBitmapDataObject2::GetDataSize() const
+{
+ return 0;
+}
+
+bool wxBitmapDataObject2::GetDataHere(void *pBuf) const
+{
+ // we put a bitmap handle into pBuf
+ *(WXHBITMAP *)pBuf = GetBitmap().GetHBITMAP();
+
+ return true;
+}
+
+bool wxBitmapDataObject2::SetData(size_t WXUNUSED(len), const void *pBuf)
+{
+ HBITMAP hbmp = *(HBITMAP *)pBuf;
+
+ BITMAP bmp;
+ if ( !GetObject(hbmp, sizeof(BITMAP), &bmp) )
+ {
+ wxLogLastError(wxT("GetObject(HBITMAP)"));
+ }
+
+ wxBitmap bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes);
+ bitmap.SetHBITMAP((WXHBITMAP)hbmp);
+
+ if ( !bitmap.Ok() ) {
+ wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
+
+ return false;
+ }
+
+ SetBitmap(bitmap);
+
+ return true;
+}
+
+#if 0
+
+size_t wxBitmapDataObject::GetDataSize(const wxDataFormat& format) const
+{
+ if ( format.GetFormatId() == CF_DIB )
+ {
+ // create the DIB
+ ScreenHDC hdc;
+
+ // shouldn't be selected into a DC or GetDIBits() would fail
+ wxASSERT_MSG( !m_bitmap.GetSelectedInto(),
+ wxT("can't copy bitmap selected into wxMemoryDC") );
+
+ // first get the info
+ BITMAPINFO bi;
+ if ( !GetDIBits(hdc, (HBITMAP)m_bitmap.GetHBITMAP(), 0, 0,
+ NULL, &bi, DIB_RGB_COLORS) )
+ {
+ wxLogLastError(wxT("GetDIBits(NULL)"));
+
+ return 0;
+ }
+
+ return sizeof(BITMAPINFO) + bi.bmiHeader.biSizeImage;
+ }
+ else // CF_BITMAP
+ {
+ // no data to copy - we don't pass HBITMAP via global memory
+ return 0;
+ }