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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
#include "tcl.h"
#include "tk.h"
#include <X11/Xlib.h>
#include <X11/X.h>
/*
* Define DND Cursors...
*/
/* No Drop Cursor... */
#define noDropCursorWidth 20
#define noDropCursorHeight 20
#define noDropCursorX 10
#define noDropCursorY 10
static unsigned char noDropCurBits[] = {
0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00};
static unsigned char noDropCurMask[] = {
0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
/* Copy Cursor... */
#define CopyCursorWidth 29
#define CopyCursorHeight 25
#define CopyCursorX 10
#define CopyCursorY 10
static unsigned char CopyCurBits[] =
{
0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x02, 0x00, 0x08, 0x01,
0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0xe8, 0x0f,
0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0x08, 0x01,
0x02, 0x00, 0x08, 0x00, 0x02, 0x04, 0x08, 0x00, 0x02, 0x0c, 0x08, 0x00,
0x02, 0x1c, 0x08, 0x00, 0x02, 0x3c, 0x08, 0x00, 0x02, 0x7c, 0x08, 0x00,
0x02, 0xfc, 0x08, 0x00, 0x02, 0xfc, 0x09, 0x00, 0x02, 0xfc, 0x0b, 0x00,
0x02, 0x7c, 0x08, 0x00, 0xfe, 0x6d, 0x0f, 0x00, 0x00, 0xc4, 0x00, 0x00,
0x00, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00};
static unsigned char CopyCurMask[] =
{
0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f,
0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f,
0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f,
0x07, 0x06, 0xfc, 0x1f, 0x07, 0x0e, 0xfc, 0x1f, 0x07, 0x1e, 0x1c, 0x00,
0x07, 0x3e, 0x1c, 0x00, 0x07, 0x7e, 0x1c, 0x00, 0x07, 0xfe, 0x1c, 0x00,
0x07, 0xfe, 0x1d, 0x00, 0x07, 0xfe, 0x1f, 0x00, 0x07, 0xfe, 0x1f, 0x00,
0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x1e, 0x00, 0xff, 0xef, 0x1f, 0x00,
0x00, 0xe6, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00,
0x00, 0x80, 0x01, 0x00};
/* Move Cursor... */
#define MoveCursorWidth 21
#define MoveCursorHeight 25
#define MoveCursorX 10
#define MoveCursorY 10
static unsigned char MoveCurBits[] =
{
0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x02, 0x00, 0x08, 0x02, 0x00, 0x08,
0x02, 0x00, 0x08, 0x02, 0x00, 0x08, 0x02, 0x00, 0x08, 0x02, 0x00, 0x08,
0x02, 0x00, 0x08, 0x02, 0x00, 0x08, 0x02, 0x04, 0x08, 0x02, 0x0c, 0x08,
0x02, 0x1c, 0x08, 0x02, 0x3c, 0x08, 0x02, 0x7c, 0x08, 0x02, 0xfc, 0x08,
0x02, 0xfc, 0x09, 0x02, 0xfc, 0x0b, 0x02, 0x7c, 0x08, 0xfe, 0x6d, 0x0f,
0x00, 0xc4, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01,
0x00, 0x00, 0x00};
static unsigned char MoveCurMask[] =
{
0xff, 0xff, 0x1f, 0xff, 0xff, 0x1f, 0xff, 0xff, 0x1f, 0x07, 0x00, 0x1c,
0x07, 0x00, 0x1c, 0x07, 0x00, 0x1c, 0x07, 0x00, 0x1c, 0x07, 0x00, 0x1c,
0x07, 0x00, 0x1c, 0x07, 0x06, 0x1c, 0x07, 0x0e, 0x1c, 0x07, 0x1e, 0x1c,
0x07, 0x3e, 0x1c, 0x07, 0x7e, 0x1c, 0x07, 0xfe, 0x1c, 0x07, 0xfe, 0x1d,
0x07, 0xfe, 0x1f, 0x07, 0xfe, 0x1f, 0xff, 0xff, 0x1f, 0xff, 0xff, 0x1e,
0xff, 0xef, 0x1f, 0x00, 0xe6, 0x01, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03,
0x00, 0x80, 0x01};
/* Link Cursor... */
#define LinkCursorWidth 29
#define LinkCursorHeight 25
#define LinkCursorX 10
#define LinkCursorY 10
static unsigned char LinkCurBits[] =
{
0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x02, 0x00, 0x08, 0x01,
0x02, 0x00, 0x88, 0x00, 0x02, 0x00, 0x48, 0x00, 0x02, 0x00, 0xe8, 0x0f,
0x02, 0x00, 0x48, 0x00, 0x02, 0x00, 0x88, 0x00, 0x02, 0x00, 0x08, 0x01,
0x02, 0x00, 0x08, 0x00, 0x02, 0x04, 0x08, 0x00, 0x02, 0x0c, 0x08, 0x00,
0x02, 0x1c, 0x08, 0x00, 0x02, 0x3c, 0x08, 0x00, 0x02, 0x7c, 0x08, 0x00,
0x02, 0xfc, 0x08, 0x00, 0x02, 0xfc, 0x09, 0x00, 0x02, 0xfc, 0x0b, 0x00,
0x02, 0x7c, 0x08, 0x00, 0xfe, 0x6d, 0x0f, 0x00, 0x00, 0xc4, 0x00, 0x00,
0x00, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00};
static unsigned char LinkCurMask[] =
{
0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f,
0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f,
0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f,
0x07, 0x06, 0xfc, 0x1f, 0x07, 0x0e, 0xfc, 0x1f, 0x07, 0x1e, 0x1c, 0x00,
0x07, 0x3e, 0x1c, 0x00, 0x07, 0x7e, 0x1c, 0x00, 0x07, 0xfe, 0x1c, 0x00,
0x07, 0xfe, 0x1d, 0x00, 0x07, 0xfe, 0x1f, 0x00, 0x07, 0xfe, 0x1f, 0x00,
0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x1e, 0x00, 0xff, 0xef, 0x1f, 0x00,
0x00, 0xe6, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00,
0x00, 0x80, 0x01, 0x00};
/* Ask Cursor... */
#define AskCursorWidth 29
#define AskCursorHeight 25
#define AskCursorX 10
#define AskCursorY 10
static unsigned char AskCurBits[] =
{
0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x02, 0x00, 0x88, 0x03,
0x02, 0x00, 0x48, 0x04, 0x02, 0x00, 0x08, 0x04, 0x02, 0x00, 0x08, 0x02,
0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0x08, 0x00,
0x02, 0x00, 0x08, 0x01, 0x02, 0x04, 0x08, 0x00, 0x02, 0x0c, 0x08, 0x00,
0x02, 0x1c, 0x08, 0x00, 0x02, 0x3c, 0x08, 0x00, 0x02, 0x7c, 0x08, 0x00,
0x02, 0xfc, 0x08, 0x00, 0x02, 0xfc, 0x09, 0x00, 0x02, 0xfc, 0x0b, 0x00,
0x02, 0x7c, 0x08, 0x00, 0xfe, 0x6d, 0x0f, 0x00, 0x00, 0xc4, 0x00, 0x00,
0x00, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00};
static unsigned char AskCurMask[] =
{
0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f,
0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f,
0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f,
0x07, 0x06, 0xfc, 0x1f, 0x07, 0x0e, 0xfc, 0x1f, 0x07, 0x1e, 0x1c, 0x00,
0x07, 0x3e, 0x1c, 0x00, 0x07, 0x7e, 0x1c, 0x00, 0x07, 0xfe, 0x1c, 0x00,
0x07, 0xfe, 0x1d, 0x00, 0x07, 0xfe, 0x1f, 0x00, 0x07, 0xfe, 0x1f, 0x00,
0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x1e, 0x00, 0xff, 0xef, 0x1f, 0x00,
0x00, 0xe6, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00,
0x00, 0x80, 0x01, 0x00};
static Cursor noDropCursor = 0,
moveCursor = 0,
copyCursor = 0,
linkCursor = 0,
askCursor = 0;
void TkDND_InitialiseCursors(Tcl_Interp *interp) {
XColor black, white;
Pixmap image_pixmap, mask_pixmap;
Tk_Window main_window;
Display *display;
Window RootWindow;
if (!interp) return;
main_window = Tk_MainWindow(interp);
Tk_MakeWindowExist(main_window);
display = Tk_Display(main_window);
RootWindow = DefaultRootWindow(display);
black.pixel = BlackPixel(display, DefaultScreen(display));
white.pixel = WhitePixel(display, DefaultScreen(display));
XQueryColor(display, DefaultColormap(display,
DefaultScreen(display)), &black);
XQueryColor(display, DefaultColormap(display,
DefaultScreen(display)), &white);
/* No Drop Cursor */
if (!noDropCursor) {
image_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) noDropCurBits, noDropCursorWidth, noDropCursorHeight);
mask_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) noDropCurMask, noDropCursorWidth, noDropCursorHeight);
noDropCursor = XCreatePixmapCursor (display, image_pixmap,
mask_pixmap, &black, &white, noDropCursorX, noDropCursorY);
XFreePixmap (display, image_pixmap);
XFreePixmap (display, mask_pixmap);
}
/* Copy Cursor */
if (!copyCursor) {
image_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) CopyCurBits, CopyCursorWidth, CopyCursorHeight);
mask_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) CopyCurMask, CopyCursorWidth, CopyCursorHeight);
copyCursor = XCreatePixmapCursor (display, image_pixmap,
mask_pixmap, &black, &white, CopyCursorX, CopyCursorY);
XFreePixmap (display, image_pixmap);
XFreePixmap (display, mask_pixmap);
}
/* Move Cursor */
if (!moveCursor) {
image_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) MoveCurBits, MoveCursorWidth, MoveCursorHeight);
mask_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) MoveCurMask, MoveCursorWidth, MoveCursorHeight);
moveCursor = XCreatePixmapCursor (display, image_pixmap,
mask_pixmap, &black, &white, MoveCursorX, MoveCursorY);
XFreePixmap (display, image_pixmap);
XFreePixmap (display, mask_pixmap);
}
/* Link Cursor */
if (!linkCursor) {
image_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) LinkCurBits, LinkCursorWidth, LinkCursorHeight);
mask_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) LinkCurMask, LinkCursorWidth, LinkCursorHeight);
linkCursor = XCreatePixmapCursor (display, image_pixmap,
mask_pixmap, &black, &white, LinkCursorX, LinkCursorY);
XFreePixmap (display, image_pixmap);
XFreePixmap (display, mask_pixmap);
}
/* Ask Cursor */
if (!askCursor) {
image_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) AskCurBits, AskCursorWidth, AskCursorHeight);
mask_pixmap = XCreateBitmapFromData(display, RootWindow,
(char *) AskCurMask, AskCursorWidth, AskCursorHeight);
askCursor = XCreatePixmapCursor (display, image_pixmap,
mask_pixmap, &black, &white, AskCursorX, AskCursorY);
XFreePixmap (display, image_pixmap);
XFreePixmap (display, mask_pixmap);
}
/* Register Cursors... */
}; /* TkDND_InitialiseCursors */
Tk_Cursor TkDND_GetCursor(Tcl_Interp *interp, Tcl_Obj *name) {
static char *DropActions[] = {
"copy", "move", "link", "ask", "private", "refuse_drop", "default",
(char *) NULL
};
enum dropactions {
ActionCopy, ActionMove, ActionLink, ActionAsk, ActionPrivate,
refuse_drop, ActionDefault
};
int status, index;
Tk_Cursor cursor;
status = Tcl_GetIndexFromObj(interp, name, (const char **) DropActions,
"dropactions", 0, &index);
if (status == TCL_OK) {
switch ((enum dropactions) index) {
case ActionDefault:
case ActionCopy: return (Tk_Cursor) copyCursor;
case ActionMove: return (Tk_Cursor) moveCursor;
case ActionLink: return (Tk_Cursor) linkCursor;
case ActionAsk: return (Tk_Cursor) askCursor;
case ActionPrivate: return (Tk_Cursor) askCursor;
case refuse_drop: return (Tk_Cursor) noDropCursor;
}
}
/* The name is not an action. Try Tk cursors... */
cursor = Tk_AllocCursorFromObj(interp, Tk_MainWindow(interp), name);
if (cursor == None) {
Tcl_SetResult(interp, "invalid cursor name", TCL_STATIC);
return (Tk_Cursor) None;
}
return cursor;
}; /* TkDND_GetCursor */
|