///////////////////////////////////////////////////////////////////////////////
-// Name: dnd.cpp
+// Name: src/gtk/dnd.cpp
// Purpose: wxDropTarget class
// Author: Robert Roebling
// Id: $Id$
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "dnd.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
-#include "wx/dnd.h"
-#include "wx/log.h"
-
-
#if wxUSE_DRAG_AND_DROP
-#include "wx/window.h"
-#include "wx/app.h"
+#include "wx/dnd.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/intl.h"
+ #include "wx/log.h"
+ #include "wx/app.h"
+ #include "wx/utils.h"
+ #include "wx/window.h"
+#endif
+
#include "wx/gdicmn.h"
-#include "wx/intl.h"
-#include "wx/utils.h"
#include "wx/gtk/private.h"
#include <gtk/gtkdnd.h>
#include <gtk/gtkselection.h>
-//-----------------------------------------------------------------------------
-// idle system
-//-----------------------------------------------------------------------------
-
-extern void wxapp_install_idle_handler();
-extern bool g_isIdle;
-
-//-----------------------------------------------------------------------------
-// thread system
-//-----------------------------------------------------------------------------
-
-#if wxUSE_THREADS
-#endif
-
//----------------------------------------------------------------------------
// global data
//----------------------------------------------------------------------------
drop_target->OnLeave();
/* this has to be done because GDK has no "drag_enter" event */
- drop_target->m_firstMotion = TRUE;
+ drop_target->m_firstMotion = true;
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
drop_target->SetDragContext( (GdkDragContext*) NULL );
/* this has to be done because GDK has no "drag_enter" event */
- drop_target->m_firstMotion = FALSE;
+ drop_target->m_firstMotion = false;
return ret;
}
/* reset the block here as someone might very well
show a dialog as a reaction to a drop and this
wouldn't work without events */
- g_blockEventsOnDrag = FALSE;
+ g_blockEventsOnDrag = false;
bool ret = drop_target->OnDrop( x, y );
}
else
{
- wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned TRUE") );
+ wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned true") );
#if wxUSE_THREADS
/* disable GUI threads */
GdkAtom format = drop_target->GetMatchingPair();
// this does happen somehow, see bug 555111
- wxCHECK_MSG( format, FALSE, _T("no matching GdkAtom for format?") )
+ wxCHECK_MSG( format, FALSE, _T("no matching GdkAtom for format?") );
/*
GdkDragAction action = GDK_ACTION_MOVE;
drop_target->SetDragWidget( (GtkWidget*) NULL );
/* this has to be done because GDK has no "drag_enter" event */
- drop_target->m_firstMotion = TRUE;
+ drop_target->m_firstMotion = true;
return ret;
}
if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
{
- wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned TRUE") );
+ wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned true") );
/* tell GTK that data transfer was successful */
gtk_drag_finish( context, TRUE, FALSE, time );
wxDropTarget::wxDropTarget( wxDataObject *data )
: wxDropTargetBase( data )
{
- m_firstMotion = TRUE;
+ m_firstMotion = true;
m_dragContext = (GdkDragContext*) NULL;
m_dragWidget = (GtkWidget*) NULL;
m_dragData = (GtkSelectionData*) NULL;
bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
{
if (!m_dataObject)
- return FALSE;
+ return false;
return (GetMatchingPair() != (GdkAtom) 0);
}
GList *child = m_dragContext->targets;
while (child)
{
- GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
+ GdkAtom formatAtom = (GdkAtom)(child->data);
wxDataFormat format( formatAtom );
#ifdef __WXDEBUG__
bool wxDropTarget::GetData()
{
if (!m_dragData)
- return FALSE;
+ return false;
if (!m_dataObject)
- return FALSE;
+ return false;
wxDataFormat dragFormat( m_dragData->target );
if (!m_dataObject->IsSupportedFormat( dragFormat ))
- return FALSE;
+ return false;
m_dataObject->SetData( dragFormat, (size_t)m_dragData->length, (const void*)m_dragData->data );
- return TRUE;
+ return true;
}
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
gtk_drag_dest_unset( widget );
- 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 );
+ g_signal_handlers_disconnect_by_func (widget,
+ (gpointer) target_drag_leave, this);
+ g_signal_handlers_disconnect_by_func (widget,
+ (gpointer) target_drag_motion, this);
+ g_signal_handlers_disconnect_by_func (widget,
+ (gpointer) target_drag_drop, this);
+ g_signal_handlers_disconnect_by_func (widget,
+ (gpointer) target_drag_data_received, this);
}
void wxDropTarget::RegisterWidget( GtkWidget *widget )
0, /* number of targets = 0 */
(GdkDragAction) 0 ); /* we don't supply any actions here */
- gtk_signal_connect( GTK_OBJECT(widget), "drag_leave",
- GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
+ g_signal_connect (widget, "drag_leave",
+ G_CALLBACK (target_drag_leave), this);
- gtk_signal_connect( GTK_OBJECT(widget), "drag_motion",
- GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
+ g_signal_connect (widget, "drag_motion",
+ G_CALLBACK (target_drag_motion), this);
- gtk_signal_connect( GTK_OBJECT(widget), "drag_drop",
- GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
+ g_signal_connect (widget, "drag_drop",
+ G_CALLBACK (target_drag_drop), this);
- gtk_signal_connect( GTK_OBJECT(widget), "drag_data_received",
- GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
+ g_signal_connect (widget, "drag_data_received",
+ G_CALLBACK (target_drag_data_received), this);
}
//----------------------------------------------------------------------------
/* disable GUI threads */
#endif
- gtk_selection_data_set( selection_data,
- selection_data->target,
- 8, // 8-bit
- d,
- size );
+ gtk_selection_data_set( selection_data,
+ selection_data->target,
+ 8, // 8-bit
+ d,
+ size );
#if wxUSE_THREADS
/* enable GUI threads */
// printf( "Drag source: drag_end.\n" );
- drop_source->m_waiting = FALSE;
+ drop_source->m_waiting = false;
}
}
const wxIcon &iconMove,
const wxIcon &iconNone)
{
- m_waiting = TRUE;
+ m_waiting = true;
m_iconWindow = (GtkWidget*) NULL;
const wxIcon &iconMove,
const wxIcon &iconNone)
{
- m_waiting = TRUE;
+ m_waiting = true;
SetData( data );
GdkPixmap *pixmap = icon->GetPixmap();
gint width,height;
- gdk_window_get_size (pixmap, &width, &height);
+ gdk_drawable_get_size (pixmap, &width, &height);
GdkColormap *colormap = gtk_widget_get_colormap( m_widget );
-#ifndef __WXGTK20__
- gtk_widget_push_visual (gdk_colormap_get_visual (colormap));
-#endif
gtk_widget_push_colormap (colormap);
m_iconWindow = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_events (m_iconWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
gtk_widget_set_app_paintable (GTK_WIDGET (m_iconWindow), TRUE);
-#ifndef __WXGTK20__
- gtk_widget_pop_visual ();
-#endif
gtk_widget_pop_colormap ();
- gtk_widget_set_usize (m_iconWindow, width, height);
+ gtk_widget_set_size_request (m_iconWindow, width, height);
gtk_widget_realize (m_iconWindow);
- gtk_signal_connect( GTK_OBJECT(m_iconWindow), "configure_event",
- GTK_SIGNAL_FUNC(gtk_dnd_window_configure_callback), (gpointer)this );
+ g_signal_connect (m_iconWindow, "configure_event",
+ G_CALLBACK (gtk_dnd_window_configure_callback), this);
gdk_window_set_back_pixmap (m_iconWindow->window, pixmap, FALSE);
return wxDragNone;
// disabled for now
- g_blockEventsOnDrag = TRUE;
+ g_blockEventsOnDrag = true;
RegisterWindow();
- m_waiting = TRUE;
+ m_waiting = true;
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
/* re-enable GUI threads */
#endif
- g_blockEventsOnDrag = FALSE;
+ g_blockEventsOnDrag = false;
UnregisterWindow();
{
if (!m_widget) return;
- gtk_signal_connect( GTK_OBJECT(m_widget), "drag_data_get",
- GTK_SIGNAL_FUNC (source_drag_data_get), (gpointer) this);
- gtk_signal_connect (GTK_OBJECT(m_widget), "drag_data_delete",
- GTK_SIGNAL_FUNC (source_drag_data_delete), (gpointer) this );
- gtk_signal_connect (GTK_OBJECT(m_widget), "drag_begin",
- GTK_SIGNAL_FUNC (source_drag_begin), (gpointer) this );
- gtk_signal_connect (GTK_OBJECT(m_widget), "drag_end",
- GTK_SIGNAL_FUNC (source_drag_end), (gpointer) this );
+ g_signal_connect (m_widget, "drag_data_get",
+ G_CALLBACK (source_drag_data_get), this);
+ g_signal_connect (m_widget, "drag_data_delete",
+ G_CALLBACK (source_drag_data_delete), this);
+ g_signal_connect (m_widget, "drag_begin",
+ G_CALLBACK (source_drag_begin), this);
+ g_signal_connect (m_widget, "drag_end",
+ G_CALLBACK (source_drag_end), this);
}
void wxDropSource::UnregisterWindow()
{
- if (!m_widget) return;
+ if (!m_widget)
+ return;
- gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_data_get), (gpointer) this );
- gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_data_delete), (gpointer) this );
- gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_begin), (gpointer) this );
- gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this );
+ g_signal_handlers_disconnect_by_func (m_widget,
+ (gpointer) source_drag_data_get,
+ this);
+ g_signal_handlers_disconnect_by_func (m_widget,
+ (gpointer) source_drag_data_delete,
+ this);
+ g_signal_handlers_disconnect_by_func (m_widget,
+ (gpointer) source_drag_begin,
+ this);
+ g_signal_handlers_disconnect_by_func (m_widget,
+ (gpointer) source_drag_end,
+ this);
}
#endif