]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dnd.h
another GetInt/GetId bug fix
[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 license
8 ///////////////////////////////////////////////////////////////////////////////
9
10
11 #ifndef __GTKDNDH__
12 #define __GTKDNDH__
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #if wxUSE_DRAG_AND_DROP
19
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/dataobj.h"
23 #include "wx/cursor.h"
24 #include "wx/icon.h"
25 #include "wx/gdicmn.h"
26
27 //-------------------------------------------------------------------------
28 // classes
29 //-------------------------------------------------------------------------
30
31 class wxWindow;
32
33 class wxDropTarget;
34 class wxTextDropTarget;
35 class wxFileDropTarget;
36
37 class wxDropSource;
38
39 // ----------------------------------------------------------------------------
40 // macros
41 // ----------------------------------------------------------------------------
42
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
46 // application code.
47 #define wxDROP_ICON(name) wxICON(name)
48
49 //-------------------------------------------------------------------------
50 // wxDropTarget
51 //-------------------------------------------------------------------------
52
53 class wxDropTarget: public wxDropTargetBase
54 {
55 public:
56 wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
57
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();
62
63 // implementation
64
65 GdkAtom GetMatchingPair();
66
67 void RegisterWidget( GtkWidget *widget );
68 void UnregisterWidget( GtkWidget *widget );
69
70 GdkDragContext *m_dragContext;
71 GtkWidget *m_dragWidget;
72 GtkSelectionData *m_dragData;
73 guint m_dragTime;
74 bool m_firstMotion; /* gdk has no "gdk_drag_enter" event */
75
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; }
80 };
81
82 //-------------------------------------------------------------------------
83 // wxDropSource
84 //-------------------------------------------------------------------------
85
86 class wxDropSource: public wxDropSourceBase
87 {
88 public:
89 /* constructor. set data later with SetData() */
90 wxDropSource( wxWindow *win = (wxWindow *)NULL,
91 const wxIcon &copy = wxNullIcon,
92 const wxIcon &move = wxNullIcon,
93 const wxIcon &none = wxNullIcon);
94
95 /* constructor for setting one data object */
96 wxDropSource( wxDataObject& data,
97 wxWindow *win,
98 const wxIcon &copy = wxNullIcon,
99 const wxIcon &move = wxNullIcon,
100 const wxIcon &none = wxNullIcon);
101
102 ~wxDropSource();
103
104 /* start drag action */
105 virtual wxDragResult DoDragDrop( bool bAllowMove = FALSE );
106
107 /* GTK implementation */
108 void RegisterWindow();
109 void UnregisterWindow();
110
111 void PrepareIcon( int action, GdkDragContext *context );
112
113 GtkWidget *m_widget;
114 GtkWidget *m_iconWindow;
115 GdkDragContext *m_dragContext;
116 wxWindow *m_window;
117
118 wxDragResult m_retValue;
119 wxIcon m_iconCopy,
120 m_iconMove,
121 m_iconNone;
122
123 bool m_waiting;
124
125 private:
126 // common part of both ctors
127 void SetIcons(const wxIcon& copy,
128 const wxIcon& move,
129 const wxIcon& none);
130 };
131
132 #endif
133
134 // wxUSE_DRAG_AND_DROP
135
136 #endif
137 //__GTKDNDH__
138