2002-02-05 11:34:33 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dnd.h
|
|
|
|
// Purpose: declaration of wxDropTarget, wxDropSource classes
|
|
|
|
// Author: Julian Smart
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2002-02-05 11:34:33 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_DND_H_
|
|
|
|
#define _WX_DND_H_
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_DRAG_AND_DROP
|
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/dataobj.h"
|
|
|
|
#include "wx/cursor.h"
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDropTarget;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrivateDropTarget;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDropSource;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDropTarget
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxDropTarget: public wxObject
|
2002-02-05 11:34:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxDropTarget();
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxDropTarget();
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual void OnEnter() { }
|
|
|
|
virtual void OnLeave() { }
|
|
|
|
virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
|
2009-08-21 06:41:26 -04:00
|
|
|
|
|
|
|
// Override these to indicate what kind of data you support:
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual size_t GetFormatCount() const = 0;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const = 0;
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// implementation
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxTextDropTarget
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxTextDropTarget: public wxDropTarget
|
2002-02-05 11:34:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxTextDropTarget() {};
|
|
|
|
virtual bool OnDrop( long x, long y, const void *data, size_t size );
|
|
|
|
virtual bool OnDropText( long x, long y, const char *psz );
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
protected:
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual size_t GetFormatCount() const;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxPrivateDropTarget
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxPrivateDropTarget: public wxDropTarget
|
2002-02-05 11:34:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxPrivateDropTarget();
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// you have to override OnDrop to get at the data
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// the string ID identifies the format of clipboard or DnD data. a word
|
|
|
|
// processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
|
|
|
|
// to the clipboard - the latter with the Id "WXWORD_FORMAT".
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
void SetId( const wxString& id )
|
|
|
|
{ m_id = id; }
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxString GetId()
|
|
|
|
{ return m_id; }
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
private:
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual size_t GetFormatCount() const;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const;
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxString m_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// A drop target which accepts files (dragged from File Manager or Explorer)
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxFileDropTarget: public wxDropTarget
|
2002-02-05 11:34:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxFileDropTarget() {};
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual bool OnDrop( long x, long y, const void *data, size_t size );
|
2009-08-21 06:41:26 -04:00
|
|
|
virtual bool OnDropFiles( long x, long y,
|
2002-02-05 11:34:33 -05:00
|
|
|
size_t nFiles, const char * const aszFiles[] );
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
protected:
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual size_t GetFormatCount() const;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDropSource
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
enum wxDragResult
|
|
|
|
{
|
|
|
|
wxDragError, // error prevented the d&d operation from completing
|
|
|
|
wxDragNone, // drag target didn't accept the data
|
|
|
|
wxDragCopy, // the data was successfully copied
|
|
|
|
wxDragMove, // the data was successfully moved
|
|
|
|
wxDragCancel // the operation was cancelled by user (not an error)
|
|
|
|
};
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxDropSource: public wxObject
|
2002-02-05 11:34:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxDropSource( wxWindow *win );
|
|
|
|
wxDropSource( wxDataObject &data, wxWindow *win );
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxDropSource(void);
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
void SetData( wxDataObject &data );
|
2002-04-28 10:30:54 -04:00
|
|
|
wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// implementation
|
|
|
|
#if 0
|
|
|
|
void RegisterWindow(void);
|
|
|
|
void UnregisterWindow(void);
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxWindow *m_window;
|
|
|
|
wxDragResult m_retValue;
|
|
|
|
wxDataObject *m_data;
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxCursor m_defaultCursor;
|
|
|
|
wxCursor m_goaheadCursor;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// wxUSE_DRAG_AND_DROP
|
|
|
|
|
2009-08-21 06:41:26 -04:00
|
|
|
#endif
|
2002-02-05 11:34:33 -05:00
|
|
|
//_WX_DND_H_
|
|
|
|
|