]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk1/dnd.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / gtk1 / dnd.h
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk1/dnd.h
3// Purpose: declaration of the wxDropTarget class
4// Author: Robert Roebling
5// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
6// Licence: wxWindows licence
7///////////////////////////////////////////////////////////////////////////////
8
9#ifndef __GTKDNDH__
10#define __GTKDNDH__
11
12#if wxUSE_DRAG_AND_DROP
13
14#include "wx/object.h"
15#include "wx/string.h"
16#include "wx/dataobj.h"
17#include "wx/cursor.h"
18#include "wx/icon.h"
19#include "wx/gdicmn.h"
20
21//-------------------------------------------------------------------------
22// classes
23//-------------------------------------------------------------------------
24
25class WXDLLIMPEXP_FWD_CORE wxWindow;
26
27class WXDLLIMPEXP_FWD_CORE wxDropTarget;
28class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
29class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
30
31class WXDLLIMPEXP_FWD_CORE wxDropSource;
32
33// ----------------------------------------------------------------------------
34// macros
35// ----------------------------------------------------------------------------
36
37// this macro may be used instead for wxDropSource ctor arguments: it will use
38// the icon 'name' from an XPM file under GTK, but will expand to something
39// else under MSW. If you don't use it, you will have to use #ifdef in the
40// application code.
41#define wxDROP_ICON(name) wxICON(name)
42
43//-------------------------------------------------------------------------
44// wxDropTarget
45//-------------------------------------------------------------------------
46
47class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
48{
49public:
50 wxDropTarget(wxDataObject *dataObject = NULL );
51
52 virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
53 virtual bool OnDrop(wxCoord x, wxCoord y);
54 virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
55 virtual bool GetData();
56
57 // implementation
58
59 GdkAtom GetMatchingPair(bool quiet = false);
60
61 void RegisterWidget( GtkWidget *widget );
62 void UnregisterWidget( GtkWidget *widget );
63
64 GdkDragContext *m_dragContext;
65 GtkWidget *m_dragWidget;
66 GtkSelectionData *m_dragData;
67 unsigned m_dragTime;
68 bool m_firstMotion; // gdk has no "gdk_drag_enter" event
69
70 void SetDragContext( GdkDragContext *dc ) { m_dragContext = dc; }
71 void SetDragWidget( GtkWidget *w ) { m_dragWidget = w; }
72 void SetDragData( GtkSelectionData *sd ) { m_dragData = sd; }
73 void SetDragTime(unsigned time) { m_dragTime = time; }
74};
75
76//-------------------------------------------------------------------------
77// wxDropSource
78//-------------------------------------------------------------------------
79
80class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
81{
82public:
83 // constructor. set data later with SetData()
84 wxDropSource( wxWindow *win = NULL,
85 const wxIcon &copy = wxNullIcon,
86 const wxIcon &move = wxNullIcon,
87 const wxIcon &none = wxNullIcon);
88
89 // constructor for setting one data object
90 wxDropSource( wxDataObject& data,
91 wxWindow *win,
92 const wxIcon &copy = wxNullIcon,
93 const wxIcon &move = wxNullIcon,
94 const wxIcon &none = wxNullIcon);
95
96 virtual ~wxDropSource();
97
98 // start drag action
99 virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
100
101 // GTK implementation
102 void RegisterWindow();
103 void UnregisterWindow();
104
105 void PrepareIcon( int action, GdkDragContext *context );
106
107 GtkWidget *m_widget;
108 GtkWidget *m_iconWindow;
109 GdkDragContext *m_dragContext;
110 wxWindow *m_window;
111
112 wxDragResult m_retValue;
113 wxIcon m_iconCopy,
114 m_iconMove,
115 m_iconNone;
116
117 bool m_waiting;
118
119private:
120 // common part of both ctors
121 void SetIcons(const wxIcon& copy,
122 const wxIcon& move,
123 const wxIcon& none);
124};
125
126#endif // wxUSE_DRAG_AND_DROP
127
128#endif //__GTKDNDH__
129