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