]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/dnd.mm
making GetPosition 1:1 symmetrical to Move (respecting contentViews), fixing borderDr...
[wxWidgets.git] / src / osx / cocoa / dnd.mm
index 74e21d53b0b53a1b9e4eea5e59e9174b3ed8a2fd..eca5246de608027d3211d6ce8d1a35cf0011eaef 100644 (file)
 
 #ifndef WX_PRECOMP
     #include "wx/app.h"
 
 #ifndef WX_PRECOMP
     #include "wx/app.h"
-    #include "wx/evtloop.h"
     #include "wx/toplevel.h"
     #include "wx/gdicmn.h"
     #include "wx/wx.h"
 #endif // WX_PRECOMP
 
     #include "wx/toplevel.h"
     #include "wx/gdicmn.h"
     #include "wx/wx.h"
 #endif // WX_PRECOMP
 
-#include <AppKit/AppKit.h>
+#include "wx/evtloop.h"
+
 #include "wx/osx/private.h"
 
 wxDropSource* gCurrentSource = NULL;
 #include "wx/osx/private.h"
 
 wxDropSource* gCurrentSource = NULL;
@@ -43,6 +43,7 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
         default:
             wxFAIL_MSG("Unexpected result code");
     }
         default:
             wxFAIL_MSG("Unexpected result code");
     }
+    return wxDragNone;
 }
 
 @interface DropSourceDelegate : NSObject
 }
 
 @interface DropSourceDelegate : NSObject
@@ -87,6 +88,9 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
 
 - (void)draggedImage:(NSImage *)anImage movedTo:(NSPoint)aPoint
 {
 
 - (void)draggedImage:(NSImage *)anImage movedTo:(NSPoint)aPoint
 {
+    wxUnusedVar( anImage );
+    wxUnusedVar( aPoint );
+    
     bool optionDown = GetCurrentKeyModifiers() & optionKey;
     wxDragResult result = optionDown ? wxDragCopy : wxDragMove;
     
     bool optionDown = GetCurrentKeyModifiers() & optionKey;
     wxDragResult result = optionDown ? wxDragCopy : wxDragMove;
     
@@ -120,8 +124,12 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
 
             if (cursorID != wxCURSOR_NONE)
             {
 
             if (cursorID != wxCURSOR_NONE)
             {
+                // TODO under 10.6 the os itself deals with the cursor, remove if things
+                // work properly everywhere
+#if 0
                 wxCursor cursor( cursorID );
                 cursor.MacInstall();
                 wxCursor cursor( cursorID );
                 cursor.MacInstall();
+#endif
             }
         }
     }
             }
         }
     }
@@ -129,6 +137,9 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
 
 - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
 {
 
 - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
 {
+    wxUnusedVar( anImage );
+    wxUnusedVar( aPoint );
+    
     resultCode = operation;
     dragFinished = YES;
 }
     resultCode = operation;
     dragFinished = YES;
 }
@@ -170,7 +181,7 @@ wxDropSource* wxDropSource::GetCurrentDropSource()
     return gCurrentSource;
 }
 
     return gCurrentSource;
 }
 
-wxDragResult wxDropSource::DoDragDrop(int flags)
+wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
 {
     wxASSERT_MSG( m_data, wxT("Drop source: no data") );
 
 {
     wxASSERT_MSG( m_data, wxT("Drop source: no data") );
 
@@ -201,12 +212,31 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
         
         NSEvent* theEvent = (NSEvent*)wxTheApp->MacGetCurrentEvent();
         wxASSERT_MSG(theEvent, "DoDragDrop must be called in response to a mouse down or drag event.");
         
         NSEvent* theEvent = (NSEvent*)wxTheApp->MacGetCurrentEvent();
         wxASSERT_MSG(theEvent, "DoDragDrop must be called in response to a mouse down or drag event.");
-        
+
+        NSPoint down = [theEvent locationInWindow];
+        NSPoint p = [view convertPoint:down toView:nil];
+                
         gCurrentSource = this;
         gCurrentSource = this;
-        NSImage* image = [[NSImage alloc] initWithSize: NSMakeSize(16,16)];
+        
+        // add a dummy square as dragged image for the moment, 
+        // TODO: proper drag image for data
+        NSSize sz = NSMakeSize(16,16);
+        NSRect fillRect = NSMakeRect(0, 0, 16, 16);
+        NSImage* image = [[NSImage alloc] initWithSize: sz];
+        [image lockFocus];
+        
+        [[[NSColor whiteColor] colorWithAlphaComponent:0.8] set];
+        NSRectFill(fillRect);
+        [[NSColor blackColor] set];
+        NSFrameRectWithWidthUsingOperation(fillRect,1.0f,NSCompositeDestinationOver);
+        
+        [image unlockFocus];        
+        
+        
         DropSourceDelegate* delegate = [[DropSourceDelegate alloc] init];
         [delegate setImplementation: this];
         DropSourceDelegate* delegate = [[DropSourceDelegate alloc] init];
         [delegate setImplementation: this];
-        [view dragImage:image at:NSMakePoint(0.0, 16.0) offset:NSMakeSize(0.0,0.0) 
+        [view dragImage:image at:p offset:NSMakeSize(0.0,0.0) 
             event: theEvent pasteboard: pboard source:delegate slideBack: NO];
         
         wxEventLoopBase * const loop = wxEventLoop::GetActive();
             event: theEvent pasteboard: pboard source:delegate slideBack: NO];
         
         wxEventLoopBase * const loop = wxEventLoop::GetActive();