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"
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 extern bool g_blockEventsOnDrag
;
36 #ifdef NEW_GTK_DND_CODE
38 #include "gtk/gtkdnd.h"
39 #include "gtk/gtkselection.h"
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 static void target_drag_leave( GtkWidget
*WXUNUSED(widget
),
46 GdkDragContext
*WXUNUSED(context
),
47 guint
WXUNUSED(time
) )
52 // ----------------------------------------------------------------------------
54 // ----------------------------------------------------------------------------
56 static gboolean
target_drag_motion( GtkWidget
*WXUNUSED(widget
),
57 GdkDragContext
*context
,
62 printf( "motion.\n" );
63 gdk_drag_status( context
, context
->suggested_action
, time
);
67 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
71 static gboolean
target_drag_drop( GtkWidget
*widget
,
72 GdkDragContext
*context
,
77 printf( "drop at: %d,%d.\n", x
, y
);
81 gtk_drag_get_data( widget
,
83 GPOINTER_TO_INT (context
->targets
->data
),
89 // ----------------------------------------------------------------------------
90 // "drag_data_received"
91 // ----------------------------------------------------------------------------
93 static void target_drag_data_received( GtkWidget
*WXUNUSED(widget
),
94 GdkDragContext
*context
,
97 GtkSelectionData
*data
,
101 printf( "data receive at: %d,%d.\n", x
, y
);
103 if ((data
->length
>= 0) && (data
->format
== 8))
105 wxString str
= (const char*)data
->data
;
106 printf( "Received %s\n.", WXSTRINGCAST str
);
107 gtk_drag_finish( context
, TRUE
, FALSE
, time
);
111 gtk_drag_finish (context
, FALSE
, FALSE
, time
);
114 // ----------------------------------------------------------------------------
116 // ----------------------------------------------------------------------------
118 wxDropTarget::wxDropTarget()
122 wxDropTarget::~wxDropTarget()
126 void wxDropTarget::UnregisterWidget( GtkWidget
*widget
)
128 wxCHECK_RET( widget
!= NULL
, "unregister widget is NULL" );
130 gtk_drag_dest_set( widget
,
132 (GtkTargetEntry
*) NULL
,
136 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
137 GTK_SIGNAL_FUNC(target_drag_leave
), (gpointer
) this );
139 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
140 GTK_SIGNAL_FUNC(target_drag_motion
), (gpointer
) this );
142 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
143 GTK_SIGNAL_FUNC(target_drag_drop
), (gpointer
) this );
145 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
146 GTK_SIGNAL_FUNC(target_drag_data_received
), (gpointer
) this );
149 void wxDropTarget::RegisterWidget( GtkWidget
*widget
)
151 wxCHECK_RET( widget
!= NULL
, "register widget is NULL" );
153 GtkTargetEntry format
;
158 for ( size_t i
= 0; i
< GetFormatCount(); i
++ )
160 wxDataFormat df
= GetFormat( i
);
164 format
.target
= "text/plain";
168 format
.target
= "file:ALL";
176 wxASSERT_MSG( valid
!= 0, "No valid DnD format supported." );
178 gtk_drag_dest_set( widget
,
179 GTK_DEST_DEFAULT_ALL
,
182 (GdkDragAction
)(GDK_ACTION_COPY
| GDK_ACTION_MOVE
) );
184 gtk_signal_connect( GTK_OBJECT(widget
), "drag_leave",
185 GTK_SIGNAL_FUNC(target_drag_leave
), (gpointer
) this );
187 gtk_signal_connect( GTK_OBJECT(widget
), "drag_motion",
188 GTK_SIGNAL_FUNC(target_drag_motion
), (gpointer
) this );
190 gtk_signal_connect( GTK_OBJECT(widget
), "drag_drop",
191 GTK_SIGNAL_FUNC(target_drag_drop
), (gpointer
) this );
193 gtk_signal_connect( GTK_OBJECT(widget
), "drag_data_received",
194 GTK_SIGNAL_FUNC(target_drag_data_received
), (gpointer
) this );
197 // ----------------------------------------------------------------------------
199 // ----------------------------------------------------------------------------
201 bool wxTextDropTarget::OnDrop( long x
, long y
, const void *data
, size_t WXUNUSED(size
) )
203 OnDropText( x
, y
, (const char*)data
);
207 bool wxTextDropTarget::OnDropText( long x
, long y
, const char *psz
)
209 printf( "Got dropped text: %s.\n", psz
);
210 printf( "At x: %d, y: %d.\n", (int)x
, (int)y
);
214 size_t wxTextDropTarget::GetFormatCount() const
219 wxDataFormat
wxTextDropTarget::GetFormat(size_t WXUNUSED(n
)) const
224 // ----------------------------------------------------------------------------
226 // ----------------------------------------------------------------------------
228 bool wxFileDropTarget::OnDropFiles( long x
, long y
, size_t nFiles
, const char * const aszFiles
[] )
230 printf( "Got %d dropped files.\n", (int)nFiles
);
231 printf( "At x: %d, y: %d.\n", (int)x
, (int)y
);
232 for (size_t i
= 0; i
< nFiles
; i
++)
234 printf( aszFiles
[i
] );
240 bool wxFileDropTarget::OnDrop(long x
, long y
, const void *data
, size_t size
)
243 char *text
= (char*) data
;
244 for (size_t i
= 0; i
< size
; i
++)
245 if (text
[i
] == 0) number
++;
247 if (number
== 0) return TRUE
;
249 char **files
= new char*[number
];
252 for (size_t i
= 0; i
< number
; i
++)
255 int len
= strlen( text
);
259 bool ret
= OnDropFiles( x
, y
, 1, files
);
266 size_t wxFileDropTarget::GetFormatCount() const
271 wxDataFormat
wxFileDropTarget::GetFormat(size_t WXUNUSED(n
)) const
273 return wxDF_FILENAME
;
276 //-------------------------------------------------------------------------
278 //-------------------------------------------------------------------------
280 wxDropSource::wxDropSource( wxWindow
*win
)
282 g_blockEventsOnDrag
= TRUE
;
285 m_widget
= win
->m_widget
;
286 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
288 m_data
= (wxDataObject
*) NULL
;
289 m_retValue
= wxDragCancel
;
291 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
292 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
295 wxDropSource::wxDropSource( wxDataObject
&data
, wxWindow
*win
)
297 g_blockEventsOnDrag
= TRUE
;
300 m_widget
= win
->m_widget
;
301 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
302 m_retValue
= wxDragCancel
;
306 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
307 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
310 void wxDropSource::SetData( wxDataObject
&data
)
315 wxDropSource::~wxDropSource(void)
317 // if (m_data) delete m_data;
319 g_blockEventsOnDrag
= FALSE
;
322 wxDragResult
wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove
) )
324 wxASSERT_MSG( m_data
, "wxDragSource: no data" );
326 if (!m_data
) return (wxDragResult
) wxDragNone
;
327 if (m_data
->GetDataSize() == 0) return (wxDragResult
) wxDragNone
;
335 g_blockEventsOnDrag
= FALSE
;
340 void wxDropSource::RegisterWindow(void)
346 wxDataFormat df
= m_data
->GetPreferredFormat();
351 formats
+= "text/plain";
354 formats
+= "file:ALL";
360 char *str
= WXSTRINGCAST formats
;
365 void wxDropSource::UnregisterWindow(void)
367 if (!m_widget
) return;
375 GtkWidget
*shape_create_icon (char **data
,
383 static char * gv_xpm
[] = {
395 " .XXXXXXXXXXXXXX. ",
396 " .XXX..XXXX..XXX. ",
397 " ....XX....XX....XX. ",
398 " .XXX.XXX..XXXX..XXX.... ",
399 " .XXXXXXXXXXXXXXXXXXX.XXX. ",
400 " .XXXXXXXXXXXXXXXXXXXXXXXX. ",
401 " .XXXXXXXXXXXXXXXXXXXXXXXX. ",
402 " ..XXXXXXXXXXXXXXXXXXXXXX. ",
403 " .XXXXXXXXXXXXXXXXXX... ",
404 " ..XXXXXXXXXXXXXXXX. ",
405 " .XXXXXXXXXXXXXXXX. ",
406 " .XXXXXXXXXXXXXXXX. ",
407 " .XXXXXXXXXXXXXXXXX. ",
408 " .XXXXXXXXXXXXXXXXX. ",
409 " .XXXXXXXXXXXXXXXXXX. ",
410 " .XXXXXXXXXXXXXXXXXXX. ",
411 " .XXXXXXXXXXXXXXXXXXXXX. ",
412 " .XXXXXXXXXXXXXX.XXXXXXX. ",
413 " .XXXXXXX.XXXXXXX.XXXXXXX. ",
414 " .XXXXXXXX.XXXXXXX.XXXXXXX. ",
415 " .XXXXXXX...XXXXX...XXXXX. ",
416 " .XXXXXXX. ..... ..... ",
424 static char * page_xpm
[] = {
425 /* width height ncolors chars_per_pixel */
434 " ................... ",
435 " .XXXXXXXXXXXXXXXXX.. ",
436 " .XXXXXXXXXXXXXXXXX.o. ",
437 " .XXXXXXXXXXXXXXXXX.oo. ",
438 " .XXXXXXXXXXXXXXXXX.ooo. ",
439 " .XXXXXXXXXXXXXXXXX.oooo. ",
440 " .XXXXXXXXXXXXXXXXX....... ",
441 " .XXXXXOOOOOOOOOOXXXooooo. ",
442 " .XXXXXXXXXXXXXXXXXXooooo. ",
443 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
444 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
445 " .XXXXXXXOOOOOOOOOXXXXXXX. ",
446 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
447 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
448 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
449 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
450 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
451 " .XXXXXXXOOOOOOOOOXXXXXXX. ",
452 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
453 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
454 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
455 " .XXXXXOOOOOOOOOOXXXXXXXX. ",
456 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
457 " .XXXXXXOOOOOOOOOOXXXXXXX. ",
458 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
459 " .XXXXXOOOOOOOXXXXXXXXXXX. ",
460 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
461 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
462 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
463 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
464 " .XXXXXXXXXXXXXXXXXXXXXXX. ",
465 " ......................... "};
468 //-----------------------------------------------------------------------------
469 // "drop_data_available_event"
470 //-----------------------------------------------------------------------------
472 static void gtk_target_callback( GtkWidget
*widget
,
473 GdkEventDropDataAvailable
*event
,
474 wxDropTarget
*target
)
480 gdk_window_get_pointer( widget
->window
, &x
, &y
, (GdkModifierType
*) NULL
);
482 // printf( "Drop data is of type %s.\n", event->data_type );
484 target
->OnDrop( x
, y
, (const void*)event
->data
, (size_t)event
->data_numbytes
);
488 g_free (event->data);
489 g_free (event->data_type);
493 // ----------------------------------------------------------------------------
495 // ----------------------------------------------------------------------------
497 wxDropTarget::wxDropTarget()
501 wxDropTarget::~wxDropTarget()
505 void wxDropTarget::UnregisterWidget( GtkWidget
*widget
)
509 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
510 GTK_SIGNAL_FUNC(gtk_target_callback
), (gpointer
) this );
512 gtk_widget_dnd_drop_set( widget
, FALSE
, (gchar
**) NULL
, 0, FALSE
);
515 void wxDropTarget::RegisterWidget( GtkWidget
*widget
)
520 for ( size_t i
= 0; i
< GetFormatCount(); i
++ )
522 wxDataFormat df
= GetFormat( i
);
526 if (i
> 0) formats
+= ";";
527 formats
+= "text/plain";
531 if (i
> 0) formats
+= ";";
532 formats
+= "file:ALL";
540 char *str
= WXSTRINGCAST formats
;
542 gtk_widget_dnd_drop_set( widget
, TRUE
, &str
, valid
, FALSE
);
544 gtk_signal_connect( GTK_OBJECT(widget
), "drop_data_available_event",
545 GTK_SIGNAL_FUNC(gtk_target_callback
), (gpointer
) this );
548 // ----------------------------------------------------------------------------
550 // ----------------------------------------------------------------------------
552 bool wxTextDropTarget::OnDrop( long x
, long y
, const void *data
, size_t WXUNUSED(size
) )
554 OnDropText( x
, y
, (const char*)data
);
558 bool wxTextDropTarget::OnDropText( long x
, long y
, const char *psz
)
560 printf( "Got dropped text: %s.\n", psz
);
561 printf( "At x: %d, y: %d.\n", (int)x
, (int)y
);
565 size_t wxTextDropTarget::GetFormatCount() const
570 wxDataFormat
wxTextDropTarget::GetFormat(size_t WXUNUSED(n
)) const
575 // ----------------------------------------------------------------------------
577 // ----------------------------------------------------------------------------
579 bool wxFileDropTarget::OnDropFiles( long x
, long y
, size_t nFiles
, const char * const aszFiles
[] )
581 printf( "Got %d dropped files.\n", (int)nFiles
);
582 printf( "At x: %d, y: %d.\n", (int)x
, (int)y
);
583 for (size_t i
= 0; i
< nFiles
; i
++)
585 printf( aszFiles
[i
] );
591 bool wxFileDropTarget::OnDrop(long x
, long y
, const void *data
, size_t size
)
594 char *text
= (char*) data
;
595 for (size_t i
= 0; i
< size
; i
++)
596 if (text
[i
] == 0) number
++;
598 if (number
== 0) return TRUE
;
600 char **files
= new char*[number
];
603 for (size_t i
= 0; i
< number
; i
++)
606 int len
= strlen( text
);
610 bool ret
= OnDropFiles( x
, y
, 1, files
);
617 size_t wxFileDropTarget::GetFormatCount() const
622 wxDataFormat
wxFileDropTarget::GetFormat(size_t WXUNUSED(n
)) const
624 return wxDF_FILENAME
;
627 //-------------------------------------------------------------------------
629 //-------------------------------------------------------------------------
632 shape_motion (GtkWidget
*widget
,
633 GdkEventMotion */
*event*/
);
635 //-----------------------------------------------------------------------------
638 void gtk_drag_callback( GtkWidget
*widget
, GdkEvent
*event
, wxDropSource
*source
)
640 wxDataObject
*data
= source
->m_data
;
642 switch (data
->GetFormat())
646 wxTextDataObject
*text_object
= (wxTextDataObject
*) data
;
648 wxString text
= text_object
->GetText();
650 char *s
= WXSTRINGCAST text
;
652 gtk_widget_dnd_data_set( widget
,
655 (int) text
.Length()+1 );
662 wxFileDataObject
*file_object
= (wxFileDataObject
*) data
;
664 wxString text
= file_object
->GetFiles();
666 char *s
= WXSTRINGCAST text
;
668 gtk_widget_dnd_data_set( widget
,
671 (int) text
.Length()+1 );
682 source
->m_retValue
= wxDragCopy
;
685 wxDropSource::wxDropSource( wxWindow
*win
)
687 g_blockEventsOnDrag
= TRUE
;
690 m_widget
= win
->m_widget
;
691 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
693 m_data
= (wxDataObject
*) NULL
;
694 m_retValue
= wxDragCancel
;
696 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
697 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
700 wxDropSource::wxDropSource( wxDataObject
&data
, wxWindow
*win
)
702 g_blockEventsOnDrag
= TRUE
;
705 m_widget
= win
->m_widget
;
706 if (win
->m_wxwindow
) m_widget
= win
->m_wxwindow
;
707 m_retValue
= wxDragCancel
;
711 m_defaultCursor
= wxCursor( wxCURSOR_NO_ENTRY
);
712 m_goaheadCursor
= wxCursor( wxCURSOR_HAND
);
715 void wxDropSource::SetData( wxDataObject
&data
)
720 wxDropSource::~wxDropSource(void)
722 // if (m_data) delete m_data;
724 g_blockEventsOnDrag
= FALSE
;
727 wxDragResult
wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove
) )
729 if (gdk_dnd
.dnd_grabbed
) return (wxDragResult
) wxDragNone
;
730 if (gdk_dnd
.drag_really
) return (wxDragResult
) wxDragNone
;
732 wxASSERT_MSG( m_data
, "wxDragSource: no data" );
734 if (!m_data
) return (wxDragResult
) wxDragNone
;
736 static GtkWidget
*drag_icon
= (GtkWidget
*) NULL
;
737 static GtkWidget
*drop_icon
= (GtkWidget
*) NULL
;
739 GdkPoint hotspot_1
= {0,-5 };
743 drag_icon
= shape_create_icon ( gv_xpm
,
744 440, 140, 0,0, GTK_WINDOW_POPUP
);
746 gtk_signal_connect (GTK_OBJECT (drag_icon
), "destroy",
747 GTK_SIGNAL_FUNC(gtk_widget_destroyed
),
750 gtk_widget_hide (drag_icon
);
753 GdkPoint hotspot_2
= {-5,-5};
757 drop_icon
= shape_create_icon ( page_xpm
,
758 440, 140, 0,0, GTK_WINDOW_POPUP
);
760 gtk_signal_connect (GTK_OBJECT (drop_icon
), "destroy",
761 GTK_SIGNAL_FUNC(gtk_widget_destroyed
),
764 gtk_widget_hide (drop_icon
);
768 gdk_dnd_set_drag_shape( drag_icon
->window
,
774 GdkWindowPrivate
*wp
= (GdkWindowPrivate
*) m_widget
->window
;
778 gdk_dnd
.drag_perhaps
= TRUE
;
780 gdk_dnd
.dnd_drag_start
.x
= 5;
781 gdk_dnd
.dnd_drag_start
.y
= 5;
782 gdk_dnd
.real_sw
= wp
;
784 if (gdk_dnd
.drag_startwindows
)
786 g_free( gdk_dnd
.drag_startwindows
);
787 gdk_dnd
.drag_startwindows
= (GdkWindow
**) NULL
;
789 gdk_dnd
.drag_numwindows
= gdk_dnd
.drag_really
= 0;
791 XWindowAttributes dnd_winattr
;
792 XGetWindowAttributes( gdk_display
, wp
->xwindow
, &dnd_winattr
);
793 wp
->dnd_drag_savedeventmask
= dnd_winattr
.your_event_mask
;
795 gdk_dnd_drag_addwindow( m_widget
->window
);
797 GdkEventDragBegin ev
;
798 ev
.type
= GDK_DRAG_BEGIN
;
799 ev
.window
= m_widget
->window
;
801 ev
.u
.flags
.protocol_version
= DND_PROTOCOL_VERSION
;
803 gdk_event_put( (GdkEvent
*)&ev
);
805 XGrabPointer( gdk_display
, wp
->xwindow
, False
,
806 ButtonMotionMask
| ButtonPressMask
| ButtonReleaseMask
| PointerMotionMask
,
807 GrabModeAsync
, GrabModeAsync
, gdk_root_window
, None
, CurrentTime
);
809 gdk_dnd_set_drag_cursors( m_defaultCursor
.GetCursor(), m_goaheadCursor
.GetCursor() );
811 gdk_dnd
.dnd_grabbed
= TRUE
;
812 gdk_dnd
.drag_really
= 1;
816 wxGetMousePosition( &x
, &y
);
818 gdk_dnd_display_drag_cursor( x
, y
, FALSE
, TRUE
);
821 shape_motion( drag_icon, (GdkEventMotion *)NULL );
822 shape_motion( drop_icon, (GdkEventMotion *)NULL );
825 while (gdk_dnd
.drag_really
|| gdk_dnd
.drag_perhaps
) wxYield();
829 g_blockEventsOnDrag
= FALSE
;
834 void wxDropSource::RegisterWindow(void)
840 wxDataFormat df
= m_data
->GetFormat();
845 formats
+= "text/plain";
848 formats
+= "file:ALL";
854 char *str
= WXSTRINGCAST formats
;
856 gtk_widget_dnd_drag_set( m_widget
, TRUE
, &str
, 1 );
858 gtk_signal_connect( GTK_OBJECT(m_widget
), "drag_request_event",
859 GTK_SIGNAL_FUNC(gtk_drag_callback
), (gpointer
)this );
862 void wxDropSource::UnregisterWindow(void)
864 if (!m_widget
) return;
866 gtk_widget_dnd_drag_set( m_widget
, FALSE
, (gchar
**) NULL
, 0 );
868 gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget
), (gpointer
)this );
875 static GdkWindow
*root_win
= (GdkWindow
*) NULL
;
877 typedef struct _cursoroffset
{gint x
,y
;} CursorOffset
;
880 shape_pressed (GtkWidget
*widget
, GdkEventButton
*event
)
884 /* ignore double and triple click */
885 if (event
->type
!= GDK_BUTTON_PRESS
)
888 p
= (CursorOffset
*)gtk_object_get_user_data (GTK_OBJECT(widget
));
889 p
->x
= (int) event
->x
;
890 p
->y
= (int) event
->y
;
892 gtk_grab_add (widget
);
893 gdk_pointer_grab (widget
->window
, TRUE
,
895 (GDK_BUTTON_RELEASE_MASK
|
896 GDK_BUTTON_MOTION_MASK
|
897 GDK_POINTER_MOTION_HINT_MASK
),
899 (GdkCursor
*) NULL
, 0);
904 shape_released (GtkWidget
*widget
)
906 gtk_grab_remove (widget
);
907 gdk_pointer_ungrab (0);
911 shape_motion (GtkWidget
*widget
,
912 GdkEventMotion */
*event*/
)
916 GdkModifierType mask
;
918 p
= (CursorOffset
*)gtk_object_get_user_data (GTK_OBJECT (widget
));
921 * Can't use event->x / event->y here
922 * because I need absolute coordinates.
924 gdk_window_get_pointer (root_win
, &xp
, &yp
, &mask
);
925 gtk_widget_set_uposition (widget
, xp
- p
->x
, yp
- p
->y
);
929 shape_create_icon (char **data
,
939 CursorOffset
* icon_pos
;
941 GdkBitmap
*gdk_pixmap_mask
;
942 GdkPixmap
*gdk_pixmap
;
945 style
= gtk_widget_get_default_style ();
946 gc
= style
->black_gc
;
949 * GDK_WINDOW_TOPLEVEL works also, giving you a title border
951 window
= gtk_window_new ((GtkWindowType
)window_type
);
953 fixed
= gtk_fixed_new ();
954 gtk_widget_set_usize (fixed
, 100,100);
955 gtk_container_add (GTK_CONTAINER (window
), fixed
);
956 gtk_widget_show (fixed
);
958 gtk_widget_set_events (window
,
959 gtk_widget_get_events (window
) |
960 GDK_BUTTON_MOTION_MASK
|
961 GDK_POINTER_MOTION_HINT_MASK
|
962 GDK_BUTTON_PRESS_MASK
);
964 gtk_widget_realize (window
);
966 gdk_pixmap
= gdk_pixmap_create_from_xpm_d (window
->window
, &gdk_pixmap_mask
,
967 &style
->bg
[GTK_STATE_NORMAL
],
970 pixmap
= gtk_pixmap_new (gdk_pixmap
, gdk_pixmap_mask
);
971 gtk_fixed_put (GTK_FIXED (fixed
), pixmap
, px
,py
);
972 gtk_widget_show (pixmap
);
974 gtk_widget_shape_combine_mask (window
, gdk_pixmap_mask
, px
,py
);
977 gtk_signal_connect (GTK_OBJECT (window
), "button_press_event",
978 GTK_SIGNAL_FUNC (shape_pressed
),NULL
);
979 gtk_signal_connect (GTK_OBJECT (window
), "button_release_event",
980 GTK_SIGNAL_FUNC (shape_released
),NULL
);
981 gtk_signal_connect (GTK_OBJECT (window
), "motion_notify_event",
982 GTK_SIGNAL_FUNC (shape_motion
),NULL
);
984 icon_pos
= g_new (CursorOffset
, 1);
985 gtk_object_set_user_data(GTK_OBJECT(window
), icon_pos
);
987 gtk_widget_set_uposition (window
, x
, y
);
988 gtk_widget_show (window
);
998 // wxUSE_DRAG_AND_DROP