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 ///////////////////////////////////////////////////////////////////////////////
10 #define _WX_GTK_DND_H_
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // this macro may be used instead for wxDropSource ctor arguments: it will use
19 // the icon 'name' from an XPM file under GTK, but will expand to something
20 // else under MSW. If you don't use it, you will have to use #ifdef in the
22 #define wxDROP_ICON(name) wxICON(name)
24 //-------------------------------------------------------------------------
26 //-------------------------------------------------------------------------
28 class WXDLLIMPEXP_CORE wxDropTarget
: public wxDropTargetBase
31 wxDropTarget(wxDataObject
*dataObject
= NULL
);
33 virtual wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
34 virtual bool OnDrop(wxCoord x
, wxCoord y
);
35 virtual wxDragResult
OnData(wxCoord x
, wxCoord y
, wxDragResult def
);
36 virtual bool GetData();
38 // Can only be called during OnXXX methods.
39 wxDataFormat
GetMatchingPair();
43 GdkAtom
GTKGetMatchingPair(bool quiet
= false);
44 wxDragResult
GTKFigureOutSuggestedAction();
46 void GtkRegisterWidget( GtkWidget
*widget
);
47 void GtkUnregisterWidget( GtkWidget
*widget
);
49 GdkDragContext
*m_dragContext
;
50 GtkWidget
*m_dragWidget
;
51 GtkSelectionData
*m_dragData
;
53 bool m_firstMotion
; // gdk has no "gdk_drag_enter" event
55 void GTKSetDragContext( GdkDragContext
*dc
) { m_dragContext
= dc
; }
56 void GTKSetDragWidget( GtkWidget
*w
) { m_dragWidget
= w
; }
57 void GTKSetDragData( GtkSelectionData
*sd
) { m_dragData
= sd
; }
58 void GTKSetDragTime(unsigned time
) { m_dragTime
= time
; }
61 //-------------------------------------------------------------------------
63 //-------------------------------------------------------------------------
65 class WXDLLIMPEXP_CORE wxDropSource
: public wxDropSourceBase
68 // constructor. set data later with SetData()
69 wxDropSource( wxWindow
*win
= NULL
,
70 const wxIcon
©
= wxNullIcon
,
71 const wxIcon
&move
= wxNullIcon
,
72 const wxIcon
&none
= wxNullIcon
);
74 // constructor for setting one data object
75 wxDropSource( wxDataObject
& data
,
77 const wxIcon
©
= wxNullIcon
,
78 const wxIcon
&move
= wxNullIcon
,
79 const wxIcon
&none
= wxNullIcon
);
81 virtual ~wxDropSource();
83 // set the icon corresponding to given drag result
84 void SetIcon(wxDragResult res
, const wxIcon
& icon
)
86 if ( res
== wxDragCopy
)
88 else if ( res
== wxDragMove
)
95 virtual wxDragResult
DoDragDrop(int flags
= wxDrag_CopyOnly
);
97 void PrepareIcon( int action
, GdkDragContext
*context
);
100 GtkWidget
*m_iconWindow
;
101 GdkDragContext
*m_dragContext
;
104 wxDragResult m_retValue
;
112 // common part of both ctors
113 void SetIcons(const wxIcon
& copy
,
117 // GTK implementation
118 void GTKConnectDragSignals();
119 void GTKDisconnectDragSignals();
123 #endif // _WX_GTK_DND_H_