X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7dab9892b3ad296d3d3664576f1d590f5fddf6bc..60372b0d54379701d62edf5595a7dc25c48330e1:/src/osx/dnd_osx.cpp diff --git a/src/osx/dnd_osx.cpp b/src/osx/dnd_osx.cpp index c19bf6eb8f..351d2b4007 100644 --- a/src/osx/dnd_osx.cpp +++ b/src/osx/dnd_osx.cpp @@ -4,7 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id: dnd.cpp 61724 2009-08-21 10:41:26Z VZ $ +// RCS-ID: $Id$ // Copyright: (c) 1998 Stefan Csomor // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -36,7 +36,7 @@ wxDragResult wxDropTarget::OnDragOver( wxDataFormat wxDropTarget::GetMatchingPair() { - wxFAIL_MSG("wxDropTarget::GetMatchingPair() not implemented in src/osx/carbon/dnd.cpp"); + wxFAIL_MSG("wxDropTarget::GetMatchingPair() not implemented in src/osx/dnd_osx.cpp"); return wxDF_INVALID; } @@ -61,6 +61,95 @@ wxDragResult wxDropTarget::OnData( return GetData() ? def : wxDragNone; } +bool wxDropTarget::CurrentDragHasSupportedFormat() +{ + bool supported = false; + if (m_dataObject == NULL) + return false; + + if ( wxDropSource* currentSource = wxDropSource::GetCurrentDropSource() ) + { + wxDataObject* data = currentSource->GetDataObject(); + + if ( data ) + { + size_t formatcount = data->GetFormatCount(); + wxDataFormat *array = new wxDataFormat[formatcount]; + data->GetAllFormats( array ); + for (size_t i = 0; !supported && i < formatcount; i++) + { + wxDataFormat format = array[i]; + if ( m_dataObject->IsSupported( format, wxDataObject::Set ) ) + { + supported = true; + break; + } + } + + delete [] array; + } + } + + if ( !supported ) + { + supported = m_dataObject->HasDataInPasteboard( m_currentDragPasteboard ); + } + + return supported; +} + +bool wxDropTarget::GetData() +{ + if (m_dataObject == NULL) + return false; + + if ( !CurrentDragHasSupportedFormat() ) + return false; + + bool transferred = false; + if ( wxDropSource* currentSource = wxDropSource::GetCurrentDropSource() ) + { + wxDataObject* data = currentSource->GetDataObject(); + + if (data != NULL) + { + size_t formatcount = data->GetFormatCount(); + wxDataFormat *array = new wxDataFormat[formatcount]; + data->GetAllFormats( array ); + for (size_t i = 0; !transferred && i < formatcount; i++) + { + wxDataFormat format = array[i]; + if ( m_dataObject->IsSupported( format, wxDataObject::Set ) ) + { + int size = data->GetDataSize( format ); + transferred = true; + + if (size == 0) + { + m_dataObject->SetData( format, 0, 0 ); + } + else + { + char *d = new char[size]; + data->GetDataHere( format, (void*)d ); + m_dataObject->SetData( format, size, d ); + delete [] d; + } + } + } + + delete [] array; + } + } + + if ( !transferred ) + { + transferred = m_dataObject->GetFromPasteboard( m_currentDragPasteboard ); + } + + return transferred; +} + //------------------------------------------------------------------------- // wxDropSource //------------------------------------------------------------------------- @@ -75,7 +164,7 @@ wxDropSource::~wxDropSource() bool wxDropSource::MacInstallDefaultCursor(wxDragResult effect) { const wxCursor& cursor = GetCursor(effect); - bool result = cursor.Ok(); + bool result = cursor.IsOk(); if ( result ) cursor.MacInstall();