Refactor DND code into Carbon and Cocoa parts, and provide a basic OS X Cocoa implementation for wxDropSource::DoDragDrop.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63365 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2010-02-03 05:31:31 +00:00
parent 803e2857b3
commit 7dab9892b3
5 changed files with 297 additions and 84 deletions

87
src/osx/dnd_osx.cpp Normal file
View File

@@ -0,0 +1,87 @@
///////////////////////////////////////////////////////////////////////////////
// Name: src/osx/dnd_osx.cpp
// Purpose: Mac common wxDropTarget, wxDropSource implementations
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id: dnd.cpp 61724 2009-08-21 10:41:26Z VZ $
// Copyright: (c) 1998 Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/toplevel.h"
#include "wx/gdicmn.h"
#endif // WX_PRECOMP
#include "wx/osx/private.h"
//----------------------------------------------------------------------------
// wxDropTarget
//----------------------------------------------------------------------------
wxDragResult wxDropTarget::OnDragOver(
wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
wxDragResult def )
{
return CurrentDragHasSupportedFormat() ? def : wxDragNone;
}
wxDataFormat wxDropTarget::GetMatchingPair()
{
wxFAIL_MSG("wxDropTarget::GetMatchingPair() not implemented in src/osx/carbon/dnd.cpp");
return wxDF_INVALID;
}
bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
{
if (m_dataObject == NULL)
return false;
return CurrentDragHasSupportedFormat();
}
wxDragResult wxDropTarget::OnData(
wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
wxDragResult def )
{
if (m_dataObject == NULL)
return wxDragNone;
if (!CurrentDragHasSupportedFormat())
return wxDragNone;
return GetData() ? def : wxDragNone;
}
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// drag request
wxDropSource::~wxDropSource()
{
}
bool wxDropSource::MacInstallDefaultCursor(wxDragResult effect)
{
const wxCursor& cursor = GetCursor(effect);
bool result = cursor.Ok();
if ( result )
cursor.MacInstall();
return result;
}
#endif // wxUSE_DRAG_AND_DROP