+wxDropTarget::wxDropTarget (
+ wxDataObject* pDataObject
+)
+{
+ m_dataObject = pDataObject;
+ m_pDropTarget = new CIDropTarget(this);
+} // end of wxDropTarget::wxDropTarget
+
+wxDropTarget::~wxDropTarget()
+{
+ Release();
+} // end of wxDropTarget::~wxDropTarget
+
+bool wxDropTarget::GetData ()
+{
+ wxDataFormat vFormat = GetSupportedFormat(m_pDropTarget->GetDataSource());
+
+ if (vFormat == wxDF_INVALID)
+ {
+ return FALSE;
+ }
+ //
+ // Under OS/2 we already have the data via the attached DRAGITEM's
+ //
+ return TRUE;
+} // end of wxDropTarget::GetData
+
+wxDataFormat wxDropTarget::GetSupportedFormat (
+ PDRAGINFO pDataSource
+) const
+{
+ PDRAGITEM pDragItem;
+ wxDataFormat vFormat;
+ wxDataFormat* pFormats;
+ ULONG ulFormats = m_dataObject->GetFormatCount(wxDataObject::Set);
+ ULONG ulItems = (ULONG)::DrgQueryDragitemCount(pDataSource);
+ ULONG i;
+ ULONG n;
+ wxString sMechanism;
+ wxString sFormat;
+ bool bValid = FALSE;
+
+ pFormats = ulFormats == 1 ? &vFormat : new wxDataFormat[ulFormats];
+ m_dataObject->GetAllFormats( pFormats
+ ,wxDataObject::Set
+ );
+
+ for (n = 0; n < ulFormats; n++)
+ {
+ switch(pFormats[n].GetType())
+ {
+ case wxDF_TEXT:
+ case wxDF_FILENAME:
+ case wxDF_HTML:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_TEXT";
+ break;
+
+ case wxDF_OEMTEXT:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_OEMTEXT";
+ break;
+
+ case wxDF_BITMAP:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_BITMAP";
+ break;
+
+ case wxDF_METAFILE:
+ case wxDF_ENHMETAFILE:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_METAFILE";
+ break;
+
+ case wxDF_TIFF:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_TIFF";
+ break;
+
+ case wxDF_SYLK:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_SYLK";
+ break;
+
+ case wxDF_DIF:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_DIF";
+ break;
+
+ case wxDF_DIB:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_DIB";
+ break;
+
+ case wxDF_PALETTE:
+ case wxDF_PENDATA:
+ case wxDF_RIFF:
+ case wxDF_WAVE:
+ case wxDF_UNICODETEXT:
+ case wxDF_LOCALE:
+ sMechanism = "DRM_OS2FILE";
+ sFormat = "DRF_UNKNOWN";
+ break;
+
+ case wxDF_PRIVATE:
+ sMechanism = "DRM_OBJECT";
+ sFormat = "DRF_UNKNOWN";
+ break;
+ }
+ for (i = 0; i < ulItems; i++)
+ {
+ pDragItem = ::DrgQueryDragitemPtr(pDataSource, i);
+ if (::DrgVerifyRMF(pDragItem, sMechanism.c_str(), sFormat.c_str()))
+ {
+ bValid = TRUE;
+ break;
+ }
+ }
+ if (bValid)
+ {
+ vFormat = pFormats[n];
+ break;
+ }
+ }
+ if (pFormats != &vFormat)
+ {
+ //
+ // Free memory if we allocated it
+ //
+ delete [] pFormats;
+ }
+ return (n < ulFormats ? vFormat : wxFormatInvalid);
+} // end of wxDropTarget::GetSupportedFormat
+
+bool wxDropTarget::IsAcceptedData (
+ PDRAGINFO pDataSource
+) const