1 /*
2    GSDragView - Generic Drag and Drop code.
3 
4    Copyright (C) 2004 Free Software Foundation, Inc.
5 
6    Author: Fred Kiefer <fredkiefer@gmx.de>
7    Date: May 2004
8 
9    Based on X11 specific code from:
10    Created by: Wim Oudshoorn <woudshoo@xs4all.nl>
11    Date: Nov 2001
12    Written by:  Adam Fedor <fedor@gnu.org>
13    Date: Nov 1998
14 
15    This file is part of the GNU Objective C User Interface Library.
16 
17    This library is free software; you can redistribute it and/or
18    modify it under the terms of the GNU Lesser General Public
19    License as published by the Free Software Foundation; either
20    version 2 of the License, or (at your option) any later version.
21 
22    This library is distributed in the hope that it will be useful,
23    but WITHOUT ANY WARRANTY; without even the implied warranty of
24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
25    Lesser General Public License for more details.
26 
27    You should have received a copy of the GNU Lesser General Public
28    License along with this library; see the file COPYING.LIB.
29    If not, see <http://www.gnu.org/licenses/> or write to the
30    Free Software Foundation, 51 Franklin Street, Fifth Floor,
31    Boston, MA 02110-1301, USA.
32 */
33 #ifndef _GSDragView_h_INCLUDE
34 #define _GSDragView_h_INCLUDE
35 
36 #import <Foundation/NSDate.h>
37 #import <Foundation/NSGeometry.h>
38 #import <AppKit/NSDragging.h>
39 #import <AppKit/NSView.h>
40 
41 @class NSMutableDictionary;
42 
43 @class NSCell;
44 @class NSEvent;
45 @class NSImage;
46 @class NSPasteboard;
47 @class NSWindow;
48 
49 /*
50  * used in the operation mask to indicate that the
51  * user can not change the drag action by
52  * pressing modifiers.
53  */
54 
55 #define NSDragOperationIgnoresModifiers  0xffff
56 
57 @interface GSDragView : NSView <NSDraggingInfo>
58 {
59   // the graphics that is dragged
60   NSCell	*dragCell;
61 
62   // the pasteboard with the dragged data
63   NSPasteboard	*dragPasteboard;
64 
65   // NSWindow in this application that is the current target
66   NSWindow	*destWindow;
67 
68   // Screen coordinates of mouse pointer, only valid when destWindow != nil
69   NSPoint	dragPoint;
70 
71   NSInteger	dragSequence;
72 
73   // the source of the dragging operation
74   id		dragSource;
75 
76   // Operations supported by the source
77   NSDragOperation dragMask;
78 
79   /* User specified operation mask (key modifiers).
80    * This is either a mask of type _NSDragOperation,
81    * or NSDragOperationIgnoresModifiers, which
82    * is defined as 0xffff
83    */
84   NSDragOperation operationMask;
85 
86   // slide the image back when drag fails?
87   BOOL		slideBack;
88 
89   /* The following information used in the drag and drop event loop
90    */
91 
92   // offset of image w.r.t. cursor
93   NSSize	offset;
94 
95   // current drag (mouse cursor) position in screen coordinates
96   NSPoint	dragPosition;
97 
98   // drag (mouse cursor) position, not yet processed
99   NSPoint	newPosition;
100 
101   // OS specific current window target of the drag operation
102   int		targetWindowRef;
103 
104   // Operations supported by the target, only valid if targetWindowRef isn't 0
105   NSDragOperation targetMask;
106 
107   // YES if target and source are in a different application
108   BOOL		destExternal;
109 
110   // YES if we are currently dragging
111   BOOL		isDragging;
112 
113   // Cache for cursors
114   NSMutableDictionary	*cursors;
115 }
116 
117 + (id) sharedDragView;
118 - (void) dragImage: (NSImage*)anImage
119 		at: (NSPoint)screenLocation
120 	    offset: (NSSize)initialOffset
121 	     event: (NSEvent*)event
122 	pasteboard: (NSPasteboard*)pboard
123 	    source: (id)sourceObject
124          slideBack: (BOOL)slideFlag;
125 - (void) postDragEvent: (NSEvent*)theEvent;
126 - (void) sendExternalEvent: (GSAppKitSubtype)subtype
127 		    action: (NSDragOperation)action
128 		  position: (NSPoint)eventLocation
129 		 timestamp: (NSTimeInterval)time
130 		  toWindow: (int)dWindowNumber;
131 - (NSWindow*) windowAcceptingDnDunder: (NSPoint)mouseLocation
132 			    windowRef: (int*)mouseWindowRef;
133 
134 @end
135 #endif
136