Chnaged text id for clipboard to "text/plain"

Now DnD actually links as well


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2058 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-04-06 20:50:34 +00:00
parent b80ec6db89
commit 22d5903e91
5 changed files with 558 additions and 200 deletions

View File

@ -42,7 +42,7 @@ class DnDText : public wxTextDropTarget
public:
DnDText(wxListBox *pOwner) { m_pOwner = pOwner; }
virtual bool OnDropText(long x, long y, const char *psz );
virtual bool OnDropText(int x, int y, const char *psz );
private:
wxListBox *m_pOwner;
@ -53,7 +53,7 @@ class DnDFile : public wxFileDropTarget
public:
DnDFile(wxListBox *pOwner) { m_pOwner = pOwner; }
virtual bool OnDropFiles(long x, long y,
virtual bool OnDropFiles(int x, int y,
size_t nFiles, const char * const aszFiles[] );
private:
@ -349,14 +349,14 @@ DnDFrame::~DnDFrame()
// ----------------------------------------------------------------------------
// Notifications called by the base class
// ----------------------------------------------------------------------------
bool DnDText::OnDropText(long, long, const char *psz)
bool DnDText::OnDropText(int, int, const char *psz)
{
m_pOwner->Append(psz);
return TRUE;
}
bool DnDFile::OnDropFiles(long, long, size_t nFiles,
bool DnDFile::OnDropFiles(int, int, size_t nFiles,
const char * const aszFiles[])
{
wxString str;

View File

@ -32,7 +32,7 @@ IMPLEMENT_CLASS(wxDataFormat, wxObject)
wxDataFormat::wxDataFormat()
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
m_type = wxDF_INVALID;
m_hasAtom = FALSE;
m_atom = (GdkAtom) 0;
@ -40,19 +40,19 @@ wxDataFormat::wxDataFormat()
wxDataFormat::wxDataFormat( wxDataType type )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
SetType( type );
}
wxDataFormat::wxDataFormat( const wxString &id )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
SetId( id );
}
wxDataFormat::wxDataFormat( wxDataFormat &format )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
m_type = format.GetType();
m_id = format.GetId();
m_hasAtom = TRUE;
@ -61,7 +61,7 @@ wxDataFormat::wxDataFormat( wxDataFormat &format )
wxDataFormat::wxDataFormat( const GdkAtom atom )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
m_hasAtom = TRUE;
m_atom = atom;
@ -91,7 +91,7 @@ void wxDataFormat::SetType( wxDataType type )
if (m_type == wxDF_TEXT)
{
m_id = "TEXT";
m_id = "text/plain";
}
else
if (m_type == wxDF_BITMAP)

View File

@ -27,12 +27,102 @@
#include <X11/Xlib.h>
// ----------------------------------------------------------------------------
// global
// ----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// global data
//----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------
// standard icons
//----------------------------------------------------------------------------
/* XPM */
static char * gv_xpm[] = {
"40 34 3 1",
" s None c None",
". c black",
"X c white",
" ",
" ",
" ...... ",
" ..XXXXXX.. ",
" .XXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXX. ",
" .XXX..XXXX..XXX. ",
" ....XX....XX....XX. ",
" .XXX.XXX..XXXX..XXX.... ",
" .XXXXXXXXXXXXXXXXXXX.XXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXXX. ",
" ..XXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXX... ",
" ..XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXX.XXXXXXX. ",
" .XXXXXXX.XXXXXXX.XXXXXXX. ",
" .XXXXXXXX.XXXXXXX.XXXXXXX. ",
" .XXXXXXX...XXXXX...XXXXX. ",
" .XXXXXXX. ..... ..... ",
" ..XXXX.. ",
" .... ",
" ",
" ",
" "};
/* XPM */
static char * page_xpm[] = {
/* width height ncolors chars_per_pixel */
"32 32 5 1",
/* colors */
" s None c None",
". c black",
"X c wheat",
"o c tan",
"O c #6699FF",
/* pixels */
" ................... ",
" .XXXXXXXXXXXXXXXXX.. ",
" .XXXXXXXXXXXXXXXXX.o. ",
" .XXXXXXXXXXXXXXXXX.oo. ",
" .XXXXXXXXXXXXXXXXX.ooo. ",
" .XXXXXXXXXXXXXXXXX.oooo. ",
" .XXXXXXXXXXXXXXXXX....... ",
" .XXXXXOOOOOOOOOOXXXooooo. ",
" .XXXXXXXXXXXXXXXXXXooooo. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" ......................... "};
#if (GTK_MINOR_VERSION > 0)
#include "gtk/gtkdnd.h"
@ -147,18 +237,35 @@ void wxDropTarget::OnLeave()
bool wxDropTarget::OnMove( int x, int y )
{
printf( "mouse move %d %d.\n", x, y );
printf( "generic move %d %d.\n", x, y );
return TRUE;
}
bool wxDropTarget::OnDrop( int x, int y )
{
printf( "mouse move %d %d.\n", x, y );
printf( "generic drop %d %d.\n", x, y );
return TRUE;
}
bool wxDropTarget::IsSupported( wxDataFormat format )
{
{
printf( "generic is supported.\n" );
if (!m_dragContext) return FALSE;
GList *child = m_dragContext->targets;
while (child)
{
GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
char *name = gdk_atom_name( formatAtom );
if (name) printf( "Format available: %s.\n", name );
child = child->next;
}
return TRUE;
}
@ -199,6 +306,7 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
format.flags = 0;
char buf[100];
strcpy( buf, "text/plain" );
format.target = buf;
gtk_drag_dest_set( widget,
GTK_DEST_DEFAULT_ALL,
@ -225,11 +333,15 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
bool wxTextDropTarget::OnMove( int WXUNUSED(x), int WXUNUSED(y) )
{
printf( "text move.\n" );
return IsSupported( wxDF_TEXT ); // same as "TEXT"
}
bool wxTextDropTarget::OnDrop( int x, int y )
{
printf( "text drop.\n" );
if (!IsSupported( wxDF_TEXT )) return FALSE;
wxTextDataObject data;
@ -314,8 +426,161 @@ bool wxFileDropTarget::OnDrop( int x, int y )
// wxDropSource
//-------------------------------------------------------------------------
wxDropSource::wxDropSource( wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
}
wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
if (data)
{
m_data = new wxDataBroker();
m_data->Add( data );
}
else
{
m_data = (wxDataBroker*) NULL;
}
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
}
wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
m_data = data;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
}
void wxDropSource::SetData( wxDataObject *data )
{
if (m_data) delete m_data;
if (data)
{
m_data = new wxDataBroker();
m_data->Add( data );
}
else
{
m_data = (wxDataBroker*) NULL;
}
}
void wxDropSource::SetData( wxDataBroker *data )
{
if (m_data) delete m_data;
m_data = data;
}
wxDropSource::~wxDropSource(void)
{
if (m_data) delete m_data;
g_blockEventsOnDrag = FALSE;
}
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
wxASSERT_MSG( m_data, "wxDragSource: no data" );
if (!m_data) return (wxDragResult) wxDragNone;
static GtkWidget *drag_icon = (GtkWidget*) NULL;
static GtkWidget *drop_icon = (GtkWidget*) NULL;
GdkPoint hotspot_1 = {0,-5 };
if (!drag_icon)
{
/*
drag_icon = shape_create_icon ( m_stopIcon,
440, 140, 0,0, GTK_WINDOW_POPUP);
gtk_signal_connect (GTK_OBJECT (drag_icon), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&drag_icon);
gtk_widget_hide (drag_icon);
*/
}
GdkPoint hotspot_2 = {-5,-5};
if (!drop_icon)
{
/*
drop_icon = shape_create_icon ( m_goIcon,
440, 140, 0,0, GTK_WINDOW_POPUP);
gtk_signal_connect (GTK_OBJECT (drop_icon), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&drop_icon);
gtk_widget_hide (drop_icon);
*/
}
return FALSE;
}
void wxDropSource::RegisterWindow(void)
{
if (!m_data) return;
}
void wxDropSource::UnregisterWindow(void)
{
if (!m_widget) return;
}
#else // NEW_CODE
//----------------------------------------------------------------------------
// forward
//----------------------------------------------------------------------------
GtkWidget *shape_create_icon ( const wxIcon &shape,
gint x,
gint y,
@ -323,92 +588,6 @@ GtkWidget *shape_create_icon ( const wxIcon &shape,
gint py,
gint window_type);
/* XPM */
static char * gv_xpm[] = {
"40 34 3 1",
" s None c None",
". c black",
"X c white",
" ",
" ",
" ...... ",
" ..XXXXXX.. ",
" .XXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXX. ",
" .XXX..XXXX..XXX. ",
" ....XX....XX....XX. ",
" .XXX.XXX..XXXX..XXX.... ",
" .XXXXXXXXXXXXXXXXXXX.XXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXXX. ",
" ..XXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXX... ",
" ..XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXX.XXXXXXX. ",
" .XXXXXXX.XXXXXXX.XXXXXXX. ",
" .XXXXXXXX.XXXXXXX.XXXXXXX. ",
" .XXXXXXX...XXXXX...XXXXX. ",
" .XXXXXXX. ..... ..... ",
" ..XXXX.. ",
" .... ",
" ",
" ",
" "};
/* XPM */
static char * page_xpm[] = {
/* width height ncolors chars_per_pixel */
"32 32 5 1",
/* colors */
" s None c None",
". c black",
"X c wheat",
"o c tan",
"O c #6699FF",
/* pixels */
" ................... ",
" .XXXXXXXXXXXXXXXXX.. ",
" .XXXXXXXXXXXXXXXXX.o. ",
" .XXXXXXXXXXXXXXXXX.oo. ",
" .XXXXXXXXXXXXXXXXX.ooo. ",
" .XXXXXXXXXXXXXXXXX.oooo. ",
" .XXXXXXXXXXXXXXXXX....... ",
" .XXXXXOOOOOOOOOOXXXooooo. ",
" .XXXXXXXXXXXXXXXXXXooooo. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" ......................... "};
//-----------------------------------------------------------------------------
// globals
//-----------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ IMPLEMENT_CLASS(wxDataFormat, wxObject)
wxDataFormat::wxDataFormat()
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
m_type = wxDF_INVALID;
m_hasAtom = FALSE;
m_atom = (GdkAtom) 0;
@ -40,19 +40,19 @@ wxDataFormat::wxDataFormat()
wxDataFormat::wxDataFormat( wxDataType type )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
SetType( type );
}
wxDataFormat::wxDataFormat( const wxString &id )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
SetId( id );
}
wxDataFormat::wxDataFormat( wxDataFormat &format )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
m_type = format.GetType();
m_id = format.GetId();
m_hasAtom = TRUE;
@ -61,7 +61,7 @@ wxDataFormat::wxDataFormat( wxDataFormat &format )
wxDataFormat::wxDataFormat( const GdkAtom atom )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
m_hasAtom = TRUE;
m_atom = atom;
@ -91,7 +91,7 @@ void wxDataFormat::SetType( wxDataType type )
if (m_type == wxDF_TEXT)
{
m_id = "TEXT";
m_id = "text/plain";
}
else
if (m_type == wxDF_BITMAP)

View File

@ -27,12 +27,102 @@
#include <X11/Xlib.h>
// ----------------------------------------------------------------------------
// global
// ----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// global data
//----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------
// standard icons
//----------------------------------------------------------------------------
/* XPM */
static char * gv_xpm[] = {
"40 34 3 1",
" s None c None",
". c black",
"X c white",
" ",
" ",
" ...... ",
" ..XXXXXX.. ",
" .XXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXX. ",
" .XXX..XXXX..XXX. ",
" ....XX....XX....XX. ",
" .XXX.XXX..XXXX..XXX.... ",
" .XXXXXXXXXXXXXXXXXXX.XXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXXX. ",
" ..XXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXX... ",
" ..XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXX.XXXXXXX. ",
" .XXXXXXX.XXXXXXX.XXXXXXX. ",
" .XXXXXXXX.XXXXXXX.XXXXXXX. ",
" .XXXXXXX...XXXXX...XXXXX. ",
" .XXXXXXX. ..... ..... ",
" ..XXXX.. ",
" .... ",
" ",
" ",
" "};
/* XPM */
static char * page_xpm[] = {
/* width height ncolors chars_per_pixel */
"32 32 5 1",
/* colors */
" s None c None",
". c black",
"X c wheat",
"o c tan",
"O c #6699FF",
/* pixels */
" ................... ",
" .XXXXXXXXXXXXXXXXX.. ",
" .XXXXXXXXXXXXXXXXX.o. ",
" .XXXXXXXXXXXXXXXXX.oo. ",
" .XXXXXXXXXXXXXXXXX.ooo. ",
" .XXXXXXXXXXXXXXXXX.oooo. ",
" .XXXXXXXXXXXXXXXXX....... ",
" .XXXXXOOOOOOOOOOXXXooooo. ",
" .XXXXXXXXXXXXXXXXXXooooo. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" ......................... "};
#if (GTK_MINOR_VERSION > 0)
#include "gtk/gtkdnd.h"
@ -147,18 +237,35 @@ void wxDropTarget::OnLeave()
bool wxDropTarget::OnMove( int x, int y )
{
printf( "mouse move %d %d.\n", x, y );
printf( "generic move %d %d.\n", x, y );
return TRUE;
}
bool wxDropTarget::OnDrop( int x, int y )
{
printf( "mouse move %d %d.\n", x, y );
printf( "generic drop %d %d.\n", x, y );
return TRUE;
}
bool wxDropTarget::IsSupported( wxDataFormat format )
{
{
printf( "generic is supported.\n" );
if (!m_dragContext) return FALSE;
GList *child = m_dragContext->targets;
while (child)
{
GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
char *name = gdk_atom_name( formatAtom );
if (name) printf( "Format available: %s.\n", name );
child = child->next;
}
return TRUE;
}
@ -199,6 +306,7 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
format.flags = 0;
char buf[100];
strcpy( buf, "text/plain" );
format.target = buf;
gtk_drag_dest_set( widget,
GTK_DEST_DEFAULT_ALL,
@ -225,11 +333,15 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
bool wxTextDropTarget::OnMove( int WXUNUSED(x), int WXUNUSED(y) )
{
printf( "text move.\n" );
return IsSupported( wxDF_TEXT ); // same as "TEXT"
}
bool wxTextDropTarget::OnDrop( int x, int y )
{
printf( "text drop.\n" );
if (!IsSupported( wxDF_TEXT )) return FALSE;
wxTextDataObject data;
@ -314,8 +426,161 @@ bool wxFileDropTarget::OnDrop( int x, int y )
// wxDropSource
//-------------------------------------------------------------------------
wxDropSource::wxDropSource( wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
}
wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
if (data)
{
m_data = new wxDataBroker();
m_data->Add( data );
}
else
{
m_data = (wxDataBroker*) NULL;
}
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
}
wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
m_data = data;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
}
void wxDropSource::SetData( wxDataObject *data )
{
if (m_data) delete m_data;
if (data)
{
m_data = new wxDataBroker();
m_data->Add( data );
}
else
{
m_data = (wxDataBroker*) NULL;
}
}
void wxDropSource::SetData( wxDataBroker *data )
{
if (m_data) delete m_data;
m_data = data;
}
wxDropSource::~wxDropSource(void)
{
if (m_data) delete m_data;
g_blockEventsOnDrag = FALSE;
}
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
wxASSERT_MSG( m_data, "wxDragSource: no data" );
if (!m_data) return (wxDragResult) wxDragNone;
static GtkWidget *drag_icon = (GtkWidget*) NULL;
static GtkWidget *drop_icon = (GtkWidget*) NULL;
GdkPoint hotspot_1 = {0,-5 };
if (!drag_icon)
{
/*
drag_icon = shape_create_icon ( m_stopIcon,
440, 140, 0,0, GTK_WINDOW_POPUP);
gtk_signal_connect (GTK_OBJECT (drag_icon), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&drag_icon);
gtk_widget_hide (drag_icon);
*/
}
GdkPoint hotspot_2 = {-5,-5};
if (!drop_icon)
{
/*
drop_icon = shape_create_icon ( m_goIcon,
440, 140, 0,0, GTK_WINDOW_POPUP);
gtk_signal_connect (GTK_OBJECT (drop_icon), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&drop_icon);
gtk_widget_hide (drop_icon);
*/
}
return FALSE;
}
void wxDropSource::RegisterWindow(void)
{
if (!m_data) return;
}
void wxDropSource::UnregisterWindow(void)
{
if (!m_widget) return;
}
#else // NEW_CODE
//----------------------------------------------------------------------------
// forward
//----------------------------------------------------------------------------
GtkWidget *shape_create_icon ( const wxIcon &shape,
gint x,
gint y,
@ -323,92 +588,6 @@ GtkWidget *shape_create_icon ( const wxIcon &shape,
gint py,
gint window_type);
/* XPM */
static char * gv_xpm[] = {
"40 34 3 1",
" s None c None",
". c black",
"X c white",
" ",
" ",
" ...... ",
" ..XXXXXX.. ",
" .XXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXX. ",
" .XXX..XXXX..XXX. ",
" ....XX....XX....XX. ",
" .XXX.XXX..XXXX..XXX.... ",
" .XXXXXXXXXXXXXXXXXXX.XXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXXX. ",
" ..XXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXX... ",
" ..XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXX.XXXXXXX. ",
" .XXXXXXX.XXXXXXX.XXXXXXX. ",
" .XXXXXXXX.XXXXXXX.XXXXXXX. ",
" .XXXXXXX...XXXXX...XXXXX. ",
" .XXXXXXX. ..... ..... ",
" ..XXXX.. ",
" .... ",
" ",
" ",
" "};
/* XPM */
static char * page_xpm[] = {
/* width height ncolors chars_per_pixel */
"32 32 5 1",
/* colors */
" s None c None",
". c black",
"X c wheat",
"o c tan",
"O c #6699FF",
/* pixels */
" ................... ",
" .XXXXXXXXXXXXXXXXX.. ",
" .XXXXXXXXXXXXXXXXX.o. ",
" .XXXXXXXXXXXXXXXXX.oo. ",
" .XXXXXXXXXXXXXXXXX.ooo. ",
" .XXXXXXXXXXXXXXXXX.oooo. ",
" .XXXXXXXXXXXXXXXXX....... ",
" .XXXXXOOOOOOOOOOXXXooooo. ",
" .XXXXXXXXXXXXXXXXXXooooo. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOOOOXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXOOOOOOOOOOXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXOOOOOOOXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" ......................... "};
//-----------------------------------------------------------------------------
// globals
//-----------------------------------------------------------------------------