]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dnd.h
A bit more or multi-format clipboard.
[wxWidgets.git] / include / wx / gtk / dnd.h
CommitLineData
c801d85f
KB
1///////////////////////////////////////////////////////////////////////////////
2// Name: dnd.h
3// Purpose: declaration of the wxDropTarget class
4// Author: Robert Roebling
58614078 5// RCS-ID: $Id$
c801d85f
KB
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
06cfab17 18#if wxUSE_DRAG_AND_DROP
ac57418f 19
c801d85f
KB
20#include "wx/object.h"
21#include "wx/string.h"
8b53e5a2 22#include "wx/dataobj.h"
c801d85f 23#include "wx/cursor.h"
e4677d31
RR
24#include "wx/icon.h"
25#include "wx/gdicmn.h"
c801d85f
KB
26
27//-------------------------------------------------------------------------
28// classes
29//-------------------------------------------------------------------------
30
31class wxWindow;
32
33class wxDropTarget;
34class wxTextDropTarget;
e3e65dac
RR
35class wxFileDropTarget;
36
37class wxDropSource;
38
d6086ea6
RR
39//-------------------------------------------------------------------------
40// wxDropTarget
41//-------------------------------------------------------------------------
42
b068c4e8 43class wxDropTarget: public wxDropTargetBase
d6086ea6
RR
44{
45public:
b068c4e8
RR
46 wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
47
48 virtual bool OnEnter(wxCoord x, wxCoord y) ;
49 virtual bool OnMove(wxCoord x, wxCoord y);
50 virtual bool OnDrop(wxCoord x, wxCoord y);
51 virtual bool OnData(wxCoord x, wxCoord y);
52 virtual bool GetData();
53
54 // implementation
55
56 GdkAtom GetMatchingPair();
57 void RegisterWidget( GtkWidget *widget );
58 void UnregisterWidget( GtkWidget *widget );
59
60 GdkDragContext *m_dragContext;
61 GtkWidget *m_dragWidget;
62 GtkSelectionData *m_dragData;
63 guint m_dragTime;
64 bool m_firstMotion; /* gdk has no "gdk_drag_enter" event */
65
66 void SetDragContext( GdkDragContext *dc ) { m_dragContext = dc; }
67 void SetDragWidget( GtkWidget *w ) { m_dragWidget = w; }
68 void SetDragData( GtkSelectionData *sd ) { m_dragData = sd; }
69 void SetDragTime( guint time ) { m_dragTime = time; }
9e2896e5 70};
8e193f38 71
97c79de2
RR
72// ----------------------------------------------------------------------------
73// A simple wxDropTarget derived class for text data: you only need to
74// override OnDropText() to get something working
75// ----------------------------------------------------------------------------
76
77class wxTextDropTarget : public wxDropTarget
78{
79public:
80 wxTextDropTarget();
81
82 virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
83
84 virtual bool OnData(wxCoord x, wxCoord y);
85};
86
87// ----------------------------------------------------------------------------
88// A drop target which accepts files (dragged from File Manager or Explorer)
89// ----------------------------------------------------------------------------
90
91class wxFileDropTarget : public wxDropTarget
92{
93public:
94 wxFileDropTarget();
95
96 // parameters are the number of files and the array of file names
97 virtual bool OnDropFiles(wxCoord x, wxCoord y,
98 const wxArrayString& filenames) = 0;
99
100 virtual bool OnData(wxCoord x, wxCoord y);
101};
102
9e2896e5
VZ
103//-------------------------------------------------------------------------
104// wxDropSource
105//-------------------------------------------------------------------------
106
b068c4e8 107class wxDropSource: public wxDropSourceBase
9e2896e5
VZ
108{
109public:
110 /* constructor. set data later with SetData() */
111 wxDropSource( wxWindow *win,
112 const wxIcon &go = wxNullIcon,
113 const wxIcon &stop = wxNullIcon );
8e193f38 114
9e2896e5
VZ
115 /* constructor for setting one data object */
116 wxDropSource( wxDataObject& data,
117 wxWindow *win,
118 const wxIcon &go = wxNullIcon,
119 const wxIcon &stop = wxNullIcon );
8e193f38 120
9e2896e5 121 ~wxDropSource();
8e193f38 122
9e2896e5
VZ
123 /* start drag action */
124 virtual wxDragResult DoDragDrop( bool bAllowMove = FALSE );
8e193f38 125
9e2896e5
VZ
126 /* GTK implementation */
127 void RegisterWindow();
128 void UnregisterWindow();
8e193f38 129
8a126fcc
RR
130 GtkWidget *m_widget;
131 wxWindow *m_window;
132 wxDragResult m_retValue;
8e193f38 133
8a126fcc
RR
134 wxCursor m_defaultCursor;
135 wxCursor m_goaheadCursor;
8e193f38 136
8a126fcc
RR
137 wxIcon m_goIcon;
138 wxIcon m_stopIcon;
8e193f38 139
8a126fcc 140 bool m_waiting;
c801d85f
KB
141};
142
ac57418f
RR
143#endif
144
145 // wxUSE_DRAG_AND_DROP
146
8e193f38 147#endif
c801d85f
KB
148 //__GTKDNDH__
149