]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dnd.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / gtk / dnd.h
CommitLineData
c801d85f 1///////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/gtk/dnd.h
c801d85f
KB
3// Purpose: declaration of the wxDropTarget class
4// Author: Robert Roebling
c801d85f 5// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
65571936 6// Licence: wxWindows licence
c801d85f
KB
7///////////////////////////////////////////////////////////////////////////////
8
0416c418
PC
9#ifndef _WX_GTK_DND_H_
10#define _WX_GTK_DND_H_
c801d85f 11
e4677d31 12#include "wx/icon.h"
e3e65dac 13
f6bcfd97
BP
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
d6086ea6
RR
24//-------------------------------------------------------------------------
25// wxDropTarget
26//-------------------------------------------------------------------------
27
20123d49 28class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
d6086ea6
RR
29{
30public:
d3b9f782 31 wxDropTarget(wxDataObject *dataObject = NULL );
8ee9d618 32
c9057ae1 33 virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
b068c4e8 34 virtual bool OnDrop(wxCoord x, wxCoord y);
8ee9d618 35 virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
b068c4e8
RR
36 virtual bool GetData();
37
51c9c13c
RR
38 // Can only be called during OnXXX methods.
39 wxDataFormat GetMatchingPair();
b068c4e8 40
1fe91d70 41 // implementation
711f12ef 42
1aeae3f7
RR
43 GdkAtom GTKGetMatchingPair(bool quiet = false);
44 wxDragResult GTKFigureOutSuggestedAction();
12db77ca 45
1fe91d70
RR
46 void GtkRegisterWidget( GtkWidget *widget );
47 void GtkUnregisterWidget( GtkWidget *widget );
b068c4e8
RR
48
49 GdkDragContext *m_dragContext;
50 GtkWidget *m_dragWidget;
51 GtkSelectionData *m_dragData;
29e461a2 52 unsigned m_dragTime;
2245b2b2 53 bool m_firstMotion; // gdk has no "gdk_drag_enter" event
b068c4e8 54
1aeae3f7
RR
55 void GTKSetDragContext( GdkDragContext *dc ) { m_dragContext = dc; }
56 void GTKSetDragWidget( GtkWidget *w ) { m_dragWidget = w; }
57 void GTKSetDragData( GtkSelectionData *sd ) { m_dragData = sd; }
29e461a2 58 void GTKSetDragTime(unsigned time) { m_dragTime = time; }
9e2896e5 59};
8e193f38 60
9e2896e5
VZ
61//-------------------------------------------------------------------------
62// wxDropSource
63//-------------------------------------------------------------------------
64
20123d49 65class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
9e2896e5
VZ
66{
67public:
2245b2b2 68 // constructor. set data later with SetData()
d3b9f782 69 wxDropSource( wxWindow *win = NULL,
f6bcfd97
BP
70 const wxIcon &copy = wxNullIcon,
71 const wxIcon &move = wxNullIcon,
72 const wxIcon &none = wxNullIcon);
8e193f38 73
2245b2b2 74 // constructor for setting one data object
9e2896e5
VZ
75 wxDropSource( wxDataObject& data,
76 wxWindow *win,
f6bcfd97
BP
77 const wxIcon &copy = wxNullIcon,
78 const wxIcon &move = wxNullIcon,
79 const wxIcon &none = wxNullIcon);
8e193f38 80
2245b2b2 81 virtual ~wxDropSource();
8e193f38 82
7bb22bd6
RD
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
2245b2b2
VZ
94 // start drag action
95 virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
8e193f38 96
f6bcfd97 97 void PrepareIcon( int action, GdkDragContext *context );
8ee9d618 98
7b5d5699
RR
99 GtkWidget *m_widget;
100 GtkWidget *m_iconWindow;
101 GdkDragContext *m_dragContext;
102 wxWindow *m_window;
8ee9d618 103
7b5d5699 104 wxDragResult m_retValue;
f6bcfd97
BP
105 wxIcon m_iconCopy,
106 m_iconMove,
107 m_iconNone;
8ee9d618 108
7b5d5699 109 bool m_waiting;
f6bcfd97
BP
110
111private:
112 // common part of both ctors
113 void SetIcons(const wxIcon& copy,
114 const wxIcon& move,
115 const wxIcon& none);
86f19f7c
VZ
116
117 // GTK implementation
118 void GTKConnectDragSignals();
119 void GTKDisconnectDragSignals();
120
c801d85f
KB
121};
122
0416c418 123#endif // _WX_GTK_DND_H_
c801d85f 124