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