1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of the wxDropTarget class
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
13 #if wxUSE_DRAG_AND_DROP
15 #include "wx/object.h"
16 #include "wx/string.h"
17 #include "wx/dataobj.h"
18 #include "wx/cursor.h"
20 #include "wx/gdicmn.h"
22 //-------------------------------------------------------------------------
24 //-------------------------------------------------------------------------
26 class WXDLLIMPEXP_FWD_CORE wxWindow
;
28 class WXDLLIMPEXP_FWD_CORE wxDropTarget
;
29 class WXDLLIMPEXP_FWD_CORE wxTextDropTarget
;
30 class WXDLLIMPEXP_FWD_CORE wxFileDropTarget
;
32 class WXDLLIMPEXP_FWD_CORE wxDropSource
;
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 // this macro may be used instead for wxDropSource ctor arguments: it will use
39 // the icon 'name' from an XPM file under GTK, but will expand to something
40 // else under MSW. If you don't use it, you will have to use #ifdef in the
42 #define wxDROP_ICON(name) wxICON(name)
44 //-------------------------------------------------------------------------
46 //-------------------------------------------------------------------------
48 class WXDLLIMPEXP_CORE wxDropTarget
: public wxDropTargetBase
51 wxDropTarget(wxDataObject
*dataObject
= NULL
);
53 virtual wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
54 virtual bool OnDrop(wxCoord x
, wxCoord y
);
55 virtual wxDragResult
OnData(wxCoord x
, wxCoord y
, wxDragResult def
);
56 virtual bool GetData();
60 GdkAtom
GetMatchingPair(bool quiet
= false);
62 void RegisterWidget( GtkWidget
*widget
);
63 void UnregisterWidget( GtkWidget
*widget
);
65 GdkDragContext
*m_dragContext
;
66 GtkWidget
*m_dragWidget
;
67 GtkSelectionData
*m_dragData
;
69 bool m_firstMotion
; // gdk has no "gdk_drag_enter" event
71 void SetDragContext( GdkDragContext
*dc
) { m_dragContext
= dc
; }
72 void SetDragWidget( GtkWidget
*w
) { m_dragWidget
= w
; }
73 void SetDragData( GtkSelectionData
*sd
) { m_dragData
= sd
; }
74 void SetDragTime( guint time
) { m_dragTime
= time
; }
77 //-------------------------------------------------------------------------
79 //-------------------------------------------------------------------------
81 class WXDLLIMPEXP_CORE wxDropSource
: public wxDropSourceBase
84 // constructor. set data later with SetData()
85 wxDropSource( wxWindow
*win
= NULL
,
86 const wxIcon
©
= wxNullIcon
,
87 const wxIcon
&move
= wxNullIcon
,
88 const wxIcon
&none
= wxNullIcon
);
90 // constructor for setting one data object
91 wxDropSource( wxDataObject
& data
,
93 const wxIcon
©
= wxNullIcon
,
94 const wxIcon
&move
= wxNullIcon
,
95 const wxIcon
&none
= wxNullIcon
);
97 virtual ~wxDropSource();
100 virtual wxDragResult
DoDragDrop(int flags
= wxDrag_CopyOnly
);
102 // GTK implementation
103 void RegisterWindow();
104 void UnregisterWindow();
106 void PrepareIcon( int action
, GdkDragContext
*context
);
109 GtkWidget
*m_iconWindow
;
110 GdkDragContext
*m_dragContext
;
113 wxDragResult m_retValue
;
121 // common part of both ctors
122 void SetIcons(const wxIcon
& copy
,
127 #endif // wxUSE_DRAG_AND_DROP