File: dnd.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (171 lines) | stat: -rw-r--r-- 4,782 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/motif/dnd.h
// Purpose:     declaration of wxDropTarget, wxDropSource classes
// Author:      Julian Smart
// Copyright:   (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_DND_H_
#define _WX_DND_H_

#include "wx/defs.h"

#if wxUSE_DRAG_AND_DROP

#include "wx/object.h"
#include "wx/string.h"
#include "wx/dataobj.h"
#include "wx/cursor.h"

//-------------------------------------------------------------------------
// classes
//-------------------------------------------------------------------------

class WXDLLIMPEXP_FWD_CORE wxWindow;

class WXDLLIMPEXP_FWD_CORE wxDropTarget;
class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
class WXDLLIMPEXP_FWD_CORE wxPrivateDropTarget;

class WXDLLIMPEXP_FWD_CORE wxDropSource;

//-------------------------------------------------------------------------
// wxDropTarget
//-------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxDropTarget: public wxObject
{
public:

    wxDropTarget();
    virtual ~wxDropTarget();

    virtual void OnEnter() { }
    virtual void OnLeave() { }
    virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;

    // Override these to indicate what kind of data you support:

    virtual size_t GetFormatCount() const = 0;
    virtual wxDataFormat GetFormat(size_t n) const = 0;

    // implementation
};

//-------------------------------------------------------------------------
// wxTextDropTarget
//-------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxTextDropTarget: public wxDropTarget
{
public:

    wxTextDropTarget() {}
    virtual bool OnDrop( long x, long y, const void *data, size_t size );
    virtual bool OnDropText( long x, long y, const char *psz );

protected:

    virtual size_t GetFormatCount() const;
    virtual wxDataFormat GetFormat(size_t n) const;
};

//-------------------------------------------------------------------------
// wxPrivateDropTarget
//-------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxPrivateDropTarget: public wxDropTarget
{
public:

    wxPrivateDropTarget();

    // you have to override OnDrop to get at the data

    // the string ID identifies the format of clipboard or DnD data. a word
    // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
    // to the clipboard - the latter with the Id "WXWORD_FORMAT".

    void SetId( const wxString& id )
    { m_id = id; }

    wxString GetId()
    { return m_id; }

private:

    virtual size_t GetFormatCount() const;
    virtual wxDataFormat GetFormat(size_t n) const;

    wxString   m_id;
};

// ----------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxFileDropTarget: public wxDropTarget
{
public:

    wxFileDropTarget() {}

    virtual bool OnDrop( long x, long y, const void *data, size_t size );
    virtual bool OnDropFiles( long x, long y,
        size_t nFiles, const char * const aszFiles[] );

protected:

    virtual size_t GetFormatCount() const;
    virtual wxDataFormat GetFormat(size_t n) const;
};

//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------

enum wxDragResult
{
    wxDragError,    // error prevented the d&d operation from completing
        wxDragNone,     // drag target didn't accept the data
        wxDragCopy,     // the data was successfully copied
        wxDragMove,     // the data was successfully moved
        wxDragCancel    // the operation was cancelled by user (not an error)
};

class WXDLLIMPEXP_CORE wxDropSource: public wxObject
{
public:

    wxDropSource( wxWindow *win );
    wxDropSource( wxDataObject &data, wxWindow *win );

    virtual ~wxDropSource(void);

    void SetData( wxDataObject &data  );
    wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);

    virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return true; }

    // implementation
#if 0
    void RegisterWindow(void);
    void UnregisterWindow(void);

    wxWindow      *m_window;
    wxDragResult   m_retValue;
    wxDataObject  *m_data;

    wxCursor      m_defaultCursor;
    wxCursor      m_goaheadCursor;
#endif
};

#endif

// wxUSE_DRAG_AND_DROP

#endif
//_WX_DND_H_