]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dnd.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / gtk / dnd.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/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 _WX_GTK_DND_H_
10 #define _WX_GTK_DND_H_
11
12 #include "wx/icon.h"
13
14 // ----------------------------------------------------------------------------
15 // macros
16 // ----------------------------------------------------------------------------
17
18 // this macro may be used instead for wxDropSource ctor arguments: it will use
19 // the icon 'name' from an XPM file under GTK, but will expand to something
20 // else under MSW. If you don't use it, you will have to use #ifdef in the
21 // application code.
22 #define wxDROP_ICON(name) wxICON(name)
23
24 //-------------------------------------------------------------------------
25 // wxDropTarget
26 //-------------------------------------------------------------------------
27
28 class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
29 {
30 public:
31 wxDropTarget(wxDataObject *dataObject = NULL );
32
33 virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
34 virtual bool OnDrop(wxCoord x, wxCoord y);
35 virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
36 virtual bool GetData();
37
38 // Can only be called during OnXXX methods.
39 wxDataFormat GetMatchingPair();
40
41 // implementation
42
43 GdkAtom GTKGetMatchingPair(bool quiet = false);
44 wxDragResult GTKFigureOutSuggestedAction();
45
46 void GtkRegisterWidget( GtkWidget *widget );
47 void GtkUnregisterWidget( GtkWidget *widget );
48
49 GdkDragContext *m_dragContext;
50 GtkWidget *m_dragWidget;
51 GtkSelectionData *m_dragData;
52 unsigned m_dragTime;
53 bool m_firstMotion; // gdk has no "gdk_drag_enter" event
54
55 void GTKSetDragContext( GdkDragContext *dc ) { m_dragContext = dc; }
56 void GTKSetDragWidget( GtkWidget *w ) { m_dragWidget = w; }
57 void GTKSetDragData( GtkSelectionData *sd ) { m_dragData = sd; }
58 void GTKSetDragTime(unsigned time) { m_dragTime = time; }
59 };
60
61 //-------------------------------------------------------------------------
62 // wxDropSource
63 //-------------------------------------------------------------------------
64
65 class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
66 {
67 public:
68 // constructor. set data later with SetData()
69 wxDropSource( wxWindow *win = NULL,
70 const wxIcon &copy = wxNullIcon,
71 const wxIcon &move = wxNullIcon,
72 const wxIcon &none = wxNullIcon);
73
74 // constructor for setting one data object
75 wxDropSource( wxDataObject& data,
76 wxWindow *win,
77 const wxIcon &copy = wxNullIcon,
78 const wxIcon &move = wxNullIcon,
79 const wxIcon &none = wxNullIcon);
80
81 virtual ~wxDropSource();
82
83 // set the icon corresponding to given drag result
84 void SetIcon(wxDragResult res, const wxIcon& icon)
85 {
86 if ( res == wxDragCopy )
87 m_iconCopy = icon;
88 else if ( res == wxDragMove )
89 m_iconMove = icon;
90 else
91 m_iconNone = icon;
92 }
93
94 // start drag action
95 virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
96
97 void PrepareIcon( int action, GdkDragContext *context );
98
99 GtkWidget *m_widget;
100 GtkWidget *m_iconWindow;
101 GdkDragContext *m_dragContext;
102 wxWindow *m_window;
103
104 wxDragResult m_retValue;
105 wxIcon m_iconCopy,
106 m_iconMove,
107 m_iconNone;
108
109 bool m_waiting;
110
111 private:
112 // common part of both ctors
113 void SetIcons(const wxIcon& copy,
114 const wxIcon& move,
115 const wxIcon& none);
116
117 // GTK implementation
118 void GTKConnectDragSignals();
119 void GTKDisconnectDragSignals();
120
121 };
122
123 #endif // _WX_GTK_DND_H_
124