1998-05-20 14:01:55 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2006-01-23 02:28:01 +00:00
|
|
|
// Name: wx/gtk1/dnd.h
|
1998-05-20 14:01:55 +00:00
|
|
|
// Purpose: declaration of the wxDropTarget class
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __GTKDNDH__
|
|
|
|
#define __GTKDNDH__
|
|
|
|
|
1999-01-06 21:09:17 +00:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
1999-01-04 13:52:06 +00:00
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
1998-12-14 16:13:49 +00:00
|
|
|
#include "wx/dataobj.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#include "wx/cursor.h"
|
1999-02-09 08:18:14 +00:00
|
|
|
#include "wx/icon.h"
|
|
|
|
#include "wx/gdicmn.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDropTarget;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
|
1998-07-27 20:50:48 +00:00
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDropSource;
|
1998-07-27 20:50:48 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// this macro may be used instead for wxDropSource ctor arguments: it will use
|
|
|
|
// the icon 'name' from an XPM file under GTK, but will expand to something
|
|
|
|
// else under MSW. If you don't use it, you will have to use #ifdef in the
|
|
|
|
// application code.
|
|
|
|
#define wxDROP_ICON(name) wxICON(name)
|
|
|
|
|
1999-04-06 17:24:14 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDropTarget
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 22:58:06 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
|
1999-04-06 17:24:14 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-01-19 13:55:27 +00:00
|
|
|
wxDropTarget(wxDataObject *dataObject = NULL );
|
1999-10-23 23:40:55 +00:00
|
|
|
|
1999-10-21 17:47:45 +00:00
|
|
|
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
1999-10-21 10:23:30 +00:00
|
|
|
virtual bool OnDrop(wxCoord x, wxCoord y);
|
1999-10-23 23:40:55 +00:00
|
|
|
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
1999-10-21 10:23:30 +00:00
|
|
|
virtual bool GetData();
|
|
|
|
|
|
|
|
// implementation
|
|
|
|
|
2009-03-22 17:18:07 +00:00
|
|
|
GdkAtom GetMatchingPair(bool quiet = false);
|
1999-10-21 20:16:53 +00:00
|
|
|
|
1999-10-21 10:23:30 +00:00
|
|
|
void RegisterWidget( GtkWidget *widget );
|
|
|
|
void UnregisterWidget( GtkWidget *widget );
|
|
|
|
|
|
|
|
GdkDragContext *m_dragContext;
|
|
|
|
GtkWidget *m_dragWidget;
|
|
|
|
GtkSelectionData *m_dragData;
|
2011-09-07 16:56:50 +00:00
|
|
|
unsigned m_dragTime;
|
2002-04-28 14:30:54 +00:00
|
|
|
bool m_firstMotion; // gdk has no "gdk_drag_enter" event
|
1999-10-21 10:23:30 +00:00
|
|
|
|
|
|
|
void SetDragContext( GdkDragContext *dc ) { m_dragContext = dc; }
|
|
|
|
void SetDragWidget( GtkWidget *w ) { m_dragWidget = w; }
|
|
|
|
void SetDragData( GtkSelectionData *sd ) { m_dragData = sd; }
|
2011-09-07 16:56:50 +00:00
|
|
|
void SetDragTime(unsigned time) { m_dragTime = time; }
|
1999-10-21 01:58:57 +00:00
|
|
|
};
|
1999-10-17 01:18:49 +00:00
|
|
|
|
1999-10-21 01:58:57 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDropSource
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 22:58:06 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
|
1999-10-21 01:58:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2002-04-28 14:30:54 +00:00
|
|
|
// constructor. set data later with SetData()
|
2009-01-19 13:55:27 +00:00
|
|
|
wxDropSource( wxWindow *win = NULL,
|
2000-07-15 19:51:35 +00:00
|
|
|
const wxIcon © = wxNullIcon,
|
|
|
|
const wxIcon &move = wxNullIcon,
|
|
|
|
const wxIcon &none = wxNullIcon);
|
1999-10-17 01:18:49 +00:00
|
|
|
|
2002-04-28 14:30:54 +00:00
|
|
|
// constructor for setting one data object
|
1999-10-21 01:58:57 +00:00
|
|
|
wxDropSource( wxDataObject& data,
|
|
|
|
wxWindow *win,
|
2000-07-15 19:51:35 +00:00
|
|
|
const wxIcon © = wxNullIcon,
|
|
|
|
const wxIcon &move = wxNullIcon,
|
|
|
|
const wxIcon &none = wxNullIcon);
|
1999-10-17 01:18:49 +00:00
|
|
|
|
2002-04-28 14:30:54 +00:00
|
|
|
virtual ~wxDropSource();
|
1999-10-17 01:18:49 +00:00
|
|
|
|
2002-04-28 14:30:54 +00:00
|
|
|
// start drag action
|
|
|
|
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
|
1999-10-17 01:18:49 +00:00
|
|
|
|
2002-04-28 14:30:54 +00:00
|
|
|
// GTK implementation
|
1999-10-21 01:58:57 +00:00
|
|
|
void RegisterWindow();
|
|
|
|
void UnregisterWindow();
|
1999-10-17 01:18:49 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
void PrepareIcon( int action, GdkDragContext *context );
|
1999-10-23 23:40:55 +00:00
|
|
|
|
1999-10-22 22:43:21 +00:00
|
|
|
GtkWidget *m_widget;
|
|
|
|
GtkWidget *m_iconWindow;
|
|
|
|
GdkDragContext *m_dragContext;
|
|
|
|
wxWindow *m_window;
|
1999-10-23 23:40:55 +00:00
|
|
|
|
1999-10-22 22:43:21 +00:00
|
|
|
wxDragResult m_retValue;
|
2000-07-15 19:51:35 +00:00
|
|
|
wxIcon m_iconCopy,
|
|
|
|
m_iconMove,
|
|
|
|
m_iconNone;
|
1999-10-23 23:40:55 +00:00
|
|
|
|
1999-10-22 22:43:21 +00:00
|
|
|
bool m_waiting;
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// common part of both ctors
|
|
|
|
void SetIcons(const wxIcon& copy,
|
|
|
|
const wxIcon& move,
|
|
|
|
const wxIcon& none);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2002-04-28 14:30:54 +00:00
|
|
|
#endif // wxUSE_DRAG_AND_DROP
|
1999-01-04 13:52:06 +00:00
|
|
|
|
2002-04-28 14:30:54 +00:00
|
|
|
#endif //__GTKDNDH__
|
1998-05-20 14:01:55 +00:00
|
|
|
|