]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dnd.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of the wxDropTarget class
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
7 // Licence: wxWindows license
8 ///////////////////////////////////////////////////////////////////////////////
18 #if wxUSE_DRAG_AND_DROP
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/dataobj.h"
23 #include "wx/cursor.h"
25 #include "wx/gdicmn.h"
27 //-------------------------------------------------------------------------
29 //-------------------------------------------------------------------------
34 class wxTextDropTarget
;
35 class wxFileDropTarget
;
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 // this macro may be used instead for wxDropSource ctor arguments: it will use
44 // the icon 'name' from an XPM file under GTK, but will expand to something
45 // else under MSW. If you don't use it, you will have to use #ifdef in the
47 #define wxDROP_ICON(name) wxICON(name)
49 //-------------------------------------------------------------------------
51 //-------------------------------------------------------------------------
53 class wxDropTarget
: public wxDropTargetBase
56 wxDropTarget(wxDataObject
*dataObject
= (wxDataObject
*) NULL
);
58 virtual wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
59 virtual bool OnDrop(wxCoord x
, wxCoord y
);
60 virtual wxDragResult
OnData(wxCoord x
, wxCoord y
, wxDragResult def
);
61 virtual bool GetData();
65 GdkAtom
GetMatchingPair();
67 void RegisterWidget( GtkWidget
*widget
);
68 void UnregisterWidget( GtkWidget
*widget
);
70 GdkDragContext
*m_dragContext
;
71 GtkWidget
*m_dragWidget
;
72 GtkSelectionData
*m_dragData
;
74 bool m_firstMotion
; // gdk has no "gdk_drag_enter" event
76 void SetDragContext( GdkDragContext
*dc
) { m_dragContext
= dc
; }
77 void SetDragWidget( GtkWidget
*w
) { m_dragWidget
= w
; }
78 void SetDragData( GtkSelectionData
*sd
) { m_dragData
= sd
; }
79 void SetDragTime( guint time
) { m_dragTime
= time
; }
82 //-------------------------------------------------------------------------
84 //-------------------------------------------------------------------------
86 class wxDropSource
: public wxDropSourceBase
89 // constructor. set data later with SetData()
90 wxDropSource( wxWindow
*win
= (wxWindow
*)NULL
,
91 const wxIcon
©
= wxNullIcon
,
92 const wxIcon
&move
= wxNullIcon
,
93 const wxIcon
&none
= wxNullIcon
);
95 // constructor for setting one data object
96 wxDropSource( wxDataObject
& data
,
98 const wxIcon
©
= wxNullIcon
,
99 const wxIcon
&move
= wxNullIcon
,
100 const wxIcon
&none
= wxNullIcon
);
102 virtual ~wxDropSource();
105 virtual wxDragResult
DoDragDrop(int flags
= wxDrag_CopyOnly
);
107 // GTK implementation
108 void RegisterWindow();
109 void UnregisterWindow();
111 void PrepareIcon( int action
, GdkDragContext
*context
);
114 GtkWidget
*m_iconWindow
;
115 GdkDragContext
*m_dragContext
;
118 wxDragResult m_retValue
;
126 // common part of both ctors
127 void SetIcons(const wxIcon
& copy
,
132 #endif // wxUSE_DRAG_AND_DROP