1 /////////////////////////////////////////////////////////////////////////////// 
   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 /////////////////////////////////////////////////////////////////////////////// 
  14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  20 #if wxUSE_DRAG_AND_DROP 
  22 #include "wx/object.h" 
  23 #include "wx/string.h" 
  24 #include "wx/dataobj.h" 
  25 #include "wx/cursor.h" 
  27 //------------------------------------------------------------------------- 
  29 //------------------------------------------------------------------------- 
  31 class WXDLLEXPORT wxWindow
; 
  33 class WXDLLEXPORT wxDropTarget
; 
  34 class WXDLLEXPORT wxTextDropTarget
; 
  35 class WXDLLEXPORT wxFileDropTarget
; 
  36 class WXDLLEXPORT wxPrivateDropTarget
; 
  38 class WXDLLEXPORT wxDropSource
; 
  40 //------------------------------------------------------------------------- 
  42 //------------------------------------------------------------------------- 
  44 class WXDLLEXPORT wxDropTarget
: public wxObject
 
  51     virtual void OnEnter() { } 
  52     virtual void OnLeave() { } 
  53     virtual bool OnDrop( long x
, long y
, const void *data
, size_t size 
) = 0; 
  55     // Override these to indicate what kind of data you support:  
  57     virtual size_t GetFormatCount() const = 0; 
  58     virtual wxDataFormat 
GetFormat(size_t n
) const = 0; 
  63 //------------------------------------------------------------------------- 
  65 //------------------------------------------------------------------------- 
  67 class WXDLLEXPORT wxTextDropTarget
: public wxDropTarget
 
  71     wxTextDropTarget() {}; 
  72     virtual bool OnDrop( long x
, long y
, const void *data
, size_t size 
); 
  73     virtual bool OnDropText( long x
, long y
, const char *psz 
); 
  77     virtual size_t GetFormatCount() const; 
  78     virtual wxDataFormat 
GetFormat(size_t n
) const; 
  81 //------------------------------------------------------------------------- 
  82 // wxPrivateDropTarget 
  83 //------------------------------------------------------------------------- 
  85 class WXDLLEXPORT wxPrivateDropTarget
: public wxDropTarget
 
  89     wxPrivateDropTarget(); 
  91     // you have to override OnDrop to get at the data 
  93     // the string ID identifies the format of clipboard or DnD data. a word 
  94     // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject 
  95     // to the clipboard - the latter with the Id "WXWORD_FORMAT". 
  97     void SetId( const wxString
& id 
) 
 105     virtual size_t GetFormatCount() const; 
 106     virtual wxDataFormat 
GetFormat(size_t n
) const; 
 111 // ---------------------------------------------------------------------------- 
 112 // A drop target which accepts files (dragged from File Manager or Explorer) 
 113 // ---------------------------------------------------------------------------- 
 115 class WXDLLEXPORT wxFileDropTarget
: public wxDropTarget
 
 119     wxFileDropTarget() {}; 
 121     virtual bool OnDrop( long x
, long y
, const void *data
, size_t size 
); 
 122     virtual bool OnDropFiles( long x
, long y
,  
 123         size_t nFiles
, const char * const aszFiles
[] ); 
 127     virtual size_t GetFormatCount() const; 
 128     virtual wxDataFormat 
GetFormat(size_t n
) const; 
 131 //------------------------------------------------------------------------- 
 133 //------------------------------------------------------------------------- 
 137     wxDragError
,    // error prevented the d&d operation from completing 
 138         wxDragNone
,     // drag target didn't accept the data 
 139         wxDragCopy
,     // the data was successfully copied 
 140         wxDragMove
,     // the data was successfully moved 
 141         wxDragCancel    
// the operation was cancelled by user (not an error) 
 144 class WXDLLEXPORT wxDropSource
: public wxObject
 
 148     wxDropSource( wxWindow 
*win 
); 
 149     wxDropSource( wxDataObject 
&data
, wxWindow 
*win 
); 
 153     void SetData( wxDataObject 
&data  
); 
 154     wxDragResult 
DoDragDrop(int flags 
= wxDrag_CopyOnly
); 
 156     virtual bool GiveFeedback( wxDragResult 
WXUNUSED(effect
), bool WXUNUSED(bScrolling
) ) { return TRUE
; }; 
 160     void RegisterWindow(void); 
 161     void UnregisterWindow(void); 
 164     wxDragResult   m_retValue
; 
 165     wxDataObject  
*m_data
; 
 167     wxCursor      m_defaultCursor
; 
 168     wxCursor      m_goaheadCursor
; 
 174 // wxUSE_DRAG_AND_DROP