extern void wxapp_install_idle_handler();
extern bool g_isIdle;
-//-----------------------------------------------------------------------------
-// thread system
-//-----------------------------------------------------------------------------
-
-#if wxUSE_THREADS
-#endif
-
//----------------------------------------------------------------------------
// global data
//----------------------------------------------------------------------------
// the trace mask we use with wxLogTrace() - call
// wxLog::AddTraceMask(TRACE_DND) to enable the trace messages from here
// (there are quite a few of them, so don't enable this by default)
-static const wxChar *TRACE_DND = _T("dnd");
+#define TRACE_DND wxT("dnd")
+// global variables because GTK+ DnD want to have the
+// mouse event that caused it
extern GdkEvent *g_lastMouseEvent;
-
extern int g_lastButtonNumber;
//----------------------------------------------------------------------------
drop_target->m_firstMotion = true;
/* after this, invalidate the drop_target's GdkDragContext */
- drop_target->SetDragContext( (GdkDragContext*) NULL );
+ drop_target->SetDragContext( NULL );
}
}
}
/* after this, invalidate the drop_target's GdkDragContext */
- drop_target->SetDragContext( (GdkDragContext*) NULL );
+ drop_target->SetDragContext( NULL );
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = false;
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, wxT("no matching GdkAtom for format?") );
/*
GdkDragAction action = GDK_ACTION_MOVE;
}
/* after this, invalidate the drop_target's GdkDragContext */
- drop_target->SetDragContext( (GdkDragContext*) NULL );
+ drop_target->SetDragContext( NULL );
/* after this, invalidate the drop_target's drag widget */
- drop_target->SetDragWidget( (GtkWidget*) NULL );
+ drop_target->SetDragWidget( NULL );
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = true;
}
/* after this, invalidate the drop_target's drag data */
- drop_target->SetDragData( (GtkSelectionData*) NULL );
+ drop_target->SetDragData( NULL );
}
}
: wxDropTargetBase( data )
{
m_firstMotion = true;
- m_dragContext = (GdkDragContext*) NULL;
- m_dragWidget = (GtkWidget*) NULL;
- m_dragData = (GtkSelectionData*) NULL;
+ m_dragContext = NULL;
+ m_dragWidget = NULL;
+ m_dragData = NULL;
m_dragTime = 0;
}
{
// GetMatchingPair() checks for m_dataObject too, no need to do it here
- // disable the debug message from GetMatchingPair() - there are too many
- // of them otherwise
-#ifdef __WXDEBUG__
- wxLogNull noLog;
-#endif // Debug
-
- return (GetMatchingPair() != (GdkAtom) 0) ? def : wxDragNone;
+ // disable the debug message from GetMatchingPair() by passing true to it
+ return (GetMatchingPair(true) != (GdkAtom) 0) ? def : wxDragNone;
}
bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
return GetData() ? def : wxDragNone;
}
-GdkAtom wxDropTarget::GetMatchingPair()
+GdkAtom wxDropTarget::GetMatchingPair(bool quiet)
{
if (!m_dataObject)
return (GdkAtom) 0;
GdkAtom formatAtom = GPOINTER_TO_INT(child->data);
wxDataFormat format( formatAtom );
-#ifdef __WXDEBUG__
- wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"),
- format.GetId().c_str());
-#endif // Debug
+ if ( !quiet )
+ {
+ wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"),
+ format.GetId().c_str());
+ }
if (m_dataObject->IsSupportedFormat( format ))
return formatAtom;
gtk_drag_dest_set( widget,
(GtkDestDefaults) 0, /* no default behaviour */
- (GtkTargetEntry*) NULL, /* we don't supply any formats here */
+ NULL, /* we don't supply any formats here */
0, /* number of targets = 0 */
(GdkDragAction) 0 ); /* we don't supply any actions here */
extern "C" {
static void source_drag_data_delete( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
+ GdkDragContext *WXUNUSED(context),
wxDropSource *WXUNUSED(drop_source) )
{
if (g_isIdle)
{
m_waiting = true;
- m_iconWindow = (GtkWidget*) NULL;
+ m_iconWindow = NULL;
m_window = win;
m_widget = win->m_widget;
SetData( data );
- m_iconWindow = (GtkWidget*) NULL;
+ m_iconWindow = NULL;
m_window = win;
m_widget = win->m_widget;
m_iconMove = iconMove;
m_iconNone = iconNone;
- if ( !m_iconCopy.Ok() )
+ if ( !m_iconCopy.IsOk() )
m_iconCopy = wxIcon(page_xpm);
- if ( !m_iconMove.Ok() )
+ if ( !m_iconMove.IsOk() )
m_iconMove = m_iconCopy;
- if ( !m_iconNone.Ok() )
+ if ( !m_iconNone.IsOk() )
m_iconNone = m_iconCopy;
}
if ( icon->GetMask() )
mask = icon->GetMask()->GetBitmap();
else
- mask = (GdkBitmap *)NULL;
+ mask = NULL;
GdkPixmap *pixmap = icon->GetPixmap();
if (g_blockEventsOnDrag)
return wxDragNone;
+ // don't start dragging if no button is down
+ if (g_lastButtonNumber == 0)
+ return wxDragNone;
+
+ // we can only start a drag after a mouse event
+ if (g_lastMouseEvent == NULL)
+ return wxDragNone;
+
// disabled for now
g_blockEventsOnDrag = true;
m_waiting = true;
- GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
+ GtkTargetList *target_list = gtk_target_list_new( NULL, 0 );
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
m_data->GetAllFormats( array );
}
delete[] array;
- /* don't start dragging if no button is down */
- if (g_lastButtonNumber)
- {
int action = GDK_ACTION_COPY;
if ( flags & wxDrag_AllowMove )
action |= GDK_ACTION_MOVE;
m_retValue = ConvertFromGTK(context->action);
if ( m_retValue == wxDragNone )
m_retValue = wxDragCancel;
- }
g_blockEventsOnDrag = false;