+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 );
+}
+
+wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win )
+{
+ g_blockEventsOnDrag = TRUE;
+
+ m_window = win;
+ m_widget = win->m_widget;
+ if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_retValue = wxDragCancel;
+
+ m_data = data;
+
+ m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
+ m_goaheadCursor = wxCursor( wxCURSOR_HAND );
+}
+
+void wxDropSource::SetData( wxDataObject *data )
+{
+ if (m_data) delete m_data;
+
+ if (data)
+ {
+ m_data = new wxDataBroker();
+ m_data->Add( data );
+ }
+ else
+ {
+ m_data = (wxDataBroker*) NULL;
+ }
+}
+
+void wxDropSource::SetData( wxDataBroker *data )
+{
+ if (m_data) delete m_data;
+
+ m_data = data;
+}
+
+wxDropSource::~wxDropSource(void)
+{
+ if (m_data) delete m_data;
+
+ g_blockEventsOnDrag = FALSE;
+}
+
+wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
+{
+ wxASSERT_MSG( m_data, "wxDragSource: no data" );
+
+ if (!m_data) return (wxDragResult) wxDragNone;
+
+ static GtkWidget *drag_icon = (GtkWidget*) NULL;
+ static GtkWidget *drop_icon = (GtkWidget*) NULL;
+
+ GdkPoint hotspot_1 = {0,-5 };
+
+ if (!drag_icon)
+ {
+/*
+ drag_icon = shape_create_icon ( m_stopIcon,
+ 440, 140, 0,0, GTK_WINDOW_POPUP);
+
+ gtk_signal_connect (GTK_OBJECT (drag_icon), "destroy",
+ GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+ &drag_icon);
+
+ gtk_widget_hide (drag_icon);
+*/
+ }
+
+ GdkPoint hotspot_2 = {-5,-5};
+
+ if (!drop_icon)
+ {
+/*
+ drop_icon = shape_create_icon ( m_goIcon,
+ 440, 140, 0,0, GTK_WINDOW_POPUP);
+
+ gtk_signal_connect (GTK_OBJECT (drop_icon), "destroy",
+ GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+ &drop_icon);
+
+ gtk_widget_hide (drop_icon);
+*/
+ }
+
+
+ return FALSE;
+}
+
+void wxDropSource::RegisterWindow(void)
+{
+ if (!m_data) return;
+}
+
+void wxDropSource::UnregisterWindow(void)
+{
+ if (!m_widget) return;
+}
+
+
+#else // NEW_CODE
+
+//----------------------------------------------------------------------------
+// forward
+//----------------------------------------------------------------------------
+
+GtkWidget *shape_create_icon ( const wxIcon &shape,
+ gint x,
+ gint y,
+ gint px,
+ gint py,
+ gint window_type);
+
+//-----------------------------------------------------------------------------
+// globals
+//-----------------------------------------------------------------------------
+
+wxDropSource *gs_currentDropSource = (wxDropSource*) NULL;
+
+//-----------------------------------------------------------------------------
+// "drop_enter_event"
+//-----------------------------------------------------------------------------
+
+static void gtk_target_enter_callback( GtkWidget *WXUNUSED(widget),
+ GdkEventDropEnter *WXUNUSED(event),
+ wxDropTarget *target )
+{
+ if (target)
+ target->OnEnter();
+}
+
+//-----------------------------------------------------------------------------
+// "drop_leave_event"
+//-----------------------------------------------------------------------------
+
+static void gtk_target_leave_callback( GtkWidget *WXUNUSED(widget),
+ GdkEventDropLeave *WXUNUSED(event),
+ wxDropTarget *target )
+{
+ if (target)
+ target->OnLeave();
+}
+
+//-----------------------------------------------------------------------------
+// "drop_data_available_event"
+//-----------------------------------------------------------------------------
+
+static void gtk_target_callback( GtkWidget *widget,
+ GdkEventDropDataAvailable *event,
+ wxDropTarget *target )
+{
+ if (target)
+ {
+ int x = 0;
+ int y = 0;
+ gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL );
+/*
+ printf( "Drop data is of type %s.\n", event->data_type );
+*/
+ target->OnDrop( x, y, (const void*)event->data, (size_t)event->data_numbytes );
+ }
+
+/*
+ g_free (event->data);
+ g_free (event->data_type);
+*/
+}
+
+// ----------------------------------------------------------------------------
+// wxDropTarget
+// ----------------------------------------------------------------------------
+
+wxDropTarget::wxDropTarget()
+{
+ m_format = (wxDataFormat*) NULL;
+}
+
+wxDropTarget::~wxDropTarget()
+{
+ if (m_format) delete m_format;
+}
+
+wxDataFormat &wxDropTarget::GetFormat(size_t n) const
+{
+ return (*m_format);