KWWidgets
Main Page
Classes
Files
File List
File Members
Utilities
tkdnd
win
OleDND.h
Go to the documentation of this file.
1
/*
2
* tkOleDND.cpp --
3
*
4
* This file implements the windows portion of the drag&drop mechanish
5
* for the tk toolkit. The protocol in use under windows is the
6
* OLE protocol. Based on code wrote by Gordon Chafee.
7
*
8
* This software is copyrighted by:
9
* George Petasis, National Centre for Scientific Research "Demokritos",
10
* Aghia Paraskevi, Athens, Greece.
11
* e-mail: petasis@iit.demokritos.gr
12
* Laurent Riesterer, Rennes, France.
13
* e-mail: laurent.riesterer@free.fr
14
*
15
* The following terms apply to all files associated
16
* with the software unless explicitly disclaimed in individual files.
17
*
18
* The authors hereby grant permission to use, copy, modify, distribute,
19
* and license this software and its documentation for any purpose, provided
20
* that existing copyright notices are retained in all copies and that this
21
* notice is included verbatim in any distributions. No written agreement,
22
* license, or royalty fee is required for any of the authorized uses.
23
* Modifications to this software may be copyrighted by their authors
24
* and need not follow the licensing terms described here, provided that
25
* the new terms are clearly indicated on the first page of each file where
26
* they apply.
27
*
28
* IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
29
* FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
30
* ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
31
* DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*
34
* THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
35
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
36
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
37
* IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
38
* NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
39
* MODIFICATIONS.
40
*/
41
42
#ifndef _OLE_DND_H
43
#define _OLE_DND_H
44
45
46
#include "vtkTcl.h"
47
#include "vtkTk.h"
48
49
#include <windows.h>
50
#include <ole2.h>
51
52
#ifdef DND_ENABLE_DROP_TARGET_HELPER
53
#include <atlbase.h>
54
#include <shlobj.h>
/* for IDropTargetHelper */
55
#include <shlguid.h>
56
/* We need this declaration for CComPtr, which uses __uuidof() */
57
struct
__declspec(uuid("{4657278B-411B-11d2-839A-00C04FD918D0}
"))
58
IDropTargetHelper;
59
#endif /* DND_ENABLE_DROP_TARGET_HELPER */
60
61
#include <tcl.h>
62
#include <tk.h>
63
#include "
tkDND.h
"
64
#include "
tkOleDND_TEnumFormatEtc.h
"
65
66
#ifdef DND_DEBUG
67
extern FILE *TkDND_Log;
68
#endif
69
70
typedef struct _OLEDND_Struct {
71
Tk_Window MainWindow; /* The main window of our application */
72
Tcl_Interp *interp; /* A Tcl Interpreter */
73
Display *display; /* Display Pointer */
74
int x; /* Current position of the mouse */
75
int y; /* Current position of the mouse */
76
int button; /* Current button used for drag operation */
77
Tk_Window CursorWindow; /* A window to replace cursor */
78
char * CursorCallback; /* A Callback to update cursor window */
79
80
Tk_Window DraggerWindow; /* Window of the drag source */
81
DWORD DraggerActions; /* Actions supported by the drag source */
82
Tcl_DString DraggerTypes; /* The list of types of the drag source */
83
CLIPFORMAT DesiredType; /* The drop desired type */
84
char *DesiredTypeStr; /* The drop desired type (string) */
85
char DesiredAction[10]; /* The drop desired action */
86
int CallbackStatus; /* The return value of last tcl callback */
87
Tcl_Obj *data; /* The object contained data to be dropped */
88
int length; /* length of the data */
89
90
/* Some useful CLIPFORMATS... */
91
CLIPFORMAT UniformResourceLocator; /* Netscape, IE */
92
CLIPFORMAT FileName; /* Windows Explorer */
93
CLIPFORMAT HTML_Format; /* Word, IE */
94
CLIPFORMAT RichTextFormat; /* Word, IE */
95
CLIPFORMAT FileGroupDescriptor; /* Explorer, files not in the file */
96
CLIPFORMAT FileGroupDescriptorW; /* system */
97
} OleDND;
98
#define DndClass OleDND
99
100
/*****************************************************************************
101
* Drop Source Related Class.
102
****************************************************************************/
103
class TkDND_DropSource: public IDropSource {
104
private:
105
ULONG m_refCnt; /* Reference count */
106
DndInfo *infoPtr; /* Pointer to hash table entry */
107
108
public:
109
TkDND_DropSource(DndInfo *infoPtr);
110
~TkDND_DropSource(void);
111
112
/* IUnknown interface members */
113
STDMETHODIMP QueryInterface(REFIID, LPVOID *);
114
STDMETHODIMP_(ULONG) AddRef(void);
115
STDMETHODIMP_(ULONG) Release(void);
116
117
/* IDropSource interface members */
118
STDMETHODIMP QueryContinueDrag(BOOL, DWORD);
119
STDMETHODIMP GiveFeedback(DWORD);
120
}; /* TkDND_DropSource */
121
122
/*****************************************************************************
123
* Data object Related Class (needed by Drag Source for OLE DND)...
124
****************************************************************************/
125
class TkDND_DataObject: public IDataObject {
126
private:
127
ULONG m_refCnt; /* Reference Count */
128
DndInfo *infoPtr; /* Pointer to hash table entry */
129
130
/* The clipboard formats that can be handled */
131
UINT m_numTypes; /* Number of types in list */
132
UINT m_maxTypes; /* Number of types that fit */
133
FORMATETC *m_typeList; /* List of types */
134
135
public:
136
TkDND_DataObject(DndInfo *infoPtr);
137
~TkDND_DataObject(void);
138
139
/* IUnknown interface members */
140
STDMETHODIMP QueryInterface(REFIID, LPVOID *);
141
STDMETHODIMP_(ULONG) AddRef(void);
142
STDMETHODIMP_(ULONG) Release(void);
143
144
/* IDataObject interface methods */
145
STDMETHODIMP GetData(LPFORMATETC, LPSTGMEDIUM);
146
STDMETHODIMP GetDataHere(LPFORMATETC, LPSTGMEDIUM);
147
STDMETHODIMP QueryGetData(LPFORMATETC);
148
STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC);
149
STDMETHODIMP SetData(LPFORMATETC, LPSTGMEDIUM, BOOL);
150
STDMETHODIMP EnumFormatEtc(DWORD, LPENUMFORMATETC *);
151
STDMETHODIMP DAdvise(LPFORMATETC, DWORD, LPADVISESINK, DWORD *);
152
STDMETHODIMP DUnadvise(DWORD);
153
STDMETHODIMP EnumDAdvise(IEnumSTATDATA **);
154
155
/* TkDND additional interface methods */
156
int AddDataType(UINT clipFormat);
157
int DelDataType(UINT clipFormat);
158
}; /* TkDND_DataObject */
159
160
/*****************************************************************************
161
* Drop Target Related Class.
162
****************************************************************************/
163
class TkDND_DropTarget;
164
typedef class TkDND_DropTarget *PTDropTarget;
165
class TkDND_DropTarget: public IDropTarget {
166
private:
167
ULONG m_refCnt; /* Reference count */
168
DndInfo *infoPtr; /* Pointer to hash table entry */
169
DWORD KeyState; /* Remember KeyState for <DragLeave> */
170
LPDATAOBJECT DataObject; /* Keep data object available */
171
#ifdef DND_ENABLE_DROP_TARGET_HELPER
172
CComPtr<IDropTargetHelper> DropHelper; /* IDropTargetHelper support. This
173
helper does some interesting
174
things, like drawing explorer
175
icons during drops... */
176
int UseDropHelper; /* A flag whether to use the helper
177
or not... */
178
#endif /* DND_ENABLE_DROP_TARGET_HELPER */
179
180
public:
181
TkDND_DropTarget(DndInfo *info);
182
~TkDND_DropTarget(void);
183
184
/* IUnknown interface members */
185
STDMETHODIMP QueryInterface(REFIID, LPVOID *);
186
STDMETHODIMP_(ULONG) AddRef(void);
187
STDMETHODIMP_(ULONG) Release(void);
188
189
/* IDropTarget interface members */
190
STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL,LPDWORD);
191
STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
192
STDMETHODIMP DragLeave(void);
193
STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
194
195
/* TkDND additional interface methods */
196
DWORD ParseAction(void);
197
Tcl_Obj *GetAndConvertData(LPDATAOBJECT,
198
DndType *, char *, FORMATETC *, STGMEDIUM *);
199
}; /* TkDND_DropTarget */
200
201
#endif _OLE_DND_H
Generated on Thu Apr 18 2013 08:50:49 for KWWidgets by
1.8.1.2