]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dnd.h
c29ded049e8031f194392df1ef9c6a17bb082931
[wxWidgets.git] / include / wx / gtk / dnd.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: dnd.h
3 // Purpose: declaration of the wxDropTarget class
4 // Author: Robert Roebling
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTK_DND_H_
11 #define _WX_GTK_DND_H_
12
13 #include "wx/icon.h"
14
15 // ----------------------------------------------------------------------------
16 // macros
17 // ----------------------------------------------------------------------------
18
19 // this macro may be used instead for wxDropSource ctor arguments: it will use
20 // the icon 'name' from an XPM file under GTK, but will expand to something
21 // else under MSW. If you don't use it, you will have to use #ifdef in the
22 // application code.
23 #define wxDROP_ICON(name) wxICON(name)
24
25 //-------------------------------------------------------------------------
26 // wxDropTarget
27 //-------------------------------------------------------------------------
28
29 class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
30 {
31 public:
32 wxDropTarget(wxDataObject *dataObject = NULL );
33
34 virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
35 virtual bool OnDrop(wxCoord x, wxCoord y);
36 virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
37 virtual bool GetData();
38
39
40 // implementation
41
42 GdkAtom GtkGetMatchingPair();
43
44 void GtkRegisterWidget( GtkWidget *widget );
45 void GtkUnregisterWidget( GtkWidget *widget );
46
47 GdkDragContext *m_dragContext;
48 GtkWidget *m_dragWidget;
49 GtkSelectionData *m_dragData;
50 guint m_dragTime;
51 bool m_firstMotion; // gdk has no "gdk_drag_enter" event
52
53 void GtkSetDragContext( GdkDragContext *dc ) { m_dragContext = dc; }
54 void GtkSetDragWidget( GtkWidget *w ) { m_dragWidget = w; }
55 void GtkSetDragData( GtkSelectionData *sd ) { m_dragData = sd; }
56 void GtkSetDragTime( guint time ) { m_dragTime = time; }
57 };
58
59 //-------------------------------------------------------------------------
60 // wxDropSource
61 //-------------------------------------------------------------------------
62
63 class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
64 {
65 public:
66 // constructor. set data later with SetData()
67 wxDropSource( wxWindow *win = NULL,
68 const wxIcon &copy = wxNullIcon,
69 const wxIcon &move = wxNullIcon,
70 const wxIcon &none = wxNullIcon);
71
72 // constructor for setting one data object
73 wxDropSource( wxDataObject& data,
74 wxWindow *win,
75 const wxIcon &copy = wxNullIcon,
76 const wxIcon &move = wxNullIcon,
77 const wxIcon &none = wxNullIcon);
78
79 virtual ~wxDropSource();
80
81 // start drag action
82 virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
83
84 void PrepareIcon( int action, GdkDragContext *context );
85
86 GtkWidget *m_widget;
87 GtkWidget *m_iconWindow;
88 GdkDragContext *m_dragContext;
89 wxWindow *m_window;
90
91 wxDragResult m_retValue;
92 wxIcon m_iconCopy,
93 m_iconMove,
94 m_iconNone;
95
96 bool m_waiting;
97
98 private:
99 // common part of both ctors
100 void SetIcons(const wxIcon& copy,
101 const wxIcon& move,
102 const wxIcon& none);
103
104 // GTK implementation
105 void GTKConnectDragSignals();
106 void GTKDisconnectDragSignals();
107
108 };
109
110 #endif // _WX_GTK_DND_H_
111