//----------------------------------------------------------------------------
// global data
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// global data
//----------------------------------------------------------------------------
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" ......................... "};
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" ......................... "};
// ----------------------------------------------------------------------------
// "drag_leave"
// ----------------------------------------------------------------------------
static void target_drag_leave( GtkWidget *WXUNUSED(widget),
// ----------------------------------------------------------------------------
// "drag_leave"
// ----------------------------------------------------------------------------
static void target_drag_leave( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- guint WXUNUSED(time),
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ guint WXUNUSED(time),
+ wxDropTarget *drop_target )
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
}
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
}
// ----------------------------------------------------------------------------
static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
// ----------------------------------------------------------------------------
static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ wxDropTarget *drop_target )
/* Owen Taylor: "if the coordinates not in a drop zone,
return FALSE, otherwise call gtk_drag_status() and
return TRUE" */
/* Owen Taylor: "if the coordinates not in a drop zone,
return FALSE, otherwise call gtk_drag_status() and
return TRUE" */
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
/* give program a chance to react (i.e. to say no by returning FALSE) */
bool ret = drop_target->OnMove( x, y );
/* give program a chance to react (i.e. to say no by returning FALSE) */
bool ret = drop_target->OnMove( x, y );
/* we don't yet handle which "actions" (i.e. copy or move)
the target accepts. so far we simply accept the
suggested action. TODO. */
if (ret)
gdk_drag_status( context, context->suggested_action, time );
/* we don't yet handle which "actions" (i.e. copy or move)
the target accepts. so far we simply accept the
suggested action. TODO. */
if (ret)
gdk_drag_status( context, context->suggested_action, time );
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
// ----------------------------------------------------------------------------
static gboolean target_drag_drop( GtkWidget *widget,
// ----------------------------------------------------------------------------
static gboolean target_drag_drop( GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ wxDropTarget *drop_target )
/* Owen Taylor: "if the drop is not in a drop zone,
return FALSE, otherwise, if you aren't accepting
the drop, call gtk_drag_finish() with success == FALSE
otherwise call gtk_drag_data_get()" */
// printf( "drop.\n" );
/* Owen Taylor: "if the drop is not in a drop zone,
return FALSE, otherwise, if you aren't accepting
the drop, call gtk_drag_finish() with success == FALSE
otherwise call gtk_drag_data_get()" */
// printf( "drop.\n" );
/* this seems to make a difference between not accepting
due to wrong target area and due to wrong format. let
us hope that this is not required.. */
/* this seems to make a difference between not accepting
due to wrong target area and due to wrong format. let
us hope that this is not required.. */
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
/* inform the wxDropTarget about the current drag widget.
this is only valid for the duration of this call */
drop_target->SetDragWidget( widget );
/* inform the wxDropTarget about the current drag widget.
this is only valid for the duration of this call */
drop_target->SetDragWidget( widget );
/* inform the wxDropTarget about the current drag time.
this is only valid for the duration of this call */
drop_target->SetDragTime( time );
/* inform the wxDropTarget about the current drag time.
this is only valid for the duration of this call */
drop_target->SetDragTime( time );
if (!ret)
{
/* cancel the whole thing */
gtk_drag_finish( context,
if (!ret)
{
/* cancel the whole thing */
gtk_drag_finish( context,
- FALSE, /* no success */
- FALSE, /* don't delete data on dropping side */
- time );
+ FALSE, /* no success */
+ FALSE, /* don't delete data on dropping side */
+ time );
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
/* after this, invalidate the drop_target's drag widget */
drop_target->SetDragWidget( (GtkWidget*) NULL );
/* after this, invalidate the drop_target's drag widget */
drop_target->SetDragWidget( (GtkWidget*) NULL );
// ----------------------------------------------------------------------------
static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
// ----------------------------------------------------------------------------
static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint WXUNUSED(info),
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *data,
+ guint WXUNUSED(info),
+ guint time,
+ wxDropTarget *drop_target )
if ((data->length <= 0) || (data->format != 8))
{
/* negative data length and non 8-bit data format
qualifies for junk */
gtk_drag_finish (context, FALSE, FALSE, time);
if ((data->length <= 0) || (data->format != 8))
{
/* negative data length and non 8-bit data format
qualifies for junk */
gtk_drag_finish (context, FALSE, FALSE, time);
/* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */
drop_target->SetDragData( data );
/* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */
drop_target->SetDragData( data );
gtk_drag_finish( context, TRUE, FALSE, time );
}
else
{
gtk_drag_finish( context, TRUE, FALSE, time );
}
else
{
gtk_drag_finish( context, FALSE, FALSE, time );
}
gtk_drag_finish( context, FALSE, FALSE, time );
}
/* after this, invalidate the drop_target's drag data */
drop_target->SetDragData( (GtkSelectionData*) NULL );
}
/* after this, invalidate the drop_target's drag data */
drop_target->SetDragData( (GtkSelectionData*) NULL );
}
/*
wxPrintf( _T("format: %s.\n"), format.GetId().c_str() );
if (format.GetType() == wxDF_PRIVATE) wxPrintf( _T("private data.\n") );
/*
wxPrintf( _T("format: %s.\n"), format.GetId().c_str() );
if (format.GetType() == wxDF_PRIVATE) wxPrintf( _T("private data.\n") );
// char *name = gdk_atom_name( formatAtom );
// if (name) printf( "Format available: %s.\n", name );
// char *name = gdk_atom_name( formatAtom );
// if (name) printf( "Format available: %s.\n", name );
if (data_object->GetFormat().GetType() == wxDF_TEXT)
{
wxTextDataObject *text_object = (wxTextDataObject*)data_object;
text_object->SetText( (const char*)m_dragData->data );
} else
if (data_object->GetFormat().GetType() == wxDF_TEXT)
{
wxTextDataObject *text_object = (wxTextDataObject*)data_object;
text_object->SetText( (const char*)m_dragData->data );
} else
- wxPrivateDataObject *priv_object = (wxPrivateDataObject*)data_object;
- priv_object->SetData( (const char*)m_dragData->data, (size_t)m_dragData->length );
+ wxPrivateDataObject *priv_object = (wxPrivateDataObject*)data_object;
+ priv_object->SetData( (const char*)m_dragData->data, (size_t)m_dragData->length );
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
{
wxCHECK_RET( widget != NULL, _T("unregister widget is NULL") );
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
{
wxCHECK_RET( widget != NULL, _T("unregister widget is NULL") );
}
void wxDropTarget::RegisterWidget( GtkWidget *widget )
{
wxCHECK_RET( widget != NULL, _T("register widget is NULL") );
}
void wxDropTarget::RegisterWidget( GtkWidget *widget )
{
wxCHECK_RET( widget != NULL, _T("register widget is NULL") );
/* gtk_drag_dest_set() determines what default behaviour we'd like
GTK to supply. we don't want to specify out targets (=formats)
or actions in advance (i.e. not GTK_DEST_DEFAULT_MOTION and
not GTK_DEST_DEFAULT_DROP). instead we react individually to
"drag_motion" and "drag_drop" events. this makes it possible
/* gtk_drag_dest_set() determines what default behaviour we'd like
GTK to supply. we don't want to specify out targets (=formats)
or actions in advance (i.e. not GTK_DEST_DEFAULT_MOTION and
not GTK_DEST_DEFAULT_DROP). instead we react individually to
"drag_motion" and "drag_drop" events. this makes it possible
GTK_DEST_DEFAULT_HIGHLIGHT as this will switch on the nice
highlighting if dragging over standard controls, but this
seems to be broken without the other two. */
GTK_DEST_DEFAULT_HIGHLIGHT as this will switch on the nice
highlighting if dragging over standard controls, but this
seems to be broken without the other two. */
- (GtkDestDefaults) 0, /* no default behaviour */
- (GtkTargetEntry*) NULL, /* we don't supply any formats here */
- 0, /* number of targets = 0 */
- (GdkDragAction) 0 ); /* we don't supply any actions here */
-
+ (GtkDestDefaults) 0, /* no default behaviour */
+ (GtkTargetEntry*) NULL, /* we don't supply any formats here */
+ 0, /* number of targets = 0 */
+ (GdkDragAction) 0 ); /* we don't supply any actions here */
+
}
//-------------------------------------------------------------------------
// wxTextDropTarget
//-------------------------------------------------------------------------
}
//-------------------------------------------------------------------------
// wxTextDropTarget
//-------------------------------------------------------------------------
OnDropData( x, y, data.GetData(), data.GetSize() );
OnDropData( x, y, data.GetData(), data.GetSize() );
// A drop target which accepts files (dragged from File Manager or Explorer)
//----------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
//----------------------------------------------------------------------------
- OnDropFiles( x, y, number, files );
-
+ OnDropFiles( x, y, number, files );
+
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint WXUNUSED(info),
- guint WXUNUSED(time),
- wxDropSource *drop_source )
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint WXUNUSED(info),
+ guint WXUNUSED(time),
+ wxDropSource *drop_source )
// printf( "Provide data!\n" );
// char *name = gdk_atom_name( selection_data->target );
// if (name) printf( "Format requested: %s.\n", name );
// printf( "Provide data!\n" );
// char *name = gdk_atom_name( selection_data->target );
// if (name) printf( "Format requested: %s.\n", name );
wxNode *node = drop_source->m_data->m_dataObjects.First();
while (node)
{
wxDataObject *data_object = (wxDataObject*) node->Data();
wxNode *node = drop_source->m_data->m_dataObjects.First();
while (node)
{
wxDataObject *data_object = (wxDataObject*) node->Data();
- if (data_object->GetFormat().GetAtom() == selection_data->target)
- {
-// printf( "format found.\n" );
-
- size_t data_size = data_object->GetSize();
-
- if (data_size > 0)
- {
-// printf( "data size: %d.\n", (int)data_size );
-
- guchar *buffer = new guchar[data_size];
- data_object->WriteData( buffer );
-
+ if (data_object->GetFormat().GetAtom() == selection_data->target)
+ {
+// printf( "format found.\n" );
+
+ size_t data_size = data_object->GetSize();
+
+ if (data_size > 0)
+ {
+// printf( "data size: %d.\n", (int)data_size );
+
+ guchar *buffer = new guchar[data_size];
+ data_object->WriteData( buffer );
+
- selection_data->target,
- 8, /* 8-bit */
- buffer,
- data_size );
-
- free( buffer );
-
- /* so far only copy, no moves. TODO. */
+ selection_data->target,
+ 8, // 8-bit
+ buffer,
+ data_size );
+
+ free( buffer );
+
+ /* so far only copy, no moves. TODO. */
//----------------------------------------------------------------------------
// "drag_data_delete"
//----------------------------------------------------------------------------
static void source_drag_data_delete( GtkWidget *WXUNUSED(widget),
//----------------------------------------------------------------------------
// "drag_data_delete"
//----------------------------------------------------------------------------
static void source_drag_data_delete( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *drop_source )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *drop_source )
//----------------------------------------------------------------------------
// "drag_begin"
//----------------------------------------------------------------------------
static void source_drag_begin( GtkWidget *WXUNUSED(widget),
//----------------------------------------------------------------------------
// "drag_begin"
//----------------------------------------------------------------------------
static void source_drag_begin( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *WXUNUSED(drop_source) )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *WXUNUSED(drop_source) )
//----------------------------------------------------------------------------
// "drag_end"
//----------------------------------------------------------------------------
static void source_drag_end( GtkWidget *WXUNUSED(widget),
//----------------------------------------------------------------------------
// "drag_end"
//----------------------------------------------------------------------------
static void source_drag_end( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *drop_source )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *drop_source )
//---------------------------------------------------------------------------
// wxDropSource
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// wxDropSource
//---------------------------------------------------------------------------
m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
m_waiting = TRUE;
wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
m_waiting = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
wxASSERT_MSG( m_data, _T("wxDragSource: no data") );
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
wxASSERT_MSG( m_data, _T("wxDragSource: no data") );
- gtk_target_list_add( target_list, gdk_atom_intern( "STRING", FALSE ), 0, 0 );
-
+ gtk_target_list_add( target_list, atom, 0, 0 );
+
/* GTK wants to know which button was pressed which caused the dragging */
int button_number = 0;
if (event.state & GDK_BUTTON1_MASK) button_number = 1;
/* GTK wants to know which button was pressed which caused the dragging */
int button_number = 0;
if (event.state & GDK_BUTTON1_MASK) button_number = 1;
wxMask *mask = m_goIcon.GetMask();
GdkBitmap *bm = (GdkBitmap *) NULL;
if (mask) bm = mask->GetBitmap();
wxMask *mask = m_goIcon.GetMask();
GdkBitmap *bm = (GdkBitmap *) NULL;
if (mask) bm = mask->GetBitmap();
- gtk_widget_get_colormap( m_widget ),
- pm,
- bm,
- 0,
- 0 );
-
- while (m_waiting) wxYield();
+ gtk_widget_get_colormap( m_widget ),
+ pm,
+ bm,
+ 0,
+ 0 );
+
+ while (m_waiting) gtk_main_iteration();;