]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/dnd.h
addind nonowned window implementation
[wxWidgets.git] / include / wx / gtk1 / dnd.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/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 __GTKDNDH__
11 #define __GTKDNDH__
12
13 #if wxUSE_DRAG_AND_DROP
14
15 #include "wx/object.h"
16 #include "wx/string.h"
17 #include "wx/dataobj.h"
18 #include "wx/cursor.h"
19 #include "wx/icon.h"
20 #include "wx/gdicmn.h"
21
22 //-------------------------------------------------------------------------
23 // classes
24 //-------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_FWD_CORE wxWindow;
27
28 class WXDLLIMPEXP_FWD_CORE wxDropTarget;
29 class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
30 class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
31
32 class WXDLLIMPEXP_FWD_CORE wxDropSource;
33
34 // ----------------------------------------------------------------------------
35 // macros
36 // ----------------------------------------------------------------------------
37
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
41 // application code.
42 #define wxDROP_ICON(name) wxICON(name)
43
44 //-------------------------------------------------------------------------
45 // wxDropTarget
46 //-------------------------------------------------------------------------
47
48 class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
49 {
50 public:
51 wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
52
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();
57
58 // implementation
59
60 GdkAtom GetMatchingPair();
61
62 void RegisterWidget( GtkWidget *widget );
63 void UnregisterWidget( GtkWidget *widget );
64
65 GdkDragContext *m_dragContext;
66 GtkWidget *m_dragWidget;
67 GtkSelectionData *m_dragData;
68 guint m_dragTime;
69 bool m_firstMotion; // gdk has no "gdk_drag_enter" event
70
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; }
75 };
76
77 //-------------------------------------------------------------------------
78 // wxDropSource
79 //-------------------------------------------------------------------------
80
81 class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
82 {
83 public:
84 // constructor. set data later with SetData()
85 wxDropSource( wxWindow *win = (wxWindow *)NULL,
86 const wxIcon &copy = wxNullIcon,
87 const wxIcon &move = wxNullIcon,
88 const wxIcon &none = wxNullIcon);
89
90 // constructor for setting one data object
91 wxDropSource( wxDataObject& data,
92 wxWindow *win,
93 const wxIcon &copy = wxNullIcon,
94 const wxIcon &move = wxNullIcon,
95 const wxIcon &none = wxNullIcon);
96
97 virtual ~wxDropSource();
98
99 // start drag action
100 virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
101
102 // GTK implementation
103 void RegisterWindow();
104 void UnregisterWindow();
105
106 void PrepareIcon( int action, GdkDragContext *context );
107
108 GtkWidget *m_widget;
109 GtkWidget *m_iconWindow;
110 GdkDragContext *m_dragContext;
111 wxWindow *m_window;
112
113 wxDragResult m_retValue;
114 wxIcon m_iconCopy,
115 m_iconMove,
116 m_iconNone;
117
118 bool m_waiting;
119
120 private:
121 // common part of both ctors
122 void SetIcons(const wxIcon& copy,
123 const wxIcon& move,
124 const wxIcon& none);
125 };
126
127 #endif // wxUSE_DRAG_AND_DROP
128
129 #endif //__GTKDNDH__
130