1998-05-20 10:01:55 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2011-03-19 20:14:35 -04:00
|
|
|
// Name: wx/gtk/dnd.h
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose: declaration of the wxDropTarget class
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-08-30 01:55:56 -04:00
|
|
|
#ifndef _WX_GTK_DND_H_
|
|
|
|
#define _WX_GTK_DND_H_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-02-09 03:18:14 -05:00
|
|
|
#include "wx/icon.h"
|
1998-07-27 16:50:48 -04:00
|
|
|
|
2000-07-15 15:51:35 -04: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 13:24:14 -04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDropTarget
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
|
1999-04-06 13:24:14 -04:00
|
|
|
{
|
|
|
|
public:
|
2009-01-19 08:55:27 -05:00
|
|
|
wxDropTarget(wxDataObject *dataObject = NULL );
|
1999-10-23 19:40:55 -04:00
|
|
|
|
1999-10-21 13:47:45 -04:00
|
|
|
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
1999-10-21 06:23:30 -04:00
|
|
|
virtual bool OnDrop(wxCoord x, wxCoord y);
|
1999-10-23 19:40:55 -04:00
|
|
|
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
1999-10-21 06:23:30 -04:00
|
|
|
virtual bool GetData();
|
|
|
|
|
2009-01-21 09:01:31 -05:00
|
|
|
// Can only be called during OnXXX methods.
|
|
|
|
wxDataFormat GetMatchingPair();
|
1999-10-21 06:23:30 -04:00
|
|
|
|
2009-01-21 06:36:28 -05:00
|
|
|
// implementation
|
2009-03-22 13:18:07 -04:00
|
|
|
|
2009-11-15 08:39:05 -05:00
|
|
|
GdkAtom GTKGetMatchingPair(bool quiet = false);
|
|
|
|
wxDragResult GTKFigureOutSuggestedAction();
|
1999-10-21 16:16:53 -04:00
|
|
|
|
2009-01-21 06:36:28 -05:00
|
|
|
void GtkRegisterWidget( GtkWidget *widget );
|
|
|
|
void GtkUnregisterWidget( GtkWidget *widget );
|
1999-10-21 06:23:30 -04:00
|
|
|
|
|
|
|
GdkDragContext *m_dragContext;
|
|
|
|
GtkWidget *m_dragWidget;
|
|
|
|
GtkSelectionData *m_dragData;
|
2011-09-07 12:56:50 -04:00
|
|
|
unsigned m_dragTime;
|
2002-04-28 10:30:54 -04:00
|
|
|
bool m_firstMotion; // gdk has no "gdk_drag_enter" event
|
1999-10-21 06:23:30 -04:00
|
|
|
|
2009-11-15 08:39:05 -05:00
|
|
|
void GTKSetDragContext( GdkDragContext *dc ) { m_dragContext = dc; }
|
|
|
|
void GTKSetDragWidget( GtkWidget *w ) { m_dragWidget = w; }
|
|
|
|
void GTKSetDragData( GtkSelectionData *sd ) { m_dragData = sd; }
|
2011-09-07 12:56:50 -04:00
|
|
|
void GTKSetDragTime(unsigned time) { m_dragTime = time; }
|
1999-10-20 21:58:57 -04:00
|
|
|
};
|
1999-10-16 21:18:49 -04:00
|
|
|
|
1999-10-20 21:58:57 -04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDropSource
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
|
1999-10-20 21:58:57 -04:00
|
|
|
{
|
|
|
|
public:
|
2002-04-28 10:30:54 -04:00
|
|
|
// constructor. set data later with SetData()
|
2009-01-19 08:55:27 -05:00
|
|
|
wxDropSource( wxWindow *win = NULL,
|
2000-07-15 15:51:35 -04:00
|
|
|
const wxIcon © = wxNullIcon,
|
|
|
|
const wxIcon &move = wxNullIcon,
|
|
|
|
const wxIcon &none = wxNullIcon);
|
1999-10-16 21:18:49 -04:00
|
|
|
|
2002-04-28 10:30:54 -04:00
|
|
|
// constructor for setting one data object
|
1999-10-20 21:58:57 -04:00
|
|
|
wxDropSource( wxDataObject& data,
|
|
|
|
wxWindow *win,
|
2000-07-15 15:51:35 -04:00
|
|
|
const wxIcon © = wxNullIcon,
|
|
|
|
const wxIcon &move = wxNullIcon,
|
|
|
|
const wxIcon &none = wxNullIcon);
|
1999-10-16 21:18:49 -04:00
|
|
|
|
2002-04-28 10:30:54 -04:00
|
|
|
virtual ~wxDropSource();
|
1999-10-16 21:18:49 -04:00
|
|
|
|
2012-05-03 19:30:40 -04:00
|
|
|
// set the icon corresponding to given drag result
|
|
|
|
void SetIcon(wxDragResult res, const wxIcon& icon)
|
|
|
|
{
|
|
|
|
if ( res == wxDragCopy )
|
|
|
|
m_iconCopy = icon;
|
|
|
|
else if ( res == wxDragMove )
|
|
|
|
m_iconMove = icon;
|
|
|
|
else
|
|
|
|
m_iconNone = icon;
|
|
|
|
}
|
|
|
|
|
2002-04-28 10:30:54 -04:00
|
|
|
// start drag action
|
|
|
|
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
|
1999-10-16 21:18:49 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
void PrepareIcon( int action, GdkDragContext *context );
|
1999-10-23 19:40:55 -04:00
|
|
|
|
1999-10-22 18:43:21 -04:00
|
|
|
GtkWidget *m_widget;
|
|
|
|
GtkWidget *m_iconWindow;
|
|
|
|
GdkDragContext *m_dragContext;
|
|
|
|
wxWindow *m_window;
|
1999-10-23 19:40:55 -04:00
|
|
|
|
1999-10-22 18:43:21 -04:00
|
|
|
wxDragResult m_retValue;
|
2000-07-15 15:51:35 -04:00
|
|
|
wxIcon m_iconCopy,
|
|
|
|
m_iconMove,
|
|
|
|
m_iconNone;
|
1999-10-23 19:40:55 -04:00
|
|
|
|
1999-10-22 18:43:21 -04:00
|
|
|
bool m_waiting;
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
// common part of both ctors
|
|
|
|
void SetIcons(const wxIcon& copy,
|
|
|
|
const wxIcon& move,
|
|
|
|
const wxIcon& none);
|
2007-11-03 17:46:55 -04:00
|
|
|
|
|
|
|
// GTK implementation
|
|
|
|
void GTKConnectDragSignals();
|
|
|
|
void GTKDisconnectDragSignals();
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2006-08-30 01:55:56 -04:00
|
|
|
#endif // _WX_GTK_DND_H_
|
1998-05-20 10:01:55 -04:00
|
|
|
|