1998-09-18 06:19:10 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dnd.h
|
1999-01-14 10:15:39 -05:00
|
|
|
// Purpose: declaration of wxDropTarget, wxDropSource classes
|
1998-09-18 06:19:10 -04:00
|
|
|
// Author: Julian Smart
|
|
|
|
// RCS-ID: $Id$
|
1999-01-14 10:15:39 -05:00
|
|
|
// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-09-18 06:19:10 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1999-01-14 10:15:39 -05:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
#ifndef _WX_DND_H_
|
|
|
|
#define _WX_DND_H_
|
|
|
|
|
2003-08-09 08:38:21 -04:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-01-14 10:15:39 -05:00
|
|
|
#pragma interface
|
1998-09-18 06:19:10 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
1999-01-14 10:15:39 -05:00
|
|
|
|
|
|
|
#if wxUSE_DRAG_AND_DROP
|
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
1999-01-14 10:15:39 -05:00
|
|
|
#include "wx/dataobj.h"
|
1998-09-18 06:19:10 -04:00
|
|
|
#include "wx/cursor.h"
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxWindow;
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxDropTarget;
|
|
|
|
class WXDLLEXPORT wxTextDropTarget;
|
|
|
|
class WXDLLEXPORT wxFileDropTarget;
|
1999-01-14 10:15:39 -05:00
|
|
|
class WXDLLEXPORT wxPrivateDropTarget;
|
1998-09-18 06:19:10 -04:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxDropSource;
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDropTarget
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxDropTarget: public wxObject
|
|
|
|
{
|
2002-02-05 11:34:33 -05:00
|
|
|
public:
|
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
wxDropTarget();
|
|
|
|
~wxDropTarget();
|
|
|
|
|
|
|
|
virtual void OnEnter() { }
|
|
|
|
virtual void OnLeave() { }
|
1999-01-14 10:15:39 -05:00
|
|
|
virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
// Override these to indicate what kind of data you support:
|
2002-02-05 11:34:33 -05:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
virtual size_t GetFormatCount() const = 0;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const = 0;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
|
|
|
// implementation
|
1998-09-18 06:19:10 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxTextDropTarget
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
|
|
|
|
{
|
2002-02-05 11:34:33 -05:00
|
|
|
public:
|
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
wxTextDropTarget() {};
|
1999-01-14 10:15:39 -05:00
|
|
|
virtual bool OnDrop( long x, long y, const void *data, size_t size );
|
1998-09-18 06:19:10 -04:00
|
|
|
virtual bool OnDropText( long x, long y, const char *psz );
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
protected:
|
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
virtual size_t GetFormatCount() const;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const;
|
|
|
|
};
|
|
|
|
|
1999-01-14 10:15:39 -05:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxPrivateDropTarget
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxPrivateDropTarget: public wxDropTarget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxPrivateDropTarget();
|
1999-01-14 10:15:39 -05:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// you have to override OnDrop to get at the data
|
|
|
|
|
|
|
|
// 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".
|
|
|
|
|
|
|
|
void SetId( const wxString& id )
|
|
|
|
{ m_id = id; }
|
|
|
|
|
|
|
|
wxString GetId()
|
|
|
|
{ return m_id; }
|
1999-01-14 10:15:39 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual size_t GetFormatCount() const;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const;
|
|
|
|
|
|
|
|
wxString m_id;
|
1999-01-14 10:15:39 -05:00
|
|
|
};
|
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// A drop target which accepts files (dragged from File Manager or Explorer)
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
|
|
|
|
{
|
2002-02-05 11:34:33 -05:00
|
|
|
public:
|
1998-09-18 06:19:10 -04:00
|
|
|
|
|
|
|
wxFileDropTarget() {};
|
|
|
|
|
1999-01-14 10:15:39 -05:00
|
|
|
virtual bool OnDrop( long x, long y, const void *data, size_t size );
|
1998-09-18 06:19:10 -04:00
|
|
|
virtual bool OnDropFiles( long x, long y,
|
2002-02-05 11:34:33 -05:00
|
|
|
size_t nFiles, const char * const aszFiles[] );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
virtual size_t GetFormatCount() const;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDropSource
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1999-01-14 10:15:39 -05:00
|
|
|
enum wxDragResult
|
|
|
|
{
|
2002-02-05 11:34:33 -05:00
|
|
|
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)
|
1999-01-14 10:15:39 -05:00
|
|
|
};
|
1998-09-18 06:19:10 -04:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxDropSource: public wxObject
|
|
|
|
{
|
2002-02-05 11:34:33 -05:00
|
|
|
public:
|
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
wxDropSource( wxWindow *win );
|
|
|
|
wxDropSource( wxDataObject &data, wxWindow *win );
|
|
|
|
|
|
|
|
~wxDropSource(void);
|
|
|
|
|
|
|
|
void SetData( wxDataObject &data );
|
2002-04-28 10:30:54 -04:00
|
|
|
wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
|
1998-09-18 06:19:10 -04:00
|
|
|
|
|
|
|
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
|
2002-02-05 11:34:33 -05:00
|
|
|
|
|
|
|
// implementation
|
1999-01-14 10:15:39 -05:00
|
|
|
#if 0
|
|
|
|
void RegisterWindow(void);
|
|
|
|
void UnregisterWindow(void);
|
2002-02-05 11:34:33 -05:00
|
|
|
|
1999-01-14 10:15:39 -05:00
|
|
|
wxWindow *m_window;
|
|
|
|
wxDragResult m_retValue;
|
1998-09-18 06:19:10 -04:00
|
|
|
wxDataObject *m_data;
|
1999-01-14 10:15:39 -05:00
|
|
|
|
|
|
|
wxCursor m_defaultCursor;
|
|
|
|
wxCursor m_goaheadCursor;
|
|
|
|
#endif
|
1998-09-18 06:19:10 -04:00
|
|
|
};
|
|
|
|
|
1999-01-14 10:15:39 -05:00
|
|
|
#endif
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// wxUSE_DRAG_AND_DROP
|
1999-01-14 10:15:39 -05:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
#endif
|
2002-02-05 11:34:33 -05:00
|
|
|
//_WX_DND_H_
|
1998-09-18 06:19:10 -04:00
|
|
|
|