+ DisposeRgn( hiliteRgn );
+ }
+ }
+ }
+ }
+ else
+ {
+ if ( trackingGlobals->m_currentTarget )
+ {
+ trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag );
+ result = trackingGlobals->m_currentTarget->OnDragOver( localx, localy, result );
+ }
+ }
+
+ // set cursor for OnEnter and OnDragOver
+ if ( trackingGlobals->m_currentSource && !trackingGlobals->m_currentSource->GiveFeedback( result ) )
+ {
+ if ( !trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) )
+ {
+ int cursorID = wxCURSOR_NONE;
+
+ switch (result)
+ {
+ case wxDragCopy:
+ cursorID = wxCURSOR_COPY_ARROW;
+ break;
+
+ case wxDragMove:
+ cursorID = wxCURSOR_ARROW;
+ break;
+
+ case wxDragNone:
+ cursorID = wxCURSOR_NO_ENTRY;
+ break;
+
+ case wxDragError:
+ case wxDragLink:
+ case wxDragCancel:
+ default:
+ // put these here to make gcc happy
+ ;
+ }
+
+ if (cursorID != wxCURSOR_NONE)
+ {
+ wxCursor cursor( cursorID );
+ cursor.MacInstall();
+ }
+ }
+ }
+ }
+ break;
+
+ case kDragTrackingLeaveWindow:
+ if (trackingGlobals == NULL)
+ break;
+
+ if (trackingGlobals->m_currentTarget)
+ {
+ trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag );
+ trackingGlobals->m_currentTarget->OnLeave();
+#ifndef __LP64__
+ HideDragHilite( theDrag );
+#endif
+ trackingGlobals->m_currentTarget = NULL;
+ }
+ trackingGlobals->m_currentTargetWindow = NULL;
+ break;
+
+ default:
+ break;
+ }
+
+ return noErr;
+}
+
+pascal OSErr wxMacWindowDragReceiveHandler(
+ WindowPtr theWindow,
+ void *handlerRefCon,
+ DragReference theDrag)
+{
+ MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*)handlerRefCon;
+ if ( trackingGlobals->m_currentTarget )
+ {
+ Point mouse, localMouse;
+ int localx, localy;
+
+ trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag );
+ GetDragMouse( theDrag, &mouse, 0L );
+ localMouse = mouse;
+ wxMacGlobalToLocal( theWindow, &localMouse );
+ localx = localMouse.h;
+ localy = localMouse.v;
+
+ // TODO : should we use client coordinates?
+ if ( trackingGlobals->m_currentTargetWindow )
+ trackingGlobals->m_currentTargetWindow->MacRootWindowToWindow( &localx, &localy );
+ if ( trackingGlobals->m_currentTarget->OnDrop( localx, localy ) )
+ {
+ // the option key indicates copy in Mac UI, if it's not pressed do
+ // move by default if it's allowed at all
+ wxDragResult
+ result = !(trackingGlobals->m_flags & wxDrag_AllowMove) ||
+ (GetCurrentKeyModifiers() & optionKey)
+ ? wxDragCopy
+ : wxDragMove;
+ trackingGlobals->m_result =
+ trackingGlobals->m_currentTarget->OnData( localx, localy, result );
+ }
+ }
+
+ return noErr;
+}
+
+#endif // wxUSE_DRAG_AND_DROP
+