00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef _X_DND_H
00043 #define _X_DND_H
00044 #include "vtkTcl.h"
00045 #include "vtkTk.h"
00046 #include <tcl.h>
00047 #include <tk.h>
00048 #include "tkDND.h"
00049
00050 #ifdef TKDND_ENABLE_MOTIF_DRAGS
00051 #ifndef TKDND_ENABLE_MOTIF_DROPS
00052 #define TKDND_ENABLE_MOTIF_DROPS
00053 #endif
00054 #endif
00055
00056
00057
00058
00059 #ifdef TKDND_ENABLE_MOTIF_DROPS
00060 #include "Dnd.h"
00061 #endif
00062
00063 #define XDND_VERSION 3
00064 #define XDND_MINVERSION 3
00065 #define XDND_ENTERTYPECOUNT 3
00066 #define XDND_BOOL short
00067
00068 #define XDND_NODROP_CURSOR 0
00069 #define XDND_COPY_CURSOR 1
00070 #define XDND_MOVE_CURSOR 2
00071 #define XDND_LINK_CURSOR 3
00072 #define XDND_ASK_CURSOR 4
00073 #define XDND_PRIVATE_CURSOR 5
00074
00075
00076
00077
00078 #ifndef XDND_DEBUG
00079 #ifdef DND_DEBUG
00080 #include <stdio.h>
00081 #define XDND_DEBUG(a) \
00082 printf("%s, %d: " a,__FILE__,__LINE__); fflush(stdout)
00083 #define XDND_DEBUG2(a,b) \
00084 printf("%s, %d: " a,__FILE__,__LINE__,b); fflush(stdout)
00085 #define XDND_DEBUG3(a,b,c) \
00086 printf("%s, %d: " a,__FILE__,__LINE__,b,c); fflush(stdout)
00087 #define XDND_DEBUG4(a,b,c,d) \
00088 printf("%s, %d: " a,__FILE__,__LINE__,b,c,d); fflush(stdout)
00089 #define XDND_DEBUG5(a,b,c,d,e) \
00090 printf("%s, %d: " a,__FILE__,__LINE__,b,c,d,e); fflush(stdout)
00091 #else
00092 #define XDND_DEBUG(a)
00093 #define XDND_DEBUG2(a,b)
00094 #define XDND_DEBUG3(a,b,c)
00095 #define XDND_DEBUG4(a,b,c,d)
00096 #define XDND_DEBUG5(a,b,c,d,e)
00097 #endif
00098 #endif
00099
00100 #ifdef __cplusplus
00101 extern "C" {
00102 #endif
00103
00104 #ifndef LONG_MAX
00105 #define LONG_MAX 0x8000000L
00106 #endif
00107
00108 #define Min(x,y) (x<y?x:y)
00109 #define XDND_Sqrt(x) ((x)*(x))
00110 #ifndef False
00111 #define False 0
00112 #endif
00113 #ifndef True
00114 #define True 1
00115 #endif
00116
00117 typedef struct _XDND_Cursor {
00118 int width, height;
00119 int x, y;
00120 unsigned char *image_data, *mask_data;
00121 char *_action;
00122 Pixmap image_pixmap, mask_pixmap;
00123 Cursor cursor;
00124 Atom action;
00125 } XDNDCursor;
00126
00127 typedef struct _XDND_Struct {
00128 Tk_Window MainWindow;
00129 Tcl_Interp *interp;
00130 Display *display;
00131 Window RootWindow;
00132 Atom XDNDVersion;
00133 int x;
00134 int y;
00135 int button;
00136 unsigned int state;
00137 int CallbackStatus;
00138 XDND_BOOL ResetValues;
00139
00140
00141 XDND_BOOL InternalDrag;
00142 XDND_BOOL ReceivedStatusFlag;
00143
00144 char *data;
00145 int index;
00146
00147
00148 Window DraggerWindow;
00149 Atom *DraggerTypeList;
00150 Atom *DraggerAskActionList;
00151 char *DraggerAskDescriptions;
00152 Tk_Window CursorWindow;
00153 char *CursorCallback;
00154 XDND_BOOL WaitForStatusFlag;
00155
00156
00157 Window Toplevel;
00158 Window MouseWindow;
00159 XDND_BOOL MouseWindowIsAware;
00160 Window MsgWindow;
00161
00162 Atom DesiredType;
00163 #ifdef XDND_USE_TK_GET_SELECTION
00164 char *DesiredName;
00165 #endif
00166 Atom SupportedAction;
00167
00168 XDND_BOOL WillAcceptDropFlag;
00169 Time LastEventTime;
00170
00171 XDND_BOOL IsDraggingFlag;
00172 XDND_BOOL UseMouseRectFlag;
00173 XRectangle MouseRectR;
00174
00175 XDNDCursor *cursors;
00176
00177
00178
00179
00180 #ifdef TKDND_ENABLE_MOTIF_DROPS
00181 DndData Motif_DND_Data;
00182 int Motif_DND;
00183 Atom Motif_DND_SuccessAtom;
00184 Atom Motif_DND_FailureAtom;
00185 #endif
00186 #ifdef TKDND_ENABLE_MOTIF_DRAGS
00187 Window Motif_LastToplevel;
00188 int Motif_ToplevelAware;
00189 Atom Motif_DND_Selection;
00190 Atom Motif_DND_WM_STATE;
00191 #endif
00192
00193
00194
00195
00196
00197
00198
00199 Window LastEnterDeliveredWindow;
00200 unsigned int
00201 Alt_ModifierMask;
00202 unsigned int
00203 Meta_ModifierMask;
00204
00205
00206 Atom DNDSelectionName;
00207
00208 Atom DNDProxyXAtom;
00209 Atom DNDAwareXAtom;
00210 Atom DNDTypeListXAtom;
00211
00212 Atom DNDEnterXAtom;
00213 Atom DNDHereXAtom;
00214 Atom DNDStatusXAtom;
00215 Atom DNDLeaveXAtom;
00216 Atom DNDDropXAtom;
00217 Atom DNDFinishedXAtom;
00218
00219 Atom DNDActionCopyXAtom;
00220 Atom DNDActionMoveXAtom;
00221 Atom DNDActionLinkXAtom;
00222 Atom DNDActionAskXAtom;
00223 Atom DNDActionPrivateXAtom;
00224
00225 Atom DNDActionListXAtom;
00226 Atom DNDActionDescriptionXAtom;
00227
00228 Atom DNDDirectSave0XAtom;
00229
00230 Atom DNDMimePlainTextXAtom;
00231 Atom DNDStringAtom;
00232 Atom DNDNonProtocolAtom;
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 int (*WidgetExistsCallback) (struct _XDND_Struct *dnd, Window window);
00246
00247
00248
00249
00250
00251 int (*WidgetApplyEnterCallback) (struct _XDND_Struct *dnd,
00252 Window target, Window source, Atom action, int x, int y,
00253 Time t, Atom *typelist);
00254
00255
00256
00257
00258
00259
00260
00261
00262 int (*WidgetApplyPositionCallback) (struct _XDND_Struct *dnd,
00263 Window target, Window source, Atom action, Atom *actionList,
00264 int x, int y, Time t, Atom *typelist, int *wantPosition,
00265 Atom *supported_action, Atom *desired_type, XRectangle *rectangle);
00266
00267
00268
00269
00270 int (*WidgetApplyLeaveCallback) (struct _XDND_Struct *dnd, Window target);
00271
00272 int (*WidgetInsertDropDataCallback) (struct _XDND_Struct *dnd,
00273 unsigned char *data, int length, int remaining,
00274 Window into, Window from, Atom type);
00275
00276
00277 int (*Ask) (struct _XDND_Struct *dnd, Window source, Window target,
00278 Atom *action);
00279
00280
00281 int (*GetData) (struct _XDND_Struct *dnd, Window source,
00282 unsigned char **data, int *length, Atom type);
00283
00284
00285 void (*HandleEvents) (struct _XDND_Struct *dnd, XEvent *xevent);
00286
00287
00288
00289
00290 Atom *(*GetDragAtoms) (struct _XDND_Struct *dnd, Window window);
00291
00292
00293
00294
00295
00296 int (*SetCursor) (struct _XDND_Struct *dnd, int cursor);
00297 } XDND;
00298 #define DndClass XDND
00299 extern Cursor noDropCursor, moveCursor, copyCursor, linkCursor, askCursor;
00300
00301
00302
00303
00304
00305 void XDND_Reset(XDND *dndp);
00306 XDND *XDND_Init(Display *display);
00307 void XDND_Enable(XDND *dnd, Window window);
00308 XDND_BOOL XDND_IsDndAware(XDND *dnd, Window window, Window* proxy, Atom *vers);
00309 int XDND_AtomListLength(Atom *list);
00310 int XDND_DescriptionListLength(char *list);
00311 Atom *XDND_GetTypeList(XDND *dnd, Window window);
00312 void XDND_AnnounceTypeList(XDND *dnd, Window window, Atom *list);
00313 void XDND_AppendType(XDND *dnd, Window window, Atom type);
00314 void XDND_AnnounceAskActions(XDND *dnd, Window window, Atom *Actions,
00315 char *Descriptions);
00316 Atom *XDND_GetAskActions(XDND *dnd, Window window);
00317 char *XDND_GetAskActionDescriptions(XDND *dnd, Window window);
00318 XDND_BOOL XDND_DraggerCanProvideText(XDND *dnd);
00319 XDND_BOOL XDND_FindTarget(XDND *dnd, int x, int y,
00320 Window *toplevel, Window *msgWindow,
00321 Window *target, XDND_BOOL *aware, Atom *version);
00322 Window XDND_FindToplevel(XDND *dnd, Window window);
00323
00324 XDND_BOOL XDND_BeginDrag(XDND *dnd, Window source, Atom *actions, Atom *types,
00325 char *Descriptions, Tk_Window cursor_window,
00326 char *cursor_callback);
00327
00328 void XDND_SendDNDEnter(XDND *dnd, Window window, Window msgWindow,
00329 XDND_BOOL isAware, Atom vers);
00330 XDND_BOOL XDND_SendDNDPosition(XDND *dnd, Atom action);
00331 XDND_BOOL XDND_SendDNDStatus(XDND *dnd, Atom action);
00332 XDND_BOOL XDND_SendDNDLeave(XDND *dnd);
00333 XDND_BOOL XDND_SendDNDDrop(XDND *dnd);
00334 XDND_BOOL XDND_SendDNDSelection(XDND *dnd, XSelectionRequestEvent *request);
00335
00336 int XDND_HandleClientMessage(XDND *dnd, XEvent *xevent);
00337 int XDND_HandleDNDEnter(XDND *dnd, XClientMessageEvent clientMessage);
00338 int XDND_HandleDNDHere(XDND *dnd, XClientMessageEvent clientMessage);
00339 int XDND_HandleDNDLeave(XDND *dnd, XClientMessageEvent clientMessage);
00340 int XDND_HandleDNDDrop(XDND *dnd, XClientMessageEvent clientMessage);
00341 int XDND_GetSelProc(ClientData clientData, Tcl_Interp *interp, char *portion);
00342
00343 int XDND_HandleDNDStatus(XDND *dnd, XClientMessageEvent clientMessage);
00344
00345 #ifdef TKDND_ENABLE_MOTIF_DROPS
00346 int MotifDND_HandleClientMessage(XDND *dnd, XEvent xevent);
00347 #endif
00348 #ifdef __cplusplus
00349 }
00350 #endif
00351
00352 #endif