1998-09-18 06:19:10 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2006-07-25 10:31:55 -04:00
|
|
|
// Name: wx/motif/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
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_DND_H_
|
|
|
|
#define _WX_DND_H_
|
|
|
|
|
|
|
|
#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:
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
wxDropTarget();
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxDropTarget();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
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;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
|
|
|
// Override these to indicate what kind of data you support:
|
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
virtual size_t GetFormatCount() const = 0;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const = 0;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
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:
|
2006-07-25 10:31:55 -04:00
|
|
|
|
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 );
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
protected:
|
2006-07-25 10:31:55 -04:00
|
|
|
|
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:
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxPrivateDropTarget();
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// you have to override OnDrop to get at the data
|
2006-07-25 10:31:55 -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".
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
void SetId( const wxString& id )
|
|
|
|
{ m_id = id; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
wxString GetId()
|
|
|
|
{ return m_id; }
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-01-14 10:15:39 -05:00
|
|
|
private:
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
virtual size_t GetFormatCount() const;
|
|
|
|
virtual wxDataFormat GetFormat(size_t n) const;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
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:
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
wxFileDropTarget() {};
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1999-01-14 10:15:39 -05:00
|
|
|
virtual bool OnDrop( long x, long y, const void *data, size_t size );
|
2006-07-25 10:31:55 -04:00
|
|
|
virtual bool OnDropFiles( long x, long y,
|
2002-02-05 11:34:33 -05:00
|
|
|
size_t nFiles, const char * const aszFiles[] );
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
protected:
|
2006-07-25 10:31:55 -04:00
|
|
|
|
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:
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
wxDropSource( wxWindow *win );
|
|
|
|
wxDropSource( wxDataObject &data, wxWindow *win );
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxDropSource(void);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
1998-09-18 06:19:10 -04:00
|
|
|
void SetData( wxDataObject &data );
|
2002-04-28 10:30:54 -04:00
|
|
|
wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
|
2006-07-25 10:31:55 -04:00
|
|
|
|
2005-02-06 12:38:33 -05:00
|
|
|
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return true; };
|
2006-07-25 10:31:55 -04:00
|
|
|
|
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);
|
2006-07-25 10:31:55 -04: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;
|
2006-07-25 10:31:55 -04:00
|
|
|
|
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
|
|
|
|
2006-07-25 10:31:55 -04:00
|
|
|
#endif
|
2002-02-05 11:34:33 -05:00
|
|
|
//_WX_DND_H_
|