1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        wx/motif/dnd.h 
   3 // Purpose:     declaration of wxDropTarget, wxDropSource classes 
   4 // Author:      Julian Smart 
   6 // Copyright:   (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart 
   7 // Licence:     wxWindows licence 
   8 /////////////////////////////////////////////////////////////////////////////// 
  15 #if wxUSE_DRAG_AND_DROP 
  17 #include "wx/object.h" 
  18 #include "wx/string.h" 
  19 #include "wx/dataobj.h" 
  20 #include "wx/cursor.h" 
  22 //------------------------------------------------------------------------- 
  24 //------------------------------------------------------------------------- 
  26 class WXDLLIMPEXP_FWD_CORE wxWindow
; 
  28 class WXDLLIMPEXP_FWD_CORE wxDropTarget
; 
  29 class WXDLLIMPEXP_FWD_CORE wxTextDropTarget
; 
  30 class WXDLLIMPEXP_FWD_CORE wxFileDropTarget
; 
  31 class WXDLLIMPEXP_FWD_CORE wxPrivateDropTarget
; 
  33 class WXDLLIMPEXP_FWD_CORE wxDropSource
; 
  35 //------------------------------------------------------------------------- 
  37 //------------------------------------------------------------------------- 
  39 class WXDLLIMPEXP_CORE wxDropTarget
: public wxObject
 
  44     virtual ~wxDropTarget(); 
  46     virtual void OnEnter() { } 
  47     virtual void OnLeave() { } 
  48     virtual bool OnDrop( long x
, long y
, const void *data
, size_t size 
) = 0; 
  50     // Override these to indicate what kind of data you support: 
  52     virtual size_t GetFormatCount() const = 0; 
  53     virtual wxDataFormat 
GetFormat(size_t n
) const = 0; 
  58 //------------------------------------------------------------------------- 
  60 //------------------------------------------------------------------------- 
  62 class WXDLLIMPEXP_CORE wxTextDropTarget
: public wxDropTarget
 
  66     wxTextDropTarget() {}; 
  67     virtual bool OnDrop( long x
, long y
, const void *data
, size_t size 
); 
  68     virtual bool OnDropText( long x
, long y
, const char *psz 
); 
  72     virtual size_t GetFormatCount() const; 
  73     virtual wxDataFormat 
GetFormat(size_t n
) const; 
  76 //------------------------------------------------------------------------- 
  77 // wxPrivateDropTarget 
  78 //------------------------------------------------------------------------- 
  80 class WXDLLIMPEXP_CORE wxPrivateDropTarget
: public wxDropTarget
 
  84     wxPrivateDropTarget(); 
  86     // you have to override OnDrop to get at the data 
  88     // the string ID identifies the format of clipboard or DnD data. a word 
  89     // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject 
  90     // to the clipboard - the latter with the Id "WXWORD_FORMAT". 
  92     void SetId( const wxString
& id 
) 
 100     virtual size_t GetFormatCount() const; 
 101     virtual wxDataFormat 
GetFormat(size_t n
) const; 
 106 // ---------------------------------------------------------------------------- 
 107 // A drop target which accepts files (dragged from File Manager or Explorer) 
 108 // ---------------------------------------------------------------------------- 
 110 class WXDLLIMPEXP_CORE wxFileDropTarget
: public wxDropTarget
 
 114     wxFileDropTarget() {}; 
 116     virtual bool OnDrop( long x
, long y
, const void *data
, size_t size 
); 
 117     virtual bool OnDropFiles( long x
, long y
, 
 118         size_t nFiles
, const char * const aszFiles
[] ); 
 122     virtual size_t GetFormatCount() const; 
 123     virtual wxDataFormat 
GetFormat(size_t n
) const; 
 126 //------------------------------------------------------------------------- 
 128 //------------------------------------------------------------------------- 
 132     wxDragError
,    // error prevented the d&d operation from completing 
 133         wxDragNone
,     // drag target didn't accept the data 
 134         wxDragCopy
,     // the data was successfully copied 
 135         wxDragMove
,     // the data was successfully moved 
 136         wxDragCancel    
// the operation was cancelled by user (not an error) 
 139 class WXDLLIMPEXP_CORE wxDropSource
: public wxObject
 
 143     wxDropSource( wxWindow 
*win 
); 
 144     wxDropSource( wxDataObject 
&data
, wxWindow 
*win 
); 
 146     virtual ~wxDropSource(void); 
 148     void SetData( wxDataObject 
&data  
); 
 149     wxDragResult 
DoDragDrop(int flags 
= wxDrag_CopyOnly
); 
 151     virtual bool GiveFeedback( wxDragResult 
WXUNUSED(effect
), bool WXUNUSED(bScrolling
) ) { return true; }; 
 155     void RegisterWindow(void); 
 156     void UnregisterWindow(void); 
 159     wxDragResult   m_retValue
; 
 160     wxDataObject  
*m_data
; 
 162     wxCursor      m_defaultCursor
; 
 163     wxCursor      m_goaheadCursor
; 
 169 // wxUSE_DRAG_AND_DROP