dnd.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/dnd.h
  3. // Purpose: Declaration of the wxDropTarget, wxDropSource class etc.
  4. // Author: Stefan Csomor
  5. // Copyright: (c) 1998 Stefan Csomor
  6. // Licence: wxWindows licence
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_DND_H_
  9. #define _WX_DND_H_
  10. #if wxUSE_DRAG_AND_DROP
  11. #include "wx/defs.h"
  12. #include "wx/object.h"
  13. #include "wx/string.h"
  14. #include "wx/string.h"
  15. #include "wx/dataobj.h"
  16. #include "wx/cursor.h"
  17. //-------------------------------------------------------------------------
  18. // classes
  19. //-------------------------------------------------------------------------
  20. class WXDLLIMPEXP_FWD_CORE wxWindow;
  21. class WXDLLIMPEXP_FWD_CORE wxDropTarget;
  22. class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
  23. class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
  24. class WXDLLIMPEXP_FWD_CORE wxDropSource;
  25. // ----------------------------------------------------------------------------
  26. // macros
  27. // ----------------------------------------------------------------------------
  28. // this macro may be used instead for wxDropSource ctor arguments: it will use
  29. // the icon 'name' from an XPM file under GTK, but will expand to something
  30. // else under MSW. If you don't use it, you will have to use #ifdef in the
  31. // application code.
  32. #define wxDROP_ICON(X) wxCursor(X##_xpm)
  33. //-------------------------------------------------------------------------
  34. // wxDropTarget
  35. //-------------------------------------------------------------------------
  36. class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
  37. {
  38. public:
  39. wxDropTarget(wxDataObject *dataObject = NULL );
  40. virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
  41. virtual bool OnDrop(wxCoord x, wxCoord y);
  42. virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
  43. virtual bool GetData();
  44. // NOTE: This is needed by the generic wxDataViewCtrl, not sure how to implement.
  45. virtual wxDataFormat GetMatchingPair();
  46. bool CurrentDragHasSupportedFormat() ;
  47. void SetCurrentDragPasteboard( void* dragpasteboard ) { m_currentDragPasteboard = dragpasteboard ; }
  48. protected :
  49. void* m_currentDragPasteboard ;
  50. };
  51. //-------------------------------------------------------------------------
  52. // wxDropSource
  53. //-------------------------------------------------------------------------
  54. class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
  55. {
  56. public:
  57. // ctors: if you use default ctor you must call SetData() later!
  58. //
  59. // NB: the "wxWindow *win" parameter is unused and is here only for wxGTK
  60. // compatibility, as well as both icon parameters
  61. wxDropSource( wxWindow *win = NULL,
  62. const wxCursor &cursorCopy = wxNullCursor,
  63. const wxCursor &cursorMove = wxNullCursor,
  64. const wxCursor &cursorStop = wxNullCursor);
  65. /* constructor for setting one data object */
  66. wxDropSource( wxDataObject& data,
  67. wxWindow *win,
  68. const wxCursor &cursorCopy = wxNullCursor,
  69. const wxCursor &cursorMove = wxNullCursor,
  70. const wxCursor &cursorStop = wxNullCursor);
  71. virtual ~wxDropSource();
  72. // do it (call this in response to a mouse button press, for example)
  73. // params: if bAllowMove is false, data can be only copied
  74. virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
  75. wxWindow* GetWindow() { return m_window ; }
  76. void SetCurrentDragPasteboard( void* dragpasteboard ) { m_currentDragPasteboard = dragpasteboard ; }
  77. bool MacInstallDefaultCursor(wxDragResult effect) ;
  78. static wxDropSource* GetCurrentDropSource();
  79. protected :
  80. wxWindow *m_window;
  81. void* m_currentDragPasteboard ;
  82. };
  83. #endif // wxUSE_DRAG_AND_DROP
  84. #endif
  85. //_WX_DND_H_