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