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 //----------------------------------------------------------------------------
42 extern bool g_blockEventsOnDrag
;
44 //----------------------------------------------------------------------------
46 //----------------------------------------------------------------------------
49 static char * gv_xpm
[] = {
63 " ....XX....XX....XX. ",
64 " .XXX.XXX..XXXX..XXX.... ",
65 " .XXXXXXXXXXXXXXXXXXX.XXX. ",
66 " .XXXXXXXXXXXXXXXXXXXXXXXX. ",
67 " .XXXXXXXXXXXXXXXXXXXXXXXX. ",
68 " ..XXXXXXXXXXXXXXXXXXXXXX. ",
69 " .XXXXXXXXXXXXXXXXXX... ",
70 " ..XXXXXXXXXXXXXXXX. ",
71 " .XXXXXXXXXXXXXXXX. ",
72 " .XXXXXXXXXXXXXXXX. ",
73 " .XXXXXXXXXXXXXXXXX. ",
74 " .XXXXXXXXXXXXXXXXX. ",
75 " .XXXXXXXXXXXXXXXXXX. ",
76 " .XXXXXXXXXXXXXXXXXXX. ",
77 " .XXXXXXXXXXXXXXXXXXXXX. ",
78 " .XXXXXXXXXXXXXX.XXXXXXX. ",
79 " .XXXXXXX.XXXXXXX.XXXXXXX. ",
80 " .XXXXXXXX.XXXXXXX.XXXXXXX. ",
81 " .XXXXXXX...XXXXX...XXXXX. ",
82 " .XXXXXXX. ..... ..... ",
90 static char * page_xpm
[] = {
91 /* width height ncolors chars_per_pixel */
100 " ................... ",
101 " .XXXXXXXXXXXXXXXXX.. ",
102 " .XXXXXXXXXXXXXXXXX.o. ",
103 " .XXXXXXXXXXXXXXXXX.oo. ",
104 " .XXXXXXXXXXXXXXXXX.ooo. ",
105 " .XXXXXXXXXXXXXXXXX.oooo. ",
106 " .XXXXXXXXXXXXXXXXX....... ",
107 " .XXXXXOOOOOOOOOOXXXooooo. ",
108 " .XXXXXXXXXXXXXXXXXXooooo. ",
109 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
110 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
111 " .XXXXXXXOOOOOOOOOXXXXXXX. ",
112 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
113 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
114 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
115 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
116 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
117 " .XXXXXXXOOOOOOOOOXXXXXXX. ",
118 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
119 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
120 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
121 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
122 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
123 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
124 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
125 " .XXXXXOOOOOOOXXXXXXXXXXX. ",
126 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
127 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
128 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
129 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
130 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
131 " ......................... "};
135 // ----------------------------------------------------------------------------
137 // ----------------------------------------------------------------------------
139 static void target_drag_leave( GtkWidget
*WXUNUSED(widget
),
140 GdkDragContext
*context
,
141 guint
WXUNUSED(time
),
142 wxDropTarget
*drop_target
)
144 if (g_isIdle
) wxapp_install_idle_handler();
146 /* inform the wxDropTarget about the current GdkDragContext.
147 this is only valid for the duration of this call */
148 drop_target
->SetDragContext( context
);
150 /* we don't need return values. this event is just for
152 drop_target
->OnLeave();
154 /* this has to be done because GDK has no "drag_enter" event */
155 drop_target
->m_firstMotion
= TRUE
;
157 /* after this, invalidate the drop_target's GdkDragContext */
158 drop_target
->SetDragContext( (GdkDragContext
*) NULL
);
161 // ----------------------------------------------------------------------------
163 // ----------------------------------------------------------------------------
165 static gboolean
target_drag_motion( GtkWidget
*WXUNUSED(widget
),
166 GdkDragContext
*context
,
170 wxDropTarget
*drop_target
)
172 if (g_isIdle
) wxapp_install_idle_handler();
174 /* Owen Taylor: "if the coordinates not in a drop zone,
175 return FALSE, otherwise call gtk_drag_status() and
178 /* inform the wxDropTarget about the current GdkDragContext.
179 this is only valid for the duration of this call */
180 drop_target
->SetDragContext( context
);
182 if (drop_target
->m_firstMotion
)
184 /* the first "drag_motion" event substitutes a "drag_enter" event */
185 drop_target
->OnEnter();
188 /* give program a chance to react (i.e. to say no by returning FALSE) */
189 bool ret
= drop_target
->OnMove( x
, y
);
191 /* we don't yet handle which "actions" (i.e. copy or move)
192 the target accepts. so far we simply accept the
193 suggested action. TODO. */
195 gdk_drag_status( context
, context
->suggested_action
, time
);
197 /* after this, invalidate the drop_target's GdkDragContext */
198 drop_target
->SetDragContext( (GdkDragContext
*) NULL
);
200 /* this has to be done because GDK has no "drag_enter" event */
201 drop_target
->m_firstMotion
= FALSE
;
206 // ----------------------------------------------------------------------------
208 // ----------------------------------------------------------------------------
210 static gboolean
target_drag_drop( GtkWidget
*widget
,
211 GdkDragContext
*context
,
215 wxDropTarget
*drop_target
)
217 if (g_isIdle
) wxapp_install_idle_handler();
219 /* Owen Taylor: "if the drop is not in a drop zone,
220 return FALSE, otherwise, if you aren't accepting
221 the drop, call gtk_drag_finish() with success == FALSE
222 otherwise call gtk_drag_data_get()" */
224 // printf( "drop.\n" );
226 /* this seems to make a difference between not accepting
227 due to wrong target area and due to wrong format. let
228 us hope that this is not required.. */
230 /* inform the wxDropTarget about the current GdkDragContext.
231 this is only valid for the duration of this call */
232 drop_target
->SetDragContext( context
);
234 /* inform the wxDropTarget about the current drag widget.
235 this is only valid for the duration of this call */
236 drop_target
->SetDragWidget( widget
);
238 /* inform the wxDropTarget about the current drag time.
239 this is only valid for the duration of this call */
240 drop_target
->SetDragTime( time
);
242 bool ret
= drop_target
->OnDrop( x
, y
);
246 /* cancel the whole thing */
247 gtk_drag_finish( context
,
248 FALSE
, /* no success */
249 FALSE
, /* don't delete data on dropping side */
253 /* after this, invalidate the drop_target's GdkDragContext */
254 drop_target
->SetDragContext( (GdkDragContext
*) NULL
);
256 /* after this, invalidate the drop_target's drag widget */
257 drop_target
->SetDragWidget( (GtkWidget
*) NULL
);
259 /* this has to be done because GDK has no "drag_enter" event */
260 drop_target
->m_firstMotion
= TRUE
;
265 // ----------------------------------------------------------------------------
266 // "drag_data_received"
267 // ----------------------------------------------------------------------------
269 static void target_drag_data_received( GtkWidget
*WXUNUSED(widget
),
270 GdkDragContext
*context
,
273 GtkSelectionData
*data
,
274 guint
WXUNUSED(info
),
276 wxDropTarget
*drop_target
)
278 if (g_isIdle
) wxapp_install_idle_handler();
280 /* Owen Taylor: "call gtk_drag_finish() with
283 // printf( "data received.\n" );
285 if ((data
->length
<= 0) || (data
->format
!= 8))
287 /* negative data length and non 8-bit data format
288 qualifies for junk */
289 gtk_drag_finish (context
, FALSE
, FALSE
, time
);
291 // printf( "no data.\n" );
296 /* inform the wxDropTarget about the current GtkSelectionData.
297 this is only valid for the duration of this call */
298 drop_target
->SetDragData( data
);
300 if (drop_target
->OnData( x
, y
))
302 /* tell GTK that data transfer was successfull */
303 gtk_drag_finish( context
, TRUE
, FALSE
, time
);
307 /* tell GTK that data transfer was not successfull */
308 gtk_drag_finish( context
, FALSE
, FALSE
, time
);
311 /* after this, invalidate the drop_target's drag data */
312 drop_target
->SetDragData( (GtkSelectionData
*) NULL
);
315 //----------------------------------------------------------------------------
317 //----------------------------------------------------------------------------
319 wxDropTarget::wxDropTarget()
321 m_firstMotion
= TRUE
;
322 m_dragContext
= (GdkDragContext
*) NULL
;
323 m_dragWidget
= (GtkWidget
*) NULL
;
324 m_dragData
= (GtkSelectionData
*) NULL
;
328 wxDropTarget::~wxDropTarget()
332 void wxDropTarget::OnEnter()
336 void wxDropTarget::OnLeave()
340 bool wxDropTarget::OnMove( int WXUNUSED(x
), int WXUNUSED(y
) )
345 bool wxDropTarget::OnDrop( int WXUNUSED(x
), int WXUNUSED(y
) )
350 bool wxDropTarget::OnData( int WXUNUSED(x
), int WXUNUSED(y
) )
355 bool wxDropTarget::RequestData( wxDataFormat format
)
357 if (!m_dragContext
) return FALSE
;
358 if (!m_dragWidget
) return FALSE
;
361 wxPrintf( _T("format: %s.\n"), format.GetId().c_str() );
362 if (format.GetType() == wxDF_PRIVATE) wxPrintf( _T("private data.\n") );
363 if (format.GetType() == wxDF_TEXT) wxPrintf( _T("text data.\n") );
366 /* this should trigger an "drag_data_received" event */
367 gtk_drag_get_data( m_dragWidget
,
375 bool wxDropTarget::IsSupported( wxDataFormat format
)
377 if (!m_dragContext
) return FALSE
;
379 GList
*child
= m_dragContext
->targets
;
382 GdkAtom formatAtom
= (GdkAtom
) GPOINTER_TO_INT(child
->data
);
384 // char *name = gdk_atom_name( formatAtom );
385 // if (name) printf( "Format available: %s.\n", name );
387 if (formatAtom
== format
.GetAtom()) return TRUE
;
394 bool wxDropTarget::GetData( wxDataObject
*data_object
)
396 if (!m_dragData
) return FALSE
;
398 if (m_dragData
->target
!= data_object
->GetFormat().GetAtom()) return FALSE
;
400 if (data_object
->GetFormat().GetType() == wxDF_TEXT
)
402 wxTextDataObject
*text_object
= (wxTextDataObject
*)data_object
;
403 text_object
->SetText( (const char*)m_dragData
->data
);
406 if (data_object
->GetFormat().GetType() == wxDF_FILENAME
)
410 if (data_object
->GetFormat().GetType() == wxDF_PRIVATE
)
412 wxPrivateDataObject
*priv_object
= (wxPrivateDataObject
*)data_object
;
413 priv_object
->SetData( (const char*)m_dragData
->data
, (size_t)m_dragData
->length
);
419 void wxDropTarget::UnregisterWidget( GtkWidget
*widget
)
421 wxCHECK_RET( widget
!= NULL
, _T("unregister widget is NULL") );
423 gtk_drag_dest_unset( widget
);
425 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
426 GTK_SIGNAL_FUNC(target_drag_leave
), (gpointer
) this );
428 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
429 GTK_SIGNAL_FUNC(target_drag_motion
), (gpointer
) this );
431 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
432 GTK_SIGNAL_FUNC(target_drag_drop
), (gpointer
) this );
434 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
435 GTK_SIGNAL_FUNC(target_drag_data_received
), (gpointer
) this );
438 void wxDropTarget::RegisterWidget( GtkWidget
*widget
)
440 wxCHECK_RET( widget
!= NULL
, _T("register widget is NULL") );
442 /* gtk_drag_dest_set() determines what default behaviour we'd like
443 GTK to supply. we don't want to specify out targets (=formats)
444 or actions in advance (i.e. not GTK_DEST_DEFAULT_MOTION and
445 not GTK_DEST_DEFAULT_DROP). instead we react individually to
446 "drag_motion" and "drag_drop" events. this makes it possible
447 to allow dropping on only a small area. we should set
448 GTK_DEST_DEFAULT_HIGHLIGHT as this will switch on the nice
449 highlighting if dragging over standard controls, but this
450 seems to be broken without the other two. */
452 gtk_drag_dest_set( widget
,
453 (GtkDestDefaults
) 0, /* no default behaviour */
454 (GtkTargetEntry
*) NULL
, /* we don't supply any formats here */
455 0, /* number of targets = 0 */
456 (GdkDragAction
) 0 ); /* we don't supply any actions here */
458 gtk_signal_connect( GTK_OBJECT(widget
), "drag_leave",
459 GTK_SIGNAL_FUNC(target_drag_leave
), (gpointer
) this );
461 gtk_signal_connect( GTK_OBJECT(widget
), "drag_motion",
462 GTK_SIGNAL_FUNC(target_drag_motion
), (gpointer
) this );
464 gtk_signal_connect( GTK_OBJECT(widget
), "drag_drop",
465 GTK_SIGNAL_FUNC(target_drag_drop
), (gpointer
) this );
467 gtk_signal_connect( GTK_OBJECT(widget
), "drag_data_received",
468 GTK_SIGNAL_FUNC(target_drag_data_received
), (gpointer
) this );
471 //-------------------------------------------------------------------------
473 //-------------------------------------------------------------------------
475 bool wxTextDropTarget::OnMove( int WXUNUSED(x
), int WXUNUSED(y
) )
477 return IsSupported( wxDF_TEXT
);
480 bool wxTextDropTarget::OnDrop( int WXUNUSED(x
), int WXUNUSED(y
) )
482 if (IsSupported( wxDF_TEXT
))
484 RequestData( wxDF_TEXT
);
491 bool wxTextDropTarget::OnData( int x
, int y
)
493 wxTextDataObject data
;
494 if (!GetData( &data
)) return FALSE
;
496 OnDropText( x
, y
, data
.GetText() );
501 //-------------------------------------------------------------------------
502 // wxPrivateDropTarget
503 //-------------------------------------------------------------------------
505 wxPrivateDropTarget::wxPrivateDropTarget()
507 m_id
= wxTheApp
->GetAppName();
510 wxPrivateDropTarget::wxPrivateDropTarget( const wxString
&id
)
515 bool wxPrivateDropTarget::OnMove( int WXUNUSED(x
), int WXUNUSED(y
) )
517 return IsSupported( m_id
);
520 bool wxPrivateDropTarget::OnDrop( int WXUNUSED(x
), int WXUNUSED(y
) )
522 if (!IsSupported( m_id
))
531 bool wxPrivateDropTarget::OnData( int x
, int y
)
533 if (!IsSupported( m_id
)) return FALSE
;
535 wxPrivateDataObject data
;
536 if (!GetData( &data
)) return FALSE
;
538 OnDropData( x
, y
, data
.GetData(), data
.GetSize() );
543 //----------------------------------------------------------------------------
544 // A drop target which accepts files (dragged from File Manager or Explorer)
545 //----------------------------------------------------------------------------
547 bool wxFileDropTarget::OnMove( int WXUNUSED(x
), int WXUNUSED(y
) )
549 return IsSupported( wxDF_FILENAME
);
552 bool wxFileDropTarget::OnDrop( int x
, int y
)
554 if (IsSupported( wxDF_FILENAME
))
556 RequestData( wxDF_FILENAME
);
563 bool wxFileDropTarget::OnData( int x
, int y
)
565 wxFileDataObject data
;
566 if (!GetData( &data
)) return FALSE
;
568 /* get number of substrings /root/mytext.txt/0/root/myothertext.txt/0/0 */
571 size_t size
= data
.GetFiles().Length();
572 wxChar
*text
= WXSTRINGCAST data
.GetFiles();
573 for ( i
= 0; i
< size
; i
++)
574 if (text
[i
] == 0) number
++;
576 if (number
== 0) return FALSE
;
578 wxChar
**files
= new wxChar
*[number
];
580 text
= WXSTRINGCAST data
.GetFiles();
581 for (i
= 0; i
< number
; i
++)
584 int len
= wxStrlen( text
);
588 OnDropFiles( x
, y
, number
, files
);
595 //----------------------------------------------------------------------------
597 //----------------------------------------------------------------------------
600 source_drag_data_get (GtkWidget
*WXUNUSED(widget
),
601 GdkDragContext
*context
,
602 GtkSelectionData
*selection_data
,
603 guint
WXUNUSED(info
),
604 guint
WXUNUSED(time
),
605 wxDropSource
*drop_source
)
607 if (g_isIdle
) wxapp_install_idle_handler();
609 // printf( "Provide data!\n" );
611 // char *name = gdk_atom_name( selection_data->target );
612 // if (name) printf( "Format requested: %s.\n", name );
614 wxNode
*node
= drop_source
->m_data
->m_dataObjects
.First();
617 wxDataObject
*data_object
= (wxDataObject
*) node
->Data();
618 if (data_object
->GetFormat().GetAtom() == selection_data
->target
)
620 // printf( "format found.\n" );
622 size_t data_size
= data_object
->GetSize();
626 // printf( "data size: %d.\n", (int)data_size );
628 guchar
*buffer
= new guchar
[data_size
];
629 data_object
->WriteData( buffer
);
631 gtk_selection_data_set( selection_data
,
632 selection_data
->target
,
639 /* so far only copy, no moves. TODO. */
640 drop_source
->m_retValue
= wxDragCopy
;
649 drop_source
->m_retValue
= wxDragCancel
;
652 //----------------------------------------------------------------------------
653 // "drag_data_delete"
654 //----------------------------------------------------------------------------
656 static void source_drag_data_delete( GtkWidget
*WXUNUSED(widget
),
657 GdkDragContext
*WXUNUSED(context
),
658 wxDropSource
*drop_source
)
660 if (g_isIdle
) wxapp_install_idle_handler();
662 // printf( "Delete the data!\n" );
664 drop_source
->m_retValue
= wxDragMove
;
667 //----------------------------------------------------------------------------
669 //----------------------------------------------------------------------------
671 static void source_drag_begin( GtkWidget
*WXUNUSED(widget
),
672 GdkDragContext
*WXUNUSED(context
),
673 wxDropSource
*WXUNUSED(drop_source
) )
675 if (g_isIdle
) wxapp_install_idle_handler();
677 // printf( "drag_begin.\n" );
680 //----------------------------------------------------------------------------
682 //----------------------------------------------------------------------------
684 static void source_drag_end( GtkWidget
*WXUNUSED(widget
),
685 GdkDragContext
*WXUNUSED(context
),
686 wxDropSource
*drop_source
)
688 if (g_isIdle
) wxapp_install_idle_handler();
690 // printf( "drag_end.\n" );
692 drop_source
->m_waiting
= FALSE
;
695 //---------------------------------------------------------------------------
697 //---------------------------------------------------------------------------
699 wxDropSource::wxDropSource( wxWindow
*win
, const wxIcon
&go
, const wxIcon
&stop
)
701 g_blockEventsOnDrag
= TRUE
;
705 m_widget
= win
->m_widget
;
706 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
708 m_data
= (wxDataBroker
*) NULL
;
709 m_retValue
= wxDragCancel
;
711 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
712 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
715 if (wxNullIcon
== go
) m_goIcon
= wxIcon( page_xpm
);
717 if (wxNullIcon
== stop
) m_stopIcon
= wxIcon( gv_xpm
);
720 wxDropSource::wxDropSource( wxDataObject
*data
, wxWindow
*win
, const wxIcon
&go
, const wxIcon
&stop
)
725 m_widget
= win
->m_widget
;
726 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
727 m_retValue
= wxDragCancel
;
731 m_data
= new wxDataBroker();
736 m_data
= (wxDataBroker
*) NULL
;
739 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
740 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
743 if (wxNullIcon
== go
) m_goIcon
= wxIcon( page_xpm
);
745 if (wxNullIcon
== stop
) m_stopIcon
= wxIcon( gv_xpm
);
748 wxDropSource::wxDropSource( wxDataBroker
*data
, wxWindow
*win
)
751 m_widget
= win
->m_widget
;
752 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
753 m_retValue
= wxDragCancel
;
757 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
758 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
761 void wxDropSource::SetData( wxDataObject
*data
)
763 if (m_data
) delete m_data
;
767 m_data
= new wxDataBroker();
772 m_data
= (wxDataBroker
*) NULL
;
776 void wxDropSource::SetData( wxDataBroker
*data
)
778 if (m_data
) delete m_data
;
783 wxDropSource::~wxDropSource(void)
785 if (m_data
) delete m_data
;
787 g_blockEventsOnDrag
= FALSE
;
790 wxDragResult
wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove
) )
792 wxASSERT_MSG( m_data
, _T("wxDragSource: no data") );
794 if (!m_data
) return (wxDragResult
) wxDragNone
;
796 g_blockEventsOnDrag
= TRUE
;
802 GdkAtom atom
= gdk_atom_intern( "STRING", FALSE
);
803 // wxPrintf( _T("atom id: %d.\n"), (int)atom );
805 GtkTargetList
*target_list
= gtk_target_list_new( (GtkTargetEntry
*) NULL
, 0 );
806 gtk_target_list_add( target_list
, atom
, 0, 0 );
808 GdkEventMotion event
;
809 event
.window
= m_widget
->window
;
812 GdkModifierType state
;
813 gdk_window_get_pointer( event
.window
, &x
, &y
, &state
);
817 event
.time
= GDK_CURRENT_TIME
;
819 /* GTK wants to know which button was pressed which caused the dragging */
820 int button_number
= 0;
821 if (event
.state
& GDK_BUTTON1_MASK
) button_number
= 1;
822 else if (event
.state
& GDK_BUTTON2_MASK
) button_number
= 2;
823 else if (event
.state
& GDK_BUTTON3_MASK
) button_number
= 3;
825 /* don't start dragging if no button is down */
828 GdkDragContext
*context
= gtk_drag_begin( m_widget
,
831 button_number
, /* number of mouse button which started drag */
832 (GdkEvent
*) &event
);
834 wxMask
*mask
= m_goIcon
.GetMask();
835 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
836 if (mask
) bm
= mask
->GetBitmap();
837 GdkPixmap
*pm
= m_goIcon
.GetPixmap();
839 gtk_drag_set_icon_pixmap( context
,
840 gtk_widget_get_colormap( m_widget
),
846 while (m_waiting
) gtk_main_iteration();;
849 g_blockEventsOnDrag
= FALSE
;
856 void wxDropSource::RegisterWindow()
858 if (!m_widget
) return;
860 gtk_signal_connect( GTK_OBJECT(m_widget
), "drag_data_get",
861 GTK_SIGNAL_FUNC (source_drag_data_get
), (gpointer
) this);
862 gtk_signal_connect (GTK_OBJECT(m_widget
), "drag_data_delete",
863 GTK_SIGNAL_FUNC (source_drag_data_delete
), (gpointer
) this );
864 gtk_signal_connect (GTK_OBJECT(m_widget
), "drag_begin",
865 GTK_SIGNAL_FUNC (source_drag_begin
), (gpointer
) this );
866 gtk_signal_connect (GTK_OBJECT(m_widget
), "drag_end",
867 GTK_SIGNAL_FUNC (source_drag_end
), (gpointer
) this );
871 void wxDropSource::UnregisterWindow()
873 if (!m_widget
) return;
875 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
876 GTK_SIGNAL_FUNC(source_drag_data_get
), (gpointer
) this );
877 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
878 GTK_SIGNAL_FUNC(source_drag_data_delete
), (gpointer
) this );
879 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
880 GTK_SIGNAL_FUNC(source_drag_begin
), (gpointer
) this );
881 gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget
),
882 GTK_SIGNAL_FUNC(source_drag_end
), (gpointer
) this );
887 // wxUSE_DRAG_AND_DROP