1 ///////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/osx/dnd.h
3 // Purpose:     Declaration of the wxDropTarget, wxDropSource class etc.
4 // Author:      Stefan Csomor
5 // Copyright:   (c) 1998 Stefan Csomor
6 // Licence:     wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
8 
9 #ifndef _WX_DND_H_
10 #define _WX_DND_H_
11 
12 #if wxUSE_DRAG_AND_DROP
13 
14 #include "wx/defs.h"
15 #include "wx/object.h"
16 #include "wx/string.h"
17 #include "wx/string.h"
18 #include "wx/dataobj.h"
19 #include "wx/cursor.h"
20 
21 //-------------------------------------------------------------------------
22 // classes
23 //-------------------------------------------------------------------------
24 
25 class WXDLLIMPEXP_FWD_CORE wxWindow;
26 
27 class WXDLLIMPEXP_FWD_CORE wxDropTarget;
28 class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
29 class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
30 
31 class WXDLLIMPEXP_FWD_CORE wxDropSource;
32 
33 class WXDLLIMPEXP_FWD_CORE wxOSXDataSource;
34 
35 // ----------------------------------------------------------------------------
36 // macros
37 // ----------------------------------------------------------------------------
38 
39 // this macro may be used instead for wxDropSource ctor arguments: it will use
40 // the icon 'name' from an XPM file under GTK, but will expand to something
41 // else under MSW. If you don't use it, you will have to use #ifdef in the
42 // application code.
43 #define wxDROP_ICON(X)   wxCursor(X##_xpm)
44 
45 //-------------------------------------------------------------------------
46 // wxDropTarget
47 //-------------------------------------------------------------------------
48 
49 class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
50 {
51   public:
52 
53     wxDropTarget(wxDataObject *dataObject = NULL );
54 
55     virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def) wxOVERRIDE;
56     virtual bool OnDrop(wxCoord x, wxCoord y) wxOVERRIDE;
57     virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) wxOVERRIDE;
58     virtual bool GetData() wxOVERRIDE;
59     // NOTE: This is needed by the generic wxDataViewCtrl, not sure how to implement.
60     virtual wxDataFormat GetMatchingPair();
61 
62     bool CurrentDragHasSupportedFormat() ;
63 
SetCurrentDragSource(wxOSXDataSource * dragpasteboard)64     void SetCurrentDragSource( wxOSXDataSource* dragpasteboard ) { m_currentDragPasteboard = dragpasteboard ; }
65   protected :
66     wxOSXDataSource* m_currentDragPasteboard ;
67 };
68 
69 //-------------------------------------------------------------------------
70 // wxDropSource
71 //-------------------------------------------------------------------------
72 
73 class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
74 {
75 public:
76     // ctors: if you use default ctor you must call SetData() later!
77     //
78     // NB: the "wxWindow *win" parameter is unused and is here only for wxGTK
79     //     compatibility, as well as both icon parameters
80     wxDropSource( wxWindow *win = NULL,
81                  const wxCursor &cursorCopy = wxNullCursor,
82                  const wxCursor &cursorMove = wxNullCursor,
83                  const wxCursor &cursorStop = wxNullCursor);
84 
85     /* constructor for setting one data object */
86     wxDropSource( wxDataObject& data,
87                   wxWindow *win,
88                  const wxCursor &cursorCopy = wxNullCursor,
89                  const wxCursor &cursorMove = wxNullCursor,
90                  const wxCursor &cursorStop = wxNullCursor);
91 
92     virtual ~wxDropSource();
93 
94     // do it (call this in response to a mouse button press, for example)
95     // params: if bAllowMove is false, data can be only copied
96     virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly) wxOVERRIDE;
97 
GetWindow()98     wxWindow*     GetWindow() { return m_window ; }
SetCurrentDragPasteboard(void * dragpasteboard)99     void SetCurrentDragPasteboard( void* dragpasteboard ) { m_currentDragPasteboard = dragpasteboard ; }
100     bool MacInstallDefaultCursor(wxDragResult effect) ;
101     static wxDropSource* GetCurrentDropSource();
102   protected :
103 
104     wxWindow        *m_window;
105     void* m_currentDragPasteboard ;
106 };
107 
108 #endif // wxUSE_DRAG_AND_DROP
109 
110 #endif
111    //_WX_DND_H_
112