1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDropTarget class
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "dnd.h"
16 #if wxUSE_DRAG_AND_DROP
18 #include "wx/window.h"
20 #include "wx/gdicmn.h"
26 #include "gdk/gdkprivate.h"
28 #include "gtk/gtkdnd.h"
29 #include "gtk/gtkselection.h"
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 extern void wxapp_install_idle_handler();
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
43 extern void wxapp_install_thread_wakeup();
44 extern void wxapp_uninstall_thread_wakeup();
47 //----------------------------------------------------------------------------
49 //----------------------------------------------------------------------------
51 extern bool g_blockEventsOnDrag
;
53 //----------------------------------------------------------------------------
55 //----------------------------------------------------------------------------
58 static char * gv_xpm
[] = {
72 " ....XX....XX....XX. ",
73 " .XXX.XXX..XXXX..XXX.... ",
74 " .XXXXXXXXXXXXXXXXXXX.XXX. ",
75 " .XXXXXXXXXXXXXXXXXXXXXXXX. ",
76 " .XXXXXXXXXXXXXXXXXXXXXXXX. ",
77 " ..XXXXXXXXXXXXXXXXXXXXXX. ",
78 " .XXXXXXXXXXXXXXXXXX... ",
79 " ..XXXXXXXXXXXXXXXX. ",
80 " .XXXXXXXXXXXXXXXX. ",
81 " .XXXXXXXXXXXXXXXX. ",
82 " .XXXXXXXXXXXXXXXXX. ",
83 " .XXXXXXXXXXXXXXXXX. ",
84 " .XXXXXXXXXXXXXXXXXX. ",
85 " .XXXXXXXXXXXXXXXXXXX. ",
86 " .XXXXXXXXXXXXXXXXXXXXX. ",
87 " .XXXXXXXXXXXXXX.XXXXXXX. ",
88 " .XXXXXXX.XXXXXXX.XXXXXXX. ",
89 " .XXXXXXXX.XXXXXXX.XXXXXXX. ",
90 " .XXXXXXX...XXXXX...XXXXX. ",
91 " .XXXXXXX. ..... ..... ",
99 static char * page_xpm
[] = {
100 /* width height ncolors chars_per_pixel */
109 " ................... ",
110 " .XXXXXXXXXXXXXXXXX.. ",
111 " .XXXXXXXXXXXXXXXXX.o. ",
112 " .XXXXXXXXXXXXXXXXX.oo. ",
113 " .XXXXXXXXXXXXXXXXX.ooo. ",
114 " .XXXXXXXXXXXXXXXXX.oooo. ",
115 " .XXXXXXXXXXXXXXXXX....... ",
116 " .XXXXXOOOOOOOOOOXXXooooo. ",
117 " .XXXXXXXXXXXXXXXXXXooooo. ",
118 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
119 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
120 " .XXXXXXXOOOOOOOOOXXXXXXX. ",
121 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
122 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
123 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
124 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
125 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
126 " .XXXXXXXOOOOOOOOOXXXXXXX. ",
127 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
128 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
129 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
130 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
131 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
132 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
133 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
134 " .XXXXXOOOOOOOXXXXXXXXXXX. ",
135 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
136 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
137 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
138 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
139 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
140 " ......................... "};
144 // ----------------------------------------------------------------------------
146 // ----------------------------------------------------------------------------
148 static void target_drag_leave( GtkWidget
*WXUNUSED(widget
),
149 GdkDragContext
*context
,
150 guint
WXUNUSED(time
),
151 wxDropTarget
*drop_target
)
153 if (g_isIdle
) wxapp_install_idle_handler();
155 /* inform the wxDropTarget about the current GdkDragContext.
156 this is only valid for the duration of this call */
157 drop_target
->SetDragContext( context
);
159 /* we don't need return values. this event is just for
161 drop_target
->OnLeave();
163 /* this has to be done because GDK has no "drag_enter" event */
164 drop_target
->m_firstMotion
= TRUE
;
166 /* after this, invalidate the drop_target's GdkDragContext */
167 drop_target
->SetDragContext( (GdkDragContext
*) NULL
);
170 // ----------------------------------------------------------------------------
172 // ----------------------------------------------------------------------------
174 static gboolean
target_drag_motion( GtkWidget
*WXUNUSED(widget
),
175 GdkDragContext
*context
,
179 wxDropTarget
*drop_target
)
181 if (g_isIdle
) wxapp_install_idle_handler();
183 /* Owen Taylor: "if the coordinates not in a drop zone,
184 return FALSE, otherwise call gtk_drag_status() and
187 /* inform the wxDropTarget about the current GdkDragContext.
188 this is only valid for the duration of this call */
189 drop_target
->SetDragContext( context
);
191 if (drop_target
->m_firstMotion
)
193 /* the first "drag_motion" event substitutes a "drag_enter" event */
194 drop_target
->OnEnter();
197 /* give program a chance to react (i.e. to say no by returning FALSE) */
198 bool ret
= drop_target
->OnMove( x
, y
);
200 /* we don't yet handle which "actions" (i.e. copy or move)
201 the target accepts. so far we simply accept the
202 suggested action. TODO. */
204 gdk_drag_status( context
, context
->suggested_action
, time
);
206 /* after this, invalidate the drop_target's GdkDragContext */
207 drop_target
->SetDragContext( (GdkDragContext
*) NULL
);
209 /* this has to be done because GDK has no "drag_enter" event */
210 drop_target
->m_firstMotion
= FALSE
;
215 // ----------------------------------------------------------------------------
217 // ----------------------------------------------------------------------------
219 static gboolean
target_drag_drop( GtkWidget
*widget
,
220 GdkDragContext
*context
,
224 wxDropTarget
*drop_target
)
226 if (g_isIdle
) wxapp_install_idle_handler();
228 /* Owen Taylor: "if the drop is not in a drop zone,
229 return FALSE, otherwise, if you aren't accepting
230 the drop, call gtk_drag_finish() with success == FALSE
231 otherwise call gtk_drag_data_get()" */
233 // printf( "drop.\n" );
235 /* this seems to make a difference between not accepting
236 due to wrong target area and due to wrong format. let
237 us hope that this is not required.. */
239 /* inform the wxDropTarget about the current GdkDragContext.
240 this is only valid for the duration of this call */
241 drop_target
->SetDragContext( context
);
243 /* inform the wxDropTarget about the current drag widget.
244 this is only valid for the duration of this call */
245 drop_target
->SetDragWidget( widget
);
247 /* inform the wxDropTarget about the current drag time.
248 this is only valid for the duration of this call */
249 drop_target
->SetDragTime( time
);
251 bool ret
= drop_target
->OnDrop( x
, y
);
255 /* cancel the whole thing */
256 gtk_drag_finish( context
,
257 FALSE
, /* no success */
258 FALSE
, /* don't delete data on dropping side */
262 /* after this, invalidate the drop_target's GdkDragContext */
263 drop_target
->SetDragContext( (GdkDragContext
*) NULL
);
265 /* after this, invalidate the drop_target's drag widget */
266 drop_target
->SetDragWidget( (GtkWidget
*) NULL
);
268 /* this has to be done because GDK has no "drag_enter" event */
269 drop_target
->m_firstMotion
= TRUE
;
274 // ----------------------------------------------------------------------------
275 // "drag_data_received"
276 // ----------------------------------------------------------------------------
278 static void target_drag_data_received( GtkWidget
*WXUNUSED(widget
),
279 GdkDragContext
*context
,
282 GtkSelectionData
*data
,
283 guint
WXUNUSED(info
),
285 wxDropTarget
*drop_target
)
287 if (g_isIdle
) wxapp_install_idle_handler();
289 /* Owen Taylor: "call gtk_drag_finish() with
293 if ((data
->length
<= 0) || (data
->format
!= 8))
295 /* negative data length and non 8-bit data format
296 qualifies for junk */
297 gtk_drag_finish (context
, FALSE
, FALSE
, time
);
302 wxLogDebug( wxT( "Drop target: data received") );
304 /* inform the wxDropTarget about the current GtkSelectionData.
305 this is only valid for the duration of this call */
306 drop_target
->SetDragData( data
);
308 if (drop_target
->OnData( x
, y
))
310 /* tell GTK that data transfer was successfull */
311 gtk_drag_finish( context
, TRUE
, FALSE
, time
);
315 /* tell GTK that data transfer was not successfull */
316 gtk_drag_finish( context
, FALSE
, FALSE
, time
);
319 /* after this, invalidate the drop_target's drag data */
320 drop_target
->SetDragData( (GtkSelectionData
*) NULL
);
323 //----------------------------------------------------------------------------
325 //----------------------------------------------------------------------------
327 wxDropTarget::wxDropTarget()
329 m_firstMotion
= TRUE
;
330 m_dragContext
= (GdkDragContext
*) NULL
;
331 m_dragWidget
= (GtkWidget
*) NULL
;
332 m_dragData
= (GtkSelectionData
*) NULL
;
336 wxDropTarget::~wxDropTarget()
340 void wxDropTarget::OnEnter()
344 void wxDropTarget::OnLeave()
348 bool wxDropTarget::OnMove( long WXUNUSED(x
), long WXUNUSED(y
) )
350 if (GetFormatCount() == 0)
353 for (size_t i
= 0; i
< GetFormatCount(); i
++)
355 if (IsSupported( GetFormat(i
) ))
362 bool wxDropTarget::OnDrop( long WXUNUSED(x
), long WXUNUSED(y
) )
364 if (GetFormatCount() == 0)
367 for (size_t i
= 0; i
< GetFormatCount(); i
++)
369 if (IsSupported( GetFormat(i
) ))
371 RequestData( GetFormat(i
) );
379 bool wxDropTarget::OnData( long WXUNUSED(x
), long WXUNUSED(y
) )
384 bool wxDropTarget::RequestData( wxDataFormat format
)
386 if (!m_dragContext
) return FALSE
;
387 if (!m_dragWidget
) return FALSE
;
390 wxPrintf( wxT("format: %s.\n"), format.GetId().c_str() );
391 if (format.GetType() == wxDF_PRIVATE) wxPrintf( wxT("private data.\n") );
392 if (format.GetType() == wxDF_TEXT) wxPrintf( wxT("text data.\n") );
396 /* disable GUI threads */
397 wxapp_uninstall_thread_wakeup();
400 /* this should trigger an "drag_data_received" event */
401 gtk_drag_get_data( m_dragWidget
,
407 /* re-enable GUI threads */
408 wxapp_install_thread_wakeup();
414 bool wxDropTarget::IsSupported( wxDataFormat format
)
416 if (!m_dragContext
) return FALSE
;
418 GList
*child
= m_dragContext
->targets
;
421 GdkAtom formatAtom
= (GdkAtom
) GPOINTER_TO_INT(child
->data
);
424 char *name
= gdk_atom_name( formatAtom
);
425 if (name
) wxLogDebug( "Drop target: drag has format: %s", name
);
428 if (formatAtom
== format
) return TRUE
;
435 bool wxDropTarget::GetData( wxDataObject
*data_object
)
437 if (!m_dragData
) return FALSE
;
439 if (m_dragData
->target
!= data_object
->GetFormat()) return FALSE
;
441 if (data_object
->GetFormat().GetType() == wxDF_TEXT
)
443 wxTextDataObject
*text_object
= (wxTextDataObject
*)data_object
;
444 text_object
->SetText( (const char*)m_dragData
->data
);
447 if (data_object
->GetFormat().GetType() == wxDF_FILENAME
)
451 if (data_object
->GetFormat().GetType() == wxDF_PRIVATE
)
453 wxPrivateDataObject
*priv_object
= (wxPrivateDataObject
*)data_object
;
454 priv_object
->SetData( (const char*)m_dragData
->data
, (size_t)m_dragData
->length
);
460 void wxDropTarget::UnregisterWidget( GtkWidget
*widget
)
462 wxCHECK_RET( widget
!= NULL
, wxT("unregister widget is NULL") );
464 gtk_drag_dest_unset( widget
);
466 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
467 GTK_SIGNAL_FUNC(target_drag_leave
), (gpointer
) this );
469 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
470 GTK_SIGNAL_FUNC(target_drag_motion
), (gpointer
) this );
472 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
473 GTK_SIGNAL_FUNC(target_drag_drop
), (gpointer
) this );
475 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
476 GTK_SIGNAL_FUNC(target_drag_data_received
), (gpointer
) this );
479 void wxDropTarget::RegisterWidget( GtkWidget
*widget
)
481 wxCHECK_RET( widget
!= NULL
, wxT("register widget is NULL") );
483 /* gtk_drag_dest_set() determines what default behaviour we'd like
484 GTK to supply. we don't want to specify out targets (=formats)
485 or actions in advance (i.e. not GTK_DEST_DEFAULT_MOTION and
486 not GTK_DEST_DEFAULT_DROP). instead we react individually to
487 "drag_motion" and "drag_drop" events. this makes it possible
488 to allow dropping on only a small area. we should set
489 GTK_DEST_DEFAULT_HIGHLIGHT as this will switch on the nice
490 highlighting if dragging over standard controls, but this
491 seems to be broken without the other two. */
493 gtk_drag_dest_set( widget
,
494 (GtkDestDefaults
) 0, /* no default behaviour */
495 (GtkTargetEntry
*) NULL
, /* we don't supply any formats here */
496 0, /* number of targets = 0 */
497 (GdkDragAction
) 0 ); /* we don't supply any actions here */
499 gtk_signal_connect( GTK_OBJECT(widget
), "drag_leave",
500 GTK_SIGNAL_FUNC(target_drag_leave
), (gpointer
) this );
502 gtk_signal_connect( GTK_OBJECT(widget
), "drag_motion",
503 GTK_SIGNAL_FUNC(target_drag_motion
), (gpointer
) this );
505 gtk_signal_connect( GTK_OBJECT(widget
), "drag_drop",
506 GTK_SIGNAL_FUNC(target_drag_drop
), (gpointer
) this );
508 gtk_signal_connect( GTK_OBJECT(widget
), "drag_data_received",
509 GTK_SIGNAL_FUNC(target_drag_data_received
), (gpointer
) this );
512 //-------------------------------------------------------------------------
514 //-------------------------------------------------------------------------
516 bool wxTextDropTarget::OnData( long x
, long y
)
518 wxTextDataObject data
;
519 if (!GetData( &data
)) return FALSE
;
521 OnDropText( x
, y
, data
.GetText() );
526 //-------------------------------------------------------------------------
527 // wxPrivateDropTarget
528 //-------------------------------------------------------------------------
531 wxPrivateDropTarget::wxPrivateDropTarget()
533 m_id = wxTheApp->GetAppName();
536 wxPrivateDropTarget::wxPrivateDropTarget( const wxString &id )
541 bool wxPrivateDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) )
543 return IsSupported( m_id );
546 bool wxPrivateDropTarget::OnDrop( long WXUNUSED(x), long WXUNUSED(y) )
548 if (!IsSupported( m_id ))
557 bool wxPrivateDropTarget::OnData( long x, long y )
559 if (!IsSupported( m_id )) return FALSE;
561 wxPrivateDataObject data;
562 if (!GetData( &data )) return FALSE;
564 OnDropData( x, y, data.GetData(), data.GetSize() );
570 //----------------------------------------------------------------------------
571 // A drop target which accepts files (dragged from File Manager or Explorer)
572 //----------------------------------------------------------------------------
574 bool wxFileDropTarget::OnData( long x
, long y
)
576 wxFileDataObject data
;
577 if (!GetData( &data
)) return FALSE
;
579 // get number of substrings /root/mytext.txt/0/root/myothertext.txt/0/0
582 size_t size
= data
.GetFiles().Length();
583 wxChar
*text
= WXSTRINGCAST data
.GetFiles();
584 for ( i
= 0; i
< size
; i
++)
585 if (text
[i
] == 0) number
++;
587 if (number
== 0) return FALSE
;
589 wxChar
**files
= new wxChar
*[number
];
591 text
= WXSTRINGCAST data
.GetFiles();
592 for (i
= 0; i
< number
; i
++)
595 int len
= wxStrlen( text
);
599 OnDropFiles( x
, y
, number
, files
);
606 //----------------------------------------------------------------------------
608 //----------------------------------------------------------------------------
611 source_drag_data_get (GtkWidget
*WXUNUSED(widget
),
612 GdkDragContext
*context
,
613 GtkSelectionData
*selection_data
,
614 guint
WXUNUSED(info
),
615 guint
WXUNUSED(time
),
616 wxDropSource
*drop_source
)
618 if (g_isIdle
) wxapp_install_idle_handler();
621 char *name
= gdk_atom_name( selection_data
->target
);
622 if (name
) wxLogDebug( wxT("Drop source: format requested: %s"), name
);
625 drop_source
->m_retValue
= wxDragCancel
;
627 wxDataObject
*data
= drop_source
->m_data
;
632 if (!data
->IsSupportedFormat(selection_data
->target
))
635 if (data
->GetDataSize(selection_data
->target
) == 0)
638 size_t size
= data
->GetDataSize(selection_data
->target
);
640 // printf( "data size: %d.\n", (int)data_size );
642 guchar
*d
= new guchar
[size
];
644 if (!data
->GetDataHere( selection_data
->target
, (void*)d
))
651 /* disable GUI threads */
652 wxapp_uninstall_thread_wakeup();
655 gtk_selection_data_set( selection_data
,
656 selection_data
->target
,
662 /* enable GUI threads */
663 wxapp_install_thread_wakeup();
668 /* so far only copy, no moves. TODO. */
669 drop_source
->m_retValue
= wxDragCopy
;
672 //----------------------------------------------------------------------------
673 // "drag_data_delete"
674 //----------------------------------------------------------------------------
676 static void source_drag_data_delete( GtkWidget
*WXUNUSED(widget
),
677 GdkDragContext
*WXUNUSED(context
),
678 wxDropSource
*drop_source
)
680 if (g_isIdle
) wxapp_install_idle_handler();
682 // printf( "Delete the data!\n" );
684 drop_source
->m_retValue
= wxDragMove
;
687 //----------------------------------------------------------------------------
689 //----------------------------------------------------------------------------
691 static void source_drag_begin( GtkWidget
*WXUNUSED(widget
),
692 GdkDragContext
*WXUNUSED(context
),
693 wxDropSource
*WXUNUSED(drop_source
) )
695 if (g_isIdle
) wxapp_install_idle_handler();
697 // printf( "drag_begin.\n" );
700 //----------------------------------------------------------------------------
702 //----------------------------------------------------------------------------
704 static void source_drag_end( GtkWidget
*WXUNUSED(widget
),
705 GdkDragContext
*WXUNUSED(context
),
706 wxDropSource
*drop_source
)
708 if (g_isIdle
) wxapp_install_idle_handler();
710 // printf( "drag_end.\n" );
712 drop_source
->m_waiting
= FALSE
;
715 //---------------------------------------------------------------------------
717 //---------------------------------------------------------------------------
719 wxDropSource::wxDropSource( wxWindow
*win
, const wxIcon
&go
, const wxIcon
&stop
)
721 g_blockEventsOnDrag
= TRUE
;
725 m_widget
= win
->m_widget
;
726 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
728 m_data
= (wxDataObject
*) NULL
;
729 m_retValue
= wxDragCancel
;
731 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
732 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
735 if (wxNullIcon
== go
) m_goIcon
= wxIcon( page_xpm
);
737 if (wxNullIcon
== stop
) m_stopIcon
= wxIcon( gv_xpm
);
740 wxDropSource::wxDropSource( wxDataObject
& data
, wxWindow
*win
,
741 const wxIcon
&go
, const wxIcon
&stop
)
746 m_widget
= win
->m_widget
;
747 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
748 m_retValue
= wxDragCancel
;
752 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
753 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
756 if (wxNullIcon
== go
) m_goIcon
= wxIcon( page_xpm
);
758 if (wxNullIcon
== stop
) m_stopIcon
= wxIcon( gv_xpm
);
761 void wxDropSource::SetData( wxDataObject
& data
)
769 wxDropSource::~wxDropSource()
774 g_blockEventsOnDrag
= FALSE
;
777 wxDragResult
wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove
) )
779 wxASSERT_MSG( m_data
, wxT("wxDragSource: no data") );
782 return (wxDragResult
) wxDragNone
;
784 if (m_data
->GetFormatCount() == 0)
785 return (wxDragResult
) wxDragNone
;
787 g_blockEventsOnDrag
= TRUE
;
793 GtkTargetList
*target_list
= gtk_target_list_new( (GtkTargetEntry
*) NULL
, 0 );
795 wxDataFormat
*array
= new wxDataFormat
[ m_data
->GetFormatCount() ];
796 m_data
->GetAllFormats( array
, TRUE
);
797 for (size_t i
= 0; i
< m_data
->GetFormatCount(); i
++)
799 GdkAtom atom
= array
[i
];
800 wxLogDebug( wxT("Supported atom %s"), gdk_atom_name( atom
) );
801 gtk_target_list_add( target_list
, atom
, 0, 0 );
805 GdkEventMotion event
;
806 event
.window
= m_widget
->window
;
809 GdkModifierType state
;
810 gdk_window_get_pointer( event
.window
, &x
, &y
, &state
);
814 event
.time
= GDK_CURRENT_TIME
;
816 /* GTK wants to know which button was pressed which caused the dragging */
817 int button_number
= 0;
818 if (event
.state
& GDK_BUTTON1_MASK
) button_number
= 1;
819 else if (event
.state
& GDK_BUTTON2_MASK
) button_number
= 2;
820 else if (event
.state
& GDK_BUTTON3_MASK
) button_number
= 3;
823 /* disable GUI threads */
824 wxapp_uninstall_thread_wakeup();
827 /* don't start dragging if no button is down */
830 GdkDragContext
*context
= gtk_drag_begin( m_widget
,
833 button_number
, /* number of mouse button which started drag */
834 (GdkEvent
*) &event
);
836 wxMask
*mask
= m_goIcon
.GetMask();
837 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
838 if (mask
) bm
= mask
->GetBitmap();
839 GdkPixmap
*pm
= m_goIcon
.GetPixmap();
841 gtk_drag_set_icon_pixmap( context
,
842 gtk_widget_get_colormap( m_widget
),
848 while (m_waiting
) gtk_main_iteration();;
852 /* re-enable GUI threads */
853 wxapp_install_thread_wakeup();
856 g_blockEventsOnDrag
= FALSE
;
863 void wxDropSource::RegisterWindow()
865 if (!m_widget
) return;
867 gtk_signal_connect( GTK_OBJECT(m_widget
), "drag_data_get",
868 GTK_SIGNAL_FUNC (source_drag_data_get
), (gpointer
) this);
869 gtk_signal_connect (GTK_OBJECT(m_widget
), "drag_data_delete",
870 GTK_SIGNAL_FUNC (source_drag_data_delete
), (gpointer
) this );
871 gtk_signal_connect (GTK_OBJECT(m_widget
), "drag_begin",
872 GTK_SIGNAL_FUNC (source_drag_begin
), (gpointer
) this );
873 gtk_signal_connect (GTK_OBJECT(m_widget
), "drag_end",
874 GTK_SIGNAL_FUNC (source_drag_end
), (gpointer
) this );
878 void wxDropSource::UnregisterWindow()
880 if (!m_widget
) return;
882 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
883 GTK_SIGNAL_FUNC(source_drag_data_get
), (gpointer
) this );
884 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
885 GTK_SIGNAL_FUNC(source_drag_data_delete
), (gpointer
) this );
886 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
887 GTK_SIGNAL_FUNC(source_drag_begin
), (gpointer
) this );
888 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
889 GTK_SIGNAL_FUNC(source_drag_end
), (gpointer
) this );
894 // wxUSE_DRAG_AND_DROP