+}
+
+void wxDropTarget::OnEnter()
+{
+}
+
+void wxDropTarget::OnLeave()
+{
+}
+
+bool wxDropTarget::OnMove( int x, int y )
+{
+ printf( "generic move %d %d.\n", x, y );
+
+ return TRUE;
+}
+
+bool wxDropTarget::OnDrop( int x, int y )
+{
+ printf( "generic drop %d %d.\n", x, y );
+
+ return TRUE;
+}
+
+bool wxDropTarget::IsSupported( wxDataFormat format )
+{
+ printf( "generic is supported.\n" );
+
+ if (!m_dragContext) return FALSE;
+
+ GList *child = m_dragContext->targets;
+ while (child)
+ {
+ GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
+ char *name = gdk_atom_name( formatAtom );
+ if (name) printf( "Format available: %s.\n", name );
+
+ child = child->next;
+ }
+
+
+ return TRUE;
+}
+
+bool wxDropTarget::GetData( wxDataObject *data )
+{
+ return FALSE;
+}
+
+void wxDropTarget::UnregisterWidget( GtkWidget *widget )
+{
+ wxCHECK_RET( widget != NULL, "unregister widget is NULL" );
+
+ gtk_drag_dest_set( widget,
+ (GtkDestDefaults) 0,
+ (GtkTargetEntry*) NULL,
+ 0,
+ (GdkDragAction) 0 );
+
+ gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
+ GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
+
+ gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
+ GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
+
+ gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
+ GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
+
+ gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
+ GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
+}
+
+void wxDropTarget::RegisterWidget( GtkWidget *widget )
+{
+ wxCHECK_RET( widget != NULL, "register widget is NULL" );
+
+ GtkTargetEntry format;
+ format.info = 0;
+ format.flags = 0;
+ char buf[100];
+ strcpy( buf, "text/plain" );
+ format.target = buf;
+
+ gtk_drag_dest_set( widget,
+ GTK_DEST_DEFAULT_ALL,
+ &format,
+ 1,
+ (GdkDragAction)(GDK_ACTION_COPY | GDK_ACTION_MOVE) );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "drag_leave",
+ GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "drag_motion",
+ GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "drag_drop",
+ GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "drag_data_received",
+ GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
+}
+
+//-------------------------------------------------------------------------
+// wxTextDropTarget
+//-------------------------------------------------------------------------
+
+bool wxTextDropTarget::OnMove( int WXUNUSED(x), int WXUNUSED(y) )
+{
+ printf( "text move.\n" );
+
+ return IsSupported( wxDF_TEXT ); // same as "TEXT"
+}
+
+bool wxTextDropTarget::OnDrop( int x, int y )
+{
+ printf( "text drop.\n" );
+
+ if (!IsSupported( wxDF_TEXT )) return FALSE;
+
+ wxTextDataObject data;
+ if (!GetData( &data )) return FALSE;
+
+ return OnDropText( x, y, data.GetText() );
+}
+
+//-------------------------------------------------------------------------
+// wxPrivateDropTarget
+//-------------------------------------------------------------------------
+
+wxPrivateDropTarget::wxPrivateDropTarget()
+{
+ m_id = wxTheApp->GetAppName();
+}
+
+wxPrivateDropTarget::wxPrivateDropTarget( const wxString &id )
+{
+ m_id = id;
+}
+
+bool wxPrivateDropTarget::OnMove( int WXUNUSED(x), int WXUNUSED(y) )
+{
+ return IsSupported( m_id );
+}
+
+bool wxPrivateDropTarget::OnDrop( int x, int y )
+{
+ if (!IsSupported( m_id )) return FALSE;
+
+ wxPrivateDataObject data;
+ if (!GetData( &data )) return FALSE;
+
+ return OnDropData( x, y, data.GetData(), data.GetSize() );
+}
+
+//----------------------------------------------------------------------------
+// A drop target which accepts files (dragged from File Manager or Explorer)
+//----------------------------------------------------------------------------
+
+bool wxFileDropTarget::OnMove( int WXUNUSED(x), int WXUNUSED(y) )
+{
+ return IsSupported( wxDF_FILENAME ); // same as "file:ALL"
+}
+
+bool wxFileDropTarget::OnDrop( int x, int y )
+{
+ if (!IsSupported( wxDF_FILENAME )) return FALSE;
+
+ wxFileDataObject data;
+ if (!GetData( &data )) return FALSE;
+
+ /* get number of substrings /root/mytext.txt/0/root/myothertext.txt/0/0 */
+ size_t number = 0;
+ size_t i;
+ size_t size = data.GetFiles().Length();
+ char *text = WXSTRINGCAST data.GetFiles();
+ for ( i = 0; i < size; i++)
+ if (text[i] == 0) number++;
+
+ if (number == 0) return TRUE;
+
+ char **files = new char*[number];
+
+ text = WXSTRINGCAST data.GetFiles();
+ for (i = 0; i < number; i++)
+ {
+ files[i] = text;
+ int len = strlen( text );
+ text += len+1;
+ }
+
+ bool ret = OnDropFiles( x, y, number, files );
+
+ free( files );
+
+ return ret;
+}
+
+//-------------------------------------------------------------------------
+// wxDropSource
+//-------------------------------------------------------------------------
+
+
+wxDropSource::wxDropSource( wxWindow *win, const wxIcon &go, const wxIcon &stop )
+{
+ g_blockEventsOnDrag = TRUE;
+
+ m_window = win;
+ m_widget = win->m_widget;
+ if (win->m_wxwindow) m_widget = win->m_wxwindow;
+
+ m_data = (wxDataBroker*) NULL;
+ m_retValue = wxDragCancel;
+
+ m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
+ m_goaheadCursor = wxCursor( wxCURSOR_HAND );
+
+ m_goIcon = go;
+ if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
+ m_stopIcon = stop;
+ if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
+}
+
+wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
+{
+ g_blockEventsOnDrag = TRUE;
+
+ m_window = win;
+ m_widget = win->m_widget;
+ if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_retValue = wxDragCancel;
+
+ if (data)
+ {
+ m_data = new wxDataBroker();
+ m_data->Add( data );
+ }
+ else
+ {
+ m_data = (wxDataBroker*) NULL;
+ }
+
+ m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
+ m_goaheadCursor = wxCursor( wxCURSOR_HAND );
+
+ m_goIcon = go;
+ if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
+ m_stopIcon = stop;
+ if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
+}