]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dnd.cpp
Add virtual ~wxAnyScrollHelperBase() to fix compiler warning.
[wxWidgets.git] / src / motif / dnd.cpp
CommitLineData
4bb6408c 1///////////////////////////////////////////////////////////////////////////////
9b5f1895 2// Name: src/motif/dnd.cpp
2d120f83 3// Purpose: wxDropTarget, wxDropSource classes
4bb6408c 4// Author: Julian Smart
4bb6408c 5// Copyright: (c) 1998 Julian Smart
9b5f1895 6// Licence: wxWindows licence
4bb6408c
JS
7///////////////////////////////////////////////////////////////////////////////
8
1248b41f
MB
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
11
2d120f83
JS
12#if wxUSE_DRAG_AND_DROP
13
4bb6408c 14#include "wx/dnd.h"
88a7a4e1
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/intl.h"
e4db172a 18 #include "wx/log.h"
670f9935 19 #include "wx/app.h"
de6185e2 20 #include "wx/utils.h"
cdccdfab 21 #include "wx/window.h"
dd05139a 22 #include "wx/gdicmn.h"
88a7a4e1
WS
23#endif
24
2d120f83 25#include <X11/Xlib.h>
4bb6408c
JS
26
27// ----------------------------------------------------------------------------
28// global
29// ----------------------------------------------------------------------------
30
31// ----------------------------------------------------------------------------
32// wxDropTarget
33// ----------------------------------------------------------------------------
34
35wxDropTarget::wxDropTarget()
36{
2d120f83 37}
4bb6408c
JS
38
39wxDropTarget::~wxDropTarget()
40{
2d120f83 41}
4bb6408c
JS
42
43// ----------------------------------------------------------------------------
44// wxTextDropTarget
45// ----------------------------------------------------------------------------
46
2d120f83 47bool wxTextDropTarget::OnDrop( long x, long y, const void *data, size_t WXUNUSED(size) )
4bb6408c 48{
2d120f83 49 OnDropText( x, y, (const char*)data );
96be256b 50 return true;
2d120f83 51}
4bb6408c
JS
52
53bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
54{
2d120f83
JS
55 wxLogDebug( "Got dropped text: %s.", psz );
56 wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
96be256b 57 return true;
2d120f83 58}
4bb6408c
JS
59
60size_t wxTextDropTarget::GetFormatCount() const
61{
62 return 1;
63}
64
65wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
66{
67 return wxDF_TEXT;
68}
69
70// ----------------------------------------------------------------------------
71// wxFileDropTarget
72// ----------------------------------------------------------------------------
73
2d120f83 74bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const aszFiles[] )
4bb6408c 75{
2d120f83
JS
76 wxLogDebug( "Got %d dropped files.", (int)nFiles );
77 wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
4dba84be
JS
78 size_t i;
79 for (i = 0; i < nFiles; i++)
2d120f83
JS
80 {
81 wxLogDebug( aszFiles[i] );
82 }
96be256b 83 return true;
4bb6408c
JS
84}
85
2d120f83 86bool wxFileDropTarget::OnDrop(long x, long y, const void *data, size_t size )
4bb6408c 87{
2d120f83
JS
88 size_t number = 0;
89 char *text = (char*) data;
4dba84be
JS
90 size_t i;
91 for (i = 0; i < size; i++)
2d120f83
JS
92 if (text[i] == 0) number++;
93
9b5f1895
WS
94 if (number == 0) return true;
95
2d120f83 96 char **files = new char*[number];
9b5f1895 97
2d120f83 98 text = (char*) data;
4dba84be 99 for ( i = 0; i < number; i++)
2d120f83
JS
100 {
101 files[i] = text;
102 int len = strlen( text );
103 text += len+1;
104 }
105
9b5f1895
WS
106 bool ret = OnDropFiles( x, y, 1, files );
107
2d120f83 108 free( files );
9b5f1895 109
2d120f83 110 return ret;
4bb6408c
JS
111}
112
113size_t wxFileDropTarget::GetFormatCount() const
114{
115 return 1;
116}
117
118wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
119{
120 return wxDF_FILENAME;
121}
122
123//-------------------------------------------------------------------------
124// wxDropSource
125//-------------------------------------------------------------------------
126
4bb6408c
JS
127wxDropSource::wxDropSource( wxWindow *win )
128{
2d120f83
JS
129#if 0
130 m_window = win;
d3b9f782 131 m_data = NULL;
2d120f83 132 m_retValue = wxDragCancel;
4bb6408c 133
2d120f83
JS
134 m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
135 m_goaheadCursor = wxCursor( wxCURSOR_HAND );
136#endif
137}
4bb6408c
JS
138
139wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
140{
2d120f83 141#if 0
96be256b 142 g_blockEventsOnDrag = true;
9b5f1895 143
2d120f83
JS
144 m_window = win;
145 m_widget = win->m_widget;
146 if (win->m_wxwindow) m_widget = win->m_wxwindow;
147 m_retValue = wxDragCancel;
9b5f1895 148
2d120f83
JS
149 m_data = &data;
150
151 m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
152 m_goaheadCursor = wxCursor( wxCURSOR_HAND );
153#endif
154}
4bb6408c
JS
155
156void wxDropSource::SetData( wxDataObject &data )
157{
2d120f83
JS
158// m_data = &data;
159}
4bb6408c
JS
160
161wxDropSource::~wxDropSource(void)
162{
2d120f83
JS
163// if (m_data) delete m_data;
164}
9b5f1895 165
2245b2b2 166wxDragResult wxDropSource::DoDragDrop( int WXUNUSED(flags) )
4bb6408c 167{
2d120f83
JS
168 // wxASSERT_MSG( m_data, "wxDragSource: no data" );
169
170 return wxDragNone;
171#if 0
172 if (!m_data) return (wxDragResult) wxDragNone;
173 if (m_data->GetDataSize() == 0) return (wxDragResult) wxDragNone;
9b5f1895 174
2d120f83 175 RegisterWindow();
9b5f1895 176
2d120f83 177 // TODO
9b5f1895 178
2d120f83 179 UnregisterWindow();
9b5f1895 180
96be256b 181 g_blockEventsOnDrag = false;
9b5f1895 182
2d120f83
JS
183 return m_retValue;
184#endif
185}
186
187#if 0
188void wxDropSource::RegisterWindow(void)
189{
190 if (!m_data) return;
191
192 wxString formats;
9b5f1895 193
2d120f83 194 wxDataFormat df = m_data->GetPreferredFormat();
9b5f1895
WS
195
196 switch (df)
2d120f83 197 {
9b5f1895 198 case wxDF_TEXT:
2d120f83 199 formats += "text/plain";
9b5f1895 200 break;
2d120f83
JS
201 case wxDF_FILENAME:
202 formats += "file:ALL";
9b5f1895 203 break;
2d120f83
JS
204 default:
205 break;
206 }
9b5f1895 207
2d120f83 208 char *str = WXSTRINGCAST formats;
9b5f1895 209
2d120f83
JS
210 // TODO
211}
4bb6408c 212
2d120f83
JS
213void wxDropSource::UnregisterWindow(void)
214{
215 if (!m_widget) return;
9b5f1895 216
2d120f83
JS
217 // TODO
218}
219#endif
220
8870c26e
JS
221wxPrivateDropTarget::wxPrivateDropTarget()
222{
223 m_id = wxTheApp->GetAppName();
224}
9b5f1895 225
8870c26e
JS
226size_t wxPrivateDropTarget::GetFormatCount() const
227{
228 return 1;
229}
230
231wxDataFormat wxPrivateDropTarget::GetFormat(size_t n) const
232{
233 return wxDF_INVALID;
234}
2d120f83
JS
235
236#endif
237 // wxUSE_DRAG_AND_DROP