1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of the wxDropTarget class
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
12 #if wxUSE_DRAG_AND_DROP
14 #include "wx/object.h"
15 #include "wx/string.h"
16 #include "wx/dataobj.h"
17 #include "wx/cursor.h"
19 #include "wx/gdicmn.h"
21 //-------------------------------------------------------------------------
23 //-------------------------------------------------------------------------
25 class WXDLLIMPEXP_FWD_CORE wxWindow
;
27 class WXDLLIMPEXP_FWD_CORE wxDropTarget
;
28 class WXDLLIMPEXP_FWD_CORE wxTextDropTarget
;
29 class WXDLLIMPEXP_FWD_CORE wxFileDropTarget
;
31 class WXDLLIMPEXP_FWD_CORE wxDropSource
;
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 // this macro may be used instead for wxDropSource ctor arguments: it will use
38 // the icon 'name' from an XPM file under GTK, but will expand to something
39 // else under MSW. If you don't use it, you will have to use #ifdef in the
41 #define wxDROP_ICON(name) wxICON(name)
43 //-------------------------------------------------------------------------
45 //-------------------------------------------------------------------------
47 class WXDLLIMPEXP_CORE wxDropTarget
: public wxDropTargetBase
50 wxDropTarget(wxDataObject
*dataObject
= NULL
);
52 virtual wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
53 virtual bool OnDrop(wxCoord x
, wxCoord y
);
54 virtual wxDragResult
OnData(wxCoord x
, wxCoord y
, wxDragResult def
);
55 virtual bool GetData();
59 GdkAtom
GetMatchingPair(bool quiet
= false);
61 void RegisterWidget( GtkWidget
*widget
);
62 void UnregisterWidget( GtkWidget
*widget
);
64 GdkDragContext
*m_dragContext
;
65 GtkWidget
*m_dragWidget
;
66 GtkSelectionData
*m_dragData
;
68 bool m_firstMotion
; // gdk has no "gdk_drag_enter" event
70 void SetDragContext( GdkDragContext
*dc
) { m_dragContext
= dc
; }
71 void SetDragWidget( GtkWidget
*w
) { m_dragWidget
= w
; }
72 void SetDragData( GtkSelectionData
*sd
) { m_dragData
= sd
; }
73 void SetDragTime(unsigned time
) { m_dragTime
= time
; }
76 //-------------------------------------------------------------------------
78 //-------------------------------------------------------------------------
80 class WXDLLIMPEXP_CORE wxDropSource
: public wxDropSourceBase
83 // constructor. set data later with SetData()
84 wxDropSource( wxWindow
*win
= NULL
,
85 const wxIcon
©
= wxNullIcon
,
86 const wxIcon
&move
= wxNullIcon
,
87 const wxIcon
&none
= wxNullIcon
);
89 // constructor for setting one data object
90 wxDropSource( wxDataObject
& data
,
92 const wxIcon
©
= wxNullIcon
,
93 const wxIcon
&move
= wxNullIcon
,
94 const wxIcon
&none
= wxNullIcon
);
96 virtual ~wxDropSource();
99 virtual wxDragResult
DoDragDrop(int flags
= wxDrag_CopyOnly
);
101 // GTK implementation
102 void RegisterWindow();
103 void UnregisterWindow();
105 void PrepareIcon( int action
, GdkDragContext
*context
);
108 GtkWidget
*m_iconWindow
;
109 GdkDragContext
*m_dragContext
;
112 wxDragResult m_retValue
;
120 // common part of both ctors
121 void SetIcons(const wxIcon
& copy
,
126 #endif // wxUSE_DRAG_AND_DROP