KWWidgets
tkDND.h
Go to the documentation of this file.
1 /*
2  * tkDND.h --
3  *
4  * Header files for the drag&drop tk extension.
5  *
6  * This software is copyrighted by:
7  * George Petasis,
8  * Software and Knowledge Engineering Laboratory,
9  * Institute of Informatics and Telecommunications,
10  * National Centre for Scientific Research "Demokritos",
11  * Aghia Paraskevi, Athens, Greece.
12  * e-mail: petasis@iit.demokritos.gr
13  * and
14  * Laurent Riesterer, Rennes, France.
15  * e-mail: laurent.riesterer@free.fr
16  *
17  * The following terms apply to all files associated
18  * with the software unless explicitly disclaimed in individual files.
19  *
20  * The authors hereby grant permission to use, copy, modify, distribute,
21  * and license this software and its documentation for any purpose, provided
22  * that existing copyright notices are retained in all copies and that this
23  * notice is included verbatim in any distributions. No written agreement,
24  * license, or royalty fee is required for any of the authorized uses.
25  * Modifications to this software may be copyrighted by their authors
26  * and need not follow the licensing terms described here, provided that
27  * the new terms are clearly indicated on the first page of each file where
28  * they apply.
29  *
30  * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
31  * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
32  * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
33  * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
37  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
38  * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
39  * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
40  * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
41  * MODIFICATIONS.
42  */
43 
44 #ifndef _TKDND
45 #define _TKDND
46 
47 #include "vtkTcl.h"
48 #include "vtkTk.h"
49 
50 #include <string.h>
51 #include <tk.h>
52 
53 /*
54  * If we aren't in 8.4, don't use 8.4 constness
55  */
56 #ifndef CONST84
57 #define CONST84
58 #endif
59 
60 #if (TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))
61 # define HAVE_TCL84
62 #endif
63 #if (TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5))
64 # define HAVE_TCL85
65 #endif
66 
67 /*
68  * If "VERSION" is not defined, place a default value...
69  */
70 #ifndef VERSION
71 #ifdef PACKAGE_VERSION
72 #define VERSION PACKAGE_VERSION
73 #else
74 #define VERSION "1.0"
75 #endif
76 #endif
77 
78 #ifdef __WIN32__
79 # include <windows.h>
80 # include <ole2.h>
81 # include <tkPlatDecls.h>
82 
83 # ifndef Tk_GetHWND
84  EXTERN HWND Tk_GetHWND(Window win);
85 # endif /* Tk_GetHWND */
86 #endif /* __WIN32__ */
87 
88 /*
89  * These are passed to Tcl_PkgProvide...
90  */
91 #define TKDND_PACKAGE "tkdnd"
92 #define TKDND_VERSION VERSION
93 
94 /*
95  * Maximum length of the action descriptions list...
96  */
97 #define TKDND_MAX_DESCRIPTIONS_LENGTH 1034
98 #define TKDND_MAX_DESCRIPTIONS_LENGTH_STR "1024"
99 
100 /*
101  * These are used for selecting the most specific events.
102  * (Laurent please add description :-)
103  */
104 #define TKDND_SOURCE 0
105 #define TKDND_GETDATA 1
106 #define TKDND_GETCURSOR 2
107 #define TKDND_TARGET 10
108 #define TKDND_DRAGENTER 11
109 #define TKDND_DRAGLEAVE 12
110 #define TKDND_DRAG 13
111 #define TKDND_DROP 14
112 #define TKDND_ASK 15
113 
114 /* TODO: remove
115 #define TKDND_MODS 0x000000FF
116 #define TKDND_BUTTONS 0x00001F00
117 */
118 
119 /*
120  * Debug Facilities...
121  */
122 #ifdef DND_DEBUG
123 #include <stdio.h>
124 #ifdef __WIN32__
125 /*
126  * Under Windows, we keep a log in a file. (Laurent, 09/07/2000)
127  */
128 extern FILE *TkDND_Log;
129 #define XDND_DEBUG(a) \
130  fprintf(TkDND_Log, "%s, %d: " a,__FILE__,__LINE__); fflush(TkDND_Log)
131 #define XDND_DEBUG2(a,b) \
132  fprintf(TkDND_Log, "%s, %d: " a,__FILE__,__LINE__,b); fflush(TkDND_Log)
133 #define XDND_DEBUG3(a,b,c) \
134  fprintf(TkDND_Log, "%s, %d: " a,__FILE__,__LINE__,b,c); fflush(TkDND_Log)
135 #define XDND_DEBUG4(a,b,c,d) \
136  fprintf(TkDND_Log, "%s, %d: " a,__FILE__,__LINE__,b,c,d); fflush(TkDND_Log)
137 #define XDND_DEBUG5(a,b,c,d,e) \
138  fprintf(TkDND_Log, "%s, %d: " a,__FILE__,__LINE__,b,c,d,e); fflush(TkDND_Log)
139 #define XDND_DEBUG6(a,b,c,d,e,f) \
140  fprintf(TkDND_Log, "%s, %d: " a,__FILE__,__LINE__,b,c,d,e,f);fflush(TkDND_Log)
141 #else /* __WIN32__ */
142 /*
143  * Under Unix, we just write messages to stdout...
144  */
145 #define XDND_DEBUG(a) \
146  printf("%s, %d: " a,__FILE__,__LINE__); fflush(stdout)
147 #define XDND_DEBUG2(a,b) \
148  printf("%s, %d: " a,__FILE__,__LINE__,b); fflush(stdout)
149 #define XDND_DEBUG3(a,b,c) \
150  printf("%s, %d: " a,__FILE__,__LINE__,b,c); fflush(stdout)
151 #define XDND_DEBUG4(a,b,c,d) \
152  printf("%s, %d: " a,__FILE__,__LINE__,b,c,d); fflush(stdout)
153 #define XDND_DEBUG5(a,b,c,d,e) \
154  printf("%s, %d: " a,__FILE__,__LINE__,b,c,d,e); fflush(stdout)
155 #define XDND_DEBUG6(a,b,c,d,e,f) \
156  printf("%s, %d: " a,__FILE__,__LINE__,b,c,d,e,f); fflush(stdout)
157 #endif /* __WIN32__ */
158 #else /* DND_DEBUG */
159 /*
160  * Debug is not enabled. Just do nothing :-)
161  */
162 #define XDND_DEBUG(a)
163 #define XDND_DEBUG2(a,b)
164 #define XDND_DEBUG3(a,b,c)
165 #define XDND_DEBUG4(a,b,c,d)
166 #define XDND_DEBUG5(a,b,c,d,e)
167 #endif /* DND_DEBUG */
168 
169 typedef struct _DndType {
170  int priority; /* For target types, check priorities */
171 #ifdef __WIN32__
172  CLIPFORMAT type; /* Clipboard format (Windows)*/
173  CLIPFORMAT matchedType; /* Clipboard format (Windows)*/
174 #else /* __WIN32__ */
175  Atom type; /* Clipboard format (Unix)*/
176  Atom matchedType; /* Clipboard format (Unix)*/
177 #endif /* __WIN32__ */
178  char *typeStr; /* Name of type */
179  unsigned long eventType; /* Type of event */
180  unsigned long eventMask; /* Modifiers of event */
181  char *script; /* Script to run */
182  struct _DndType *next; /* Next one in list */
183  short EnterEventSent; /* Have we send an <DragEnter> event? */
184 } DndType;
185 
186 typedef struct _DndInfo {
187  Tcl_Interp *interp; /* The associated interp */
188  Tk_Window topwin; /* The main Tk window */
189  Tk_Window tkwin; /* The associated Tk window */
190  DndType head; /* Head of the list of supported types */
191 #ifdef __WIN32__
192  LPDROPTARGET DropTarget; /* The OLE IDropTarget object */
193 #endif /* __WIN32__ */
195  Tcl_HashEntry *hashEntry; /* Hash table entry */
196 } DndInfo;
197 
198 typedef struct _DndClass {
199  Tk_Window MainWindow; /* The main window of our application */
200  Tcl_Interp *interp; /* A Tcl Interpreter */
201  Display *display; /* Display Pointer */
202 } DndClass;
203 
204 #ifndef LONG
205 #define LONG long
206 #endif /* LONG */
207 
208 #ifdef MAC_TCL
209 /*
210  * Anybody ?
211  */
212 #endif /* MAC_TCL */
213 
214 #endif /* _TKDND */