1 /**
2 *
3 * $Id: DragIcon.c,v 1.1 2004/08/28 19:22:43 dannybackx Exp $
4 *
5 * Copyright (C) 1995 Free Software Foundation, Inc.
6 * Copyright (C) 1995-2001 LessTif Development Team
7 *
8 * This file is part of the GNU LessTif Library.
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
19 *
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the Free
22 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 **/
25
26 static const char rcsid[] = "$Id: DragIcon.c,v 1.1 2004/08/28 19:22:43 dannybackx Exp $";
27
28 #include <LTconfig.h>
29
30 #include <XmI/XmI.h>
31 #include <Xm/XmP.h>
32 #include <Xm/DragDrop.h>
33 #include <Xm/DragIconP.h>
34 #include <Xm/ScreenP.h>
35
36 #include <XmI/DebugUtil.h>
37
38 static void class_initialize(void);
39
40 static void class_part_initialize(WidgetClass w_class);
41
42 static void initialize(Widget request, Widget new_w,
43 ArgList args, Cardinal *num_args);
44
45 static void destroy(Widget w);
46
47 static Boolean set_values(Widget current, Widget request, Widget new_w,
48 ArgList args, Cardinal *num_args);
49
50
51 /*
52 * Resources for the DragIcon class
53 */
54 #define Offset(field) XtOffsetOf(XmDragIconRec, drag.field)
55 static XtResource resources[] =
56 {
57 {
58 XmNdepth, XmCDepth, XmRInt,
59 sizeof(Cardinal), Offset(depth),
60 XmRImmediate, (XtPointer)1
61 },
62 {
63 XmNwidth, XmCWidth, XmRDimension,
64 sizeof(Dimension), Offset(width),
65 XmRImmediate, (XtPointer)0
66 },
67 {
68 XmNheight, XmCHeight, XmRDimension,
69 sizeof(Dimension), Offset(height),
70 XmRImmediate, (XtPointer)0
71 },
72 {
73 XmNhotX, XmCHot, XmRPosition,
74 sizeof(Position), Offset(hot_x),
75 XmRImmediate, (XtPointer)0
76 },
77 {
78 XmNhotY, XmCHot, XmRPosition,
79 sizeof(Position), Offset(hot_y),
80 XmRImmediate, (XtPointer)0
81 },
82 {
83 XmNmask, XmCPixmap, XmRBitmap,
84 sizeof(Pixmap), Offset(mask),
85 XmRImmediate, (XtPointer)XmUNSPECIFIED_PIXMAP
86 },
87 {
88 XmNpixmap, XmCPixmap, XmRBitmap,
89 sizeof(Pixmap), Offset(pixmap),
90 XmRImmediate, (XtPointer)XmUNSPECIFIED_PIXMAP
91 },
92 {
93 XmNoffsetX, XmCOffset, XmRPosition,
94 sizeof(Position), Offset(offset_x),
95 XmRImmediate, (XtPointer)0
96 },
97 {
98 XmNoffsetY, XmCOffset, XmRPosition,
99 sizeof(Position), Offset(offset_y),
100 XmRImmediate, (XtPointer)0
101 },
102 {
103 XmNattachment, XmCAttachment, XmRIconAttachment,
104 sizeof(unsigned char), Offset(attachment),
105 XmRImmediate, (XtPointer)XmATTACH_NORTH_WEST
106 }
107 };
108 /* *INDENT-OFF* */
109 static XmBaseClassExtRec _XmDragIconRectClassExtRec = {
110 /* next_extension */ NULL,
111 /* record_type */ NULLQUARK,
112 /* version */ XmBaseClassExtVersion,
113 /* size */ sizeof(XmBaseClassExtRec),
114 /* initialize_prehook */ NULL,
115 /* set_values_prehook */ NULL,
116 /* initialize_posthook */ NULL,
117 /* set_values_posthook */ NULL,
118 /* secondary_object_class */ NULL,
119 /* secondary_object_create */ NULL,
120 /* get_secondary_resources */ NULL,
121 /* fast_subclass */ { 0 },
122 /* get_values_prehook */ NULL,
123 /* get_values_posthook */ NULL,
124 /* class_part_init_prehook */ NULL,
125 /* class_part_init_posthook */ NULL,
126 /* ext_resources */ NULL,
127 /* compiled_ext_resources */ NULL,
128 /* num_ext_resources */ 0,
129 /* use_sub_resources */ False,
130 /* widget_navigable */ NULL,
131 /* focus_change */ NULL,
132 /* wrapper_data */ NULL
133 };
134
135 XmDragIconClassRec xmDragIconClassRec = {
136 /* RectObj class part */
137 {
138 /* superclass */ (WidgetClass)&objectClassRec,
139 /* class_name */ "XmDragIcon",
140 /* widget_size */ sizeof(XmDragIconRec),
141 /* class_initialize */ class_initialize,
142 /* class_part_initialize */ class_part_initialize,
143 /* class_inited */ False,
144 /* initialize */ initialize,
145 /* initialize_hook */ NULL,
146 /* rect1 */ NULL,
147 /* rect2 */ NULL,
148 /* rect3 */ 0,
149 /* resources */ resources,
150 /* num_resources */ XtNumber(resources),
151 /* xrm_class */ NULLQUARK,
152 /* rect4 */ 0,
153 /* rect5 */ 0,
154 /* rect6 */ 0,
155 /* rect7 */ 0,
156 /* destroy */ destroy,
157 /* resize */ NULL,
158 /* expose */ NULL,
159 /* set_values */ set_values,
160 /* set_values_hook */ NULL,
161 /* set_values_almost */ XtInheritSetValuesAlmost,
162 /* get_values_hook */ NULL,
163 /* rect9 */ NULL,
164 /* version */ XtVersion,
165 /* callback offsets */ NULL,
166 /* rect10 */ NULL,
167 /* query_geometry */ NULL,
168 /* rect11 */ NULL,
169 /* extension */ NULL
170 },
171 /* XmDragIcon part */
172 {
173 /* extension */ NULL
174 }
175 };
176 /* *INDENT-ON* */
177
178
179 WidgetClass xmDragIconObjectClass = (WidgetClass)&xmDragIconClassRec;
180
181 #define state16_width 16
182 #define state16_height 16
183 static unsigned char state16_bits[] =
184 {
185 0x00, 0x00, 0x3e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x02, 0x00,
186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
188
189 #define state16_mask_width 16
190 #define state16_mask_height 16
191 static unsigned char state16_mask_bits[] =
192 {
193 0x7f, 0x00, 0x7f, 0x00, 0x7f, 0x00, 0x3f, 0x00, 0x1f, 0x00, 0x0f, 0x00,
194 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
196
197 #define move16_width 16
198 #define move16_height 16
199 static unsigned char move16_bits[] =
200 {
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0x40, 0x0c,
202 0x40, 0x1c, 0x40, 0x3c, 0x40, 0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x20,
203 0x40, 0x20, 0x40, 0x20, 0xc0, 0x3f, 0x00, 0x00};
204
205 #define move16_mask_width 16
206 #define move16_mask_height 16
207 static unsigned char move16_mask_bits[] =
208 {
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0xe0, 0x1f, 0xe0, 0x3f,
210 0xe0, 0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xe0, 0x7f,
211 0xe0, 0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xe0, 0x7f};
212
213 #define copy16_width 16
214 #define copy16_height 16
215 static unsigned char copy16_bits[] =
216 {
217 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x80, 0x18, 0x80, 0x38, 0xb0, 0x78,
218 0x90, 0x40, 0x90, 0x40, 0x90, 0x40, 0x90, 0x40, 0x90, 0x40, 0x90, 0x7f,
219 0x10, 0x00, 0x10, 0x08, 0xf0, 0x0f, 0x00, 0x00};
220
221 #define copy16_mask_width 16
222 #define copy16_mask_height 16
223 static unsigned char copy16_mask_bits[] =
224 {
225 0x00, 0x00, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0, 0x7f, 0xf8, 0xff, 0xf8, 0xff,
226 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff,
227 0xf8, 0xff, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f};
228
229 #define link16_width 16
230 #define link16_height 16
231 static unsigned char link16_bits[] =
232 {
233 0x00, 0x00, 0x80, 0x0f, 0x80, 0x18, 0x80, 0x38, 0x80, 0x78, 0xb8, 0x40,
234 0x88, 0x4e, 0x88, 0x4c, 0x08, 0x4a, 0x08, 0x41, 0xa8, 0x7c, 0x68, 0x00,
235 0xe8, 0x04, 0x08, 0x04, 0xf8, 0x07, 0x00, 0x00};
236
237 #define link16_mask_width 16
238 #define link16_mask_height 16
239 static unsigned char link16_mask_bits[] =
240 {
241 0xc0, 0x1f, 0xc0, 0x3f, 0xc0, 0x7f, 0xc0, 0xff, 0xfc, 0xff, 0xfc, 0xff,
242 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff,
243 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f};
244
245 #define source16_width 16
246 #define source16_height 16
247 static unsigned char source16_bits[] =
248 {
249 0x00, 0x00, 0xaa, 0xca, 0x54, 0x85, 0xaa, 0xca, 0x54, 0xe0, 0x2a, 0xe3,
250 0x94, 0x81, 0xea, 0xf8, 0x54, 0xd4, 0xaa, 0xac, 0x94, 0xd9, 0xca, 0xac,
251 0x64, 0xd6, 0x32, 0xab, 0xa4, 0xd6, 0xfe, 0xff};
252
253 #define text16_width 16
254 #define text16_height 16
255 static unsigned char text16_bits[] =
256 {
257 0x00, 0x00, 0xfe, 0x0f, 0x02, 0x08, 0x02, 0x08, 0xfa, 0x0b, 0x02, 0x08,
258 0xfa, 0x0b, 0x02, 0x08, 0x02, 0x08, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00,
259 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
260
261 #define text16_mask_width 16
262 #define text16_mask_height 16
263 static unsigned char text16_mask_bits[] =
264 {
265 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f,
266 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
268
269 #define state32_width 32
270 #define state32_height 28
271 static unsigned char state32_bits[] =
272 {
273 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
274 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
275 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
281 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
284
285 #define state32_mask_width 32
286 #define state32_mask_height 32
287 static unsigned char state32_mask_bits[] =
288 {
289 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
290 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
291 0xff, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00,
292 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
298 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
300
301 #define move32_width 32
302 #define move32_height 32
303 static unsigned char move32_bits[] =
304 {
305 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00,
308 0x20, 0xe0, 0x00, 0x00, 0x20, 0xe0, 0x01, 0x00, 0x20, 0xe0, 0x03, 0x00,
309 0x20, 0xe0, 0x07, 0x00, 0x20, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x0c, 0x00,
310 0x20, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x0c, 0x00,
311 0x20, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x0c, 0x00,
312 0x20, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x0c, 0x00,
313 0xe0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
315 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
316
317 #define move32_mask_width 32
318 #define move32_mask_height 32
319 static unsigned char move32_mask_bits[] =
320 {
321 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
322 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
323 0xf0, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00,
324 0xf0, 0xff, 0x03, 0x00, 0xf0, 0xff, 0x07, 0x00, 0xf0, 0xff, 0x0f, 0x00,
325 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00,
326 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00,
327 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00,
328 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00,
329 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xe0, 0xff, 0x1f, 0x00,
330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
331 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
332
333 #define copy32_width 32
334 #define copy32_height 32
335 static unsigned char copy32_bits[] =
336 {
337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
339 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00,
340 0x20, 0xe0, 0x00, 0x00, 0x20, 0xe0, 0x01, 0x00, 0x20, 0xe0, 0x03, 0x00,
341 0x20, 0xe0, 0x07, 0x00, 0x20, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x0c, 0x00,
342 0x20, 0x00, 0x2c, 0x00, 0x20, 0x00, 0x6c, 0x00, 0x20, 0x00, 0xec, 0x00,
343 0x20, 0x00, 0x8c, 0x01, 0x20, 0x00, 0x8c, 0x01, 0x20, 0x00, 0x8c, 0x01,
344 0x20, 0x00, 0x8c, 0x01, 0x20, 0x00, 0x8c, 0x01, 0x20, 0x00, 0x8c, 0x01,
345 0xe0, 0xff, 0x8f, 0x01, 0xc0, 0xff, 0x8f, 0x01, 0x00, 0x00, 0x80, 0x01,
346 0x00, 0x04, 0x80, 0x01, 0x00, 0x04, 0x80, 0x01, 0x00, 0xfc, 0xff, 0x01,
347 0x00, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00};
348
349 #define copy32_mask_width 32
350 #define copy32_mask_height 32
351 static unsigned char copy32_mask_bits[] =
352 {
353 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
354 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
355 0xf0, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00,
356 0xf0, 0xff, 0x03, 0x00, 0xf0, 0xff, 0x07, 0x00, 0xf0, 0xff, 0x0f, 0x00,
357 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x7f, 0x00,
358 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x01, 0xf0, 0xff, 0xff, 0x03,
359 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x03,
360 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x03,
361 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x03,
362 0x00, 0xfe, 0xff, 0x03, 0x00, 0xfe, 0xff, 0x03, 0x00, 0xfe, 0xff, 0x03,
363 0x00, 0xfe, 0xff, 0x03, 0x00, 0xfc, 0xff, 0x03};
364
365 #define link32_width 32
366 #define link32_height 32
367 static unsigned char link32_bits[] =
368 {
369 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
370 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
371 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0x20, 0x30, 0x00, 0x00,
372 0x20, 0x70, 0x00, 0x00, 0x20, 0xf0, 0x00, 0x00, 0x20, 0xf0, 0x01, 0x00,
373 0x20, 0x00, 0x7b, 0x00, 0x20, 0x00, 0xc3, 0x00, 0x20, 0x04, 0xc3, 0x01,
374 0x20, 0x06, 0xc3, 0x03, 0x20, 0x0f, 0xc2, 0x07, 0x20, 0x36, 0x00, 0x0c,
375 0x20, 0xc4, 0x00, 0x0c, 0x20, 0x00, 0x23, 0x0c, 0x20, 0x00, 0x6c, 0x0c,
376 0x20, 0x00, 0xf0, 0x0c, 0xe0, 0xff, 0x61, 0x0c, 0xc0, 0xff, 0x23, 0x0c,
377 0x00, 0x00, 0x00, 0x0c, 0x00, 0x80, 0x00, 0x0c, 0x00, 0x80, 0x00, 0x0c,
378 0x00, 0x80, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00,
379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
380
381 #define link32_mask_width 32
382 #define link32_mask_height 32
383 static unsigned char link32_mask_bits[] =
384 {
385 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
386 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387 0xf0, 0x3f, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00,
388 0xf0, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x03, 0x00, 0xf0, 0xff, 0xff, 0x00,
389 0xf0, 0xff, 0xff, 0x01, 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x07,
390 0xf0, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0x1f,
391 0xf0, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0x1f,
392 0xf0, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0x1f,
393 0xe0, 0xff, 0xff, 0x1f, 0x00, 0xc0, 0xff, 0x1f, 0x00, 0xc0, 0xff, 0x1f,
394 0x00, 0xc0, 0xff, 0x1f, 0x00, 0xc0, 0xff, 0x1f, 0x00, 0x80, 0xff, 0x1f,
395 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
396
397 #define source32_width 32
398 #define source32_height 32
399 static unsigned char source32_bits[] =
400 {
401 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x54, 0x55, 0x55, 0xd5,
402 0xa8, 0xaa, 0xaa, 0xea, 0x54, 0x55, 0x55, 0xd1, 0xa8, 0xaa, 0xaa, 0xe0,
403 0x54, 0x55, 0x55, 0xd0, 0xa8, 0xaa, 0xaa, 0xf0, 0x54, 0x55, 0x55, 0xd9,
404 0xa8, 0xaa, 0x00, 0xee, 0x54, 0x55, 0x00, 0xd6, 0xa8, 0x2a, 0x3f, 0xea,
405 0x54, 0x95, 0x05, 0xd7, 0xa8, 0xea, 0x82, 0xee, 0x54, 0x45, 0xc1, 0xd5,
406 0xa8, 0xaa, 0xf4, 0x81, 0x54, 0xd5, 0x78, 0xff, 0xa8, 0xaa, 0xa0, 0xea,
407 0x54, 0x95, 0x41, 0xd5, 0xa8, 0x4a, 0x87, 0xea, 0x54, 0x85, 0x0d, 0xd5,
408 0xa8, 0xc2, 0x9a, 0xea, 0x54, 0x61, 0x05, 0xd5, 0xa8, 0xb0, 0xc2, 0xea,
409 0x54, 0x58, 0x61, 0xd5, 0x28, 0xac, 0xb0, 0xea, 0x14, 0x56, 0x58, 0xd5,
410 0x08, 0xab, 0xa8, 0xea, 0x14, 0x55, 0x51, 0xd5, 0x28, 0xaa, 0xaa, 0xea,
411 0xfc, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff};
412
413 #define text32_width 32
414 #define text32_height 20
415 static unsigned char text32_bits[] =
416 {
417 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x01, 0x02, 0x00, 0x00, 0x01,
418 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01,
419 0x82, 0xff, 0x0f, 0x01, 0xc2, 0xff, 0x0f, 0x01, 0xc2, 0xff, 0x07, 0x01,
420 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x82, 0xff, 0x0f, 0x01,
421 0xc2, 0xff, 0x0f, 0x01, 0xc2, 0xff, 0x07, 0x01, 0x02, 0x00, 0x00, 0x01,
422 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01,
423 0xfe, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00};
424
425 #define text32_mask_width 32
426 #define text32_mask_height 20
427 static unsigned char text32_mask_bits[] =
428 {
429 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03,
430 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03,
431 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03,
432 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03,
433 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03,
434 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03,
435 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03};
436
437 /*
438 * standardize building for the standard op/state/source pixmaps
439 */
440 typedef struct
441 {
442 int width, height;
443 int hot_x, hot_y;
444 int offset_x, offset_y;
445 char *pix_name;
446 unsigned char *data;
447 char *mask_name;
448 unsigned char *mask_data;
449 }
450 XmCursorDataRec;
451
452 static XmCursorDataRec state16CursorDataRec =
453 {
454 state16_width, state16_height,
455 1, 1, -8, -2,
456 "state16", state16_bits,
457 "state16_mask", state16_mask_bits
458 };
459
460 static XmCursorDataRec move16CursorDataRec =
461 {
462 move16_width, move16_height,
463 1, 1, -8, -2,
464 "move16", move16_bits,
465 "move16_mask", move16_mask_bits
466 };
467
468 static XmCursorDataRec copy16CursorDataRec =
469 {
470 copy16_width, copy16_height,
471 1, 1, -8, -2,
472 "copy16", copy16_bits,
473 "copy16_mask", copy16_mask_bits
474 };
475
476 static XmCursorDataRec link16CursorDataRec =
477 {
478 link16_width, link16_height,
479 1, 1, -8, -2,
480 "link16", link16_bits,
481 "link16_mask", link16_mask_bits
482 };
483
484 static XmCursorDataRec source16CursorDataRec =
485 {
486 source16_width, source16_height,
487 0, 0, 0, 0,
488 "source16", source16_bits,
489 NULL, NULL
490 };
491
492 static XmCursorDataRec text16CursorDataRec =
493 {
494 text16_width, text16_height,
495 2, 2, 0, 0,
496 "text16", text16_bits,
497 "text16_mask", text16_mask_bits
498 };
499
500 static XmCursorDataRec state32CursorDataRec =
501 {
502 state32_width, state32_height,
503 1, 1, -16, -4,
504 "state32", state32_bits,
505 "state32_mask", state32_mask_bits
506 };
507
508 static XmCursorDataRec move32CursorDataRec =
509 {
510 move32_width, move32_height,
511 1, 1, -16, -4,
512 "move32", move32_bits,
513 "move32_mask", move32_mask_bits
514 };
515
516 static XmCursorDataRec copy32CursorDataRec =
517 {
518 move32_width, move32_height,
519 1, 1, -16, -4,
520 "copy32", copy32_bits,
521 "copy32_mask", copy32_mask_bits
522 };
523
524 static XmCursorDataRec link32CursorDataRec =
525 {
526 link32_width, link32_height,
527 1, 1, -16, -4,
528 "link32", link32_bits,
529 "link32_mask", link32_mask_bits
530 };
531
532 static XmCursorDataRec source32CursorDataRec =
533 {
534 source32_width, source32_height,
535 0, 0, 0, 0,
536 "source32", source32_bits,
537 NULL, NULL
538 };
539
540 static XmCursorDataRec text32CursorDataRec =
541 {
542 text32_width, text32_height,
543 4, 4, 0, 0,
544 "text32", text32_bits,
545 "text32_mask", text32_mask_bits
546 };
547
548 /*
549 * associate the quarks to the DragIcons
550 */
551 typedef struct
552 {
553 XrmQuark *quark;
554 XmCursorDataRec *cdr;
555 }
556 XmQuarkToCursorRec;
557
558 static XmQuarkToCursorRec quarkTo16CursorTable[] =
559 {
560 {&_XmValidCursorIconQuark, &state16CursorDataRec},
561 {&_XmInvalidCursorIconQuark, &state16CursorDataRec},
562 {&_XmNoneCursorIconQuark, &state16CursorDataRec},
563 {&_XmMoveCursorIconQuark, &move16CursorDataRec},
564 {&_XmCopyCursorIconQuark, ©16CursorDataRec},
565 {&_XmLinkCursorIconQuark, &link16CursorDataRec},
566 {&_XmDefaultDragIconQuark, &source16CursorDataRec},
567 {NULL, &text16CursorDataRec},
568 };
569
570 static XmQuarkToCursorRec quarkToCursorTable[] =
571 {
572 {&_XmValidCursorIconQuark, &state32CursorDataRec},
573 {&_XmInvalidCursorIconQuark, &state32CursorDataRec},
574 {&_XmNoneCursorIconQuark, &state32CursorDataRec},
575 {&_XmMoveCursorIconQuark, &move32CursorDataRec},
576 {&_XmCopyCursorIconQuark, ©32CursorDataRec},
577 {&_XmLinkCursorIconQuark, &link32CursorDataRec},
578 {&_XmDefaultDragIconQuark, &source32CursorDataRec},
579 {NULL, &text32CursorDataRec}
580 };
581
582 static void
class_initialize(void)583 class_initialize(void)
584 {
585 DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:class_initialize(%d)\n",
586 __FILE__, __LINE__));
587 _XmDragIconRectClassExtRec.record_type = XmQmotif;
588 }
589
590 static void
class_part_initialize(WidgetClass widget_class)591 class_part_initialize(WidgetClass widget_class)
592 {
593 DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:class_part_initialize(%d)\n",
594 __FILE__, __LINE__));
595 _XmFastSubclassInit(widget_class, XmDRAG_ICON_BIT);
596 }
597
598 static void
initialize(Widget request,Widget new_w,ArgList args,Cardinal * num_args)599 initialize(Widget request, Widget new_w,
600 ArgList args, Cardinal *num_args)
601 {
602 Dimension uwidth, uheight;
603 Screen *pscr;
604 char *name;
605 Pixel fg, bg;
606 int hx, hy, depth, which;
607 unsigned int width, height;
608 XImage *image;
609
610 DEBUGOUT(_LtDebug(__FILE__, new_w,
611 "%s:initialize(%d) - %i args\n"
612 "\trequest X %5i Y %5i W %5i H %5i\n"
613 "\t new_w X %5i Y %5i W %5i H %5i\n",
614 __FILE__, __LINE__,
615 *num_args,
616 XtX(request), XtY(request),
617 XtWidth(request), XtHeight(request),
618 XtX(new_w), XtY(new_w),
619 XtWidth(new_w), XtHeight(new_w)));
620 DEBUGOUT(_LtDebugPrintArgList(__FILE__, new_w, args, *num_args, False));
621
622 pscr = XtScreenOfObject(XtParent(new_w));
623
624 DI_Region(new_w) = NULL;
625 DI_RestoreRegion(new_w) = NULL;
626
627 DI_IsDirty(new_w) = False;
628
629 if (DI_Pixmap(new_w) == XmUNSPECIFIED_PIXMAP)
630 {
631 _XmGetMaxCursorSize(new_w, &uwidth, &uheight);
632
633 if (uwidth < 32 || uheight < 32)
634 {
635 for (which = 0;
636 quarkTo16CursorTable[which].quark != NULL;
637 which++)
638 {
639 if (ObjName(new_w) == *(quarkTo16CursorTable[which].quark))
640 break;
641 }
642
643 _XmCreateImage(image, XtDisplay(new_w),
644 (char *)quarkTo16CursorTable[which].cdr->data,
645 quarkTo16CursorTable[which].cdr->width,
646 quarkTo16CursorTable[which].cdr->height,
647 LSBFirst);
648
649 _XmInstallImage(image, quarkTo16CursorTable[which].cdr->pix_name,
650 quarkTo16CursorTable[which].cdr->hot_x,
651 quarkTo16CursorTable[which].cdr->hot_y);
652
653 DI_Pixmap(new_w) = _XmGetPixmap(pscr,
654 quarkTo16CursorTable[which].cdr->pix_name,
655 1,
656 1,
657 0);
658
659 _XmCreateImage(image, XtDisplay(new_w),
660 (char *)quarkTo16CursorTable[which].cdr->mask_data,
661 quarkTo16CursorTable[which].cdr->width,
662 quarkTo16CursorTable[which].cdr->height,
663 LSBFirst);
664
665 _XmInstallImage(image, quarkTo16CursorTable[which].cdr->mask_name,
666 quarkTo16CursorTable[which].cdr->hot_x,
667 quarkTo16CursorTable[which].cdr->hot_y);
668
669 DI_Mask(new_w) = _XmGetPixmap(pscr,
670 quarkTo16CursorTable[which].cdr->mask_name,
671 1,
672 1,
673 0);
674
675 DI_Width(new_w) = quarkTo16CursorTable[which].cdr->width;
676 DI_Height(new_w) = quarkTo16CursorTable[which].cdr->height;
677 DI_HotX(new_w) = quarkTo16CursorTable[which].cdr->hot_x;
678 DI_HotY(new_w) = quarkTo16CursorTable[which].cdr->hot_y;
679 DI_OffsetX(new_w) = quarkTo16CursorTable[which].cdr->offset_x;
680 DI_OffsetY(new_w) = quarkTo16CursorTable[which].cdr->offset_y;
681 }
682 else
683 {
684 for (which = 0;
685 quarkToCursorTable[which].quark != NULL;
686 which++)
687 {
688 if (ObjName(new_w) == *(quarkToCursorTable[which].quark))
689 break;
690 }
691
692 _XmCreateImage(image, XtDisplay(new_w),
693 (char *)quarkToCursorTable[which].cdr->data,
694 quarkToCursorTable[which].cdr->width,
695 quarkToCursorTable[which].cdr->height,
696 LSBFirst);
697
698 _XmInstallImage(image, quarkToCursorTable[which].cdr->pix_name,
699 quarkToCursorTable[which].cdr->hot_x,
700 quarkToCursorTable[which].cdr->hot_y);
701
702 DI_Pixmap(new_w) = _XmGetPixmap(pscr,
703 quarkToCursorTable[which].cdr->pix_name,
704 1,
705 1,
706 0);
707
708 _XmCreateImage(image, XtDisplay(new_w),
709 (char *)quarkToCursorTable[which].cdr->mask_data,
710 quarkToCursorTable[which].cdr->width,
711 quarkToCursorTable[which].cdr->height,
712 LSBFirst);
713
714 _XmInstallImage(image, quarkToCursorTable[which].cdr->mask_name,
715 quarkToCursorTable[which].cdr->hot_x,
716 quarkToCursorTable[which].cdr->hot_y);
717
718 DI_Mask(new_w) = _XmGetPixmap(pscr,
719 quarkToCursorTable[which].cdr->mask_name,
720 1,
721 1,
722 0);
723
724 DI_Width(new_w) = quarkToCursorTable[which].cdr->width;
725 DI_Height(new_w) = quarkToCursorTable[which].cdr->height;
726 DI_HotX(new_w) = quarkToCursorTable[which].cdr->hot_x;
727 DI_HotY(new_w) = quarkToCursorTable[which].cdr->hot_y;
728 DI_OffsetX(new_w) = quarkToCursorTable[which].cdr->offset_x;
729 DI_OffsetY(new_w) = quarkToCursorTable[which].cdr->offset_y;
730 }
731 }
732
733 if (DI_Width(new_w) == 0 || DI_Height(new_w) == 0)
734 {
735
736 if (_XmGetPixmapData(pscr, DI_Pixmap(new_w), &name, &depth,
737 &fg, &bg, &hx, &hy, &width, &height))
738 {
739 DI_Depth(new_w) = depth;
740 DI_HotX(new_w) = hx;
741 DI_HotY(new_w) = hy;
742 DI_Width(new_w) = width;
743 DI_Height(new_w) = height;
744
745 }
746 else
747 {
748 DI_Width(new_w) = 0;
749 DI_Height(new_w) = 0;
750 DI_Pixmap(new_w) = XmUNSPECIFIED_PIXMAP;
751 }
752 }
753 }
754
755 static void
destroy(Widget w)756 destroy(Widget w)
757 {
758 DEBUGOUT(_LtDebug(__FILE__, w, "%s:destroy(%d)\n",
759 __FILE__, __LINE__));
760
761 if (DI_Region(w))
762 {
763 XDestroyRegion(DI_Region(w));
764 }
765
766 if (DI_RestoreRegion(w))
767 {
768 XDestroyRegion(DI_RestoreRegion(w));
769 }
770
771 _XmScreenRemoveFromCursorCache((XmDragIconObject)w);
772 }
773
774 static Boolean
set_values(Widget current,Widget request,Widget new_w,ArgList args,Cardinal * num_args)775 set_values(Widget current, Widget request, Widget new_w,
776 ArgList args, Cardinal *num_args)
777 {
778 Boolean refresh = False;
779
780 DEBUGOUT(_LtDebug(__FILE__, new_w,
781 "%s:set_values(%d) - %i args\n"
782 "\t old X %5i Y %5i W %5i H %5i\n"
783 "\trequest X %5i Y %5i W %5i H %5i\n"
784 "\t new_w X %5i Y %5i W %5i H %5i\n",
785 __FILE__, __LINE__,
786 *num_args,
787 XtX(current), XtY(current),
788 XtWidth(current), XtHeight(current),
789 XtX(request), XtY(request),
790 XtWidth(request), XtHeight(request),
791 XtX(new_w), XtY(new_w),
792 XtWidth(new_w), XtHeight(new_w)));
793 DEBUGOUT(_LtDebugPrintArgList(__FILE__, new_w, args, *num_args, False));
794
795 if (DI_Depth(new_w) != DI_Depth(current) ||
796 DI_Width(new_w) != DI_Width(current) ||
797 DI_Height(new_w) != DI_Height(current) ||
798 DI_HotX(new_w) != DI_HotX(current) ||
799 DI_HotY(new_w) != DI_HotY(current) ||
800 DI_OffsetX(new_w) != DI_OffsetX(current) ||
801 DI_OffsetY(new_w) != DI_OffsetY(current))
802 {
803 refresh = True;
804 DI_IsDirty(new_w) = True;
805 }
806
807 if (DI_Pixmap(new_w) != DI_Pixmap(current) ||
808 DI_Mask(new_w) != DI_Mask(current))
809 {
810 refresh = True;
811 DI_IsDirty(new_w) = True;
812 }
813
814 return refresh;
815 }
816
817 static XContext textIconContext = None;
818 #define XmTextualDragIconRID ((XID)None)
819
820 Widget
_XmGetTextualDragIcon(Widget w)821 _XmGetTextualDragIcon(Widget w)
822 {
823 Widget widget;
824
825 DEBUGOUT(_LtDebug(__FILE__, w, "_XmGetTextualDragIcon\n"));
826
827 if (textIconContext == None)
828 {
829 textIconContext = XUniqueContext();
830 }
831
832 if (XFindContext(XtDisplay(w), XmTextualDragIconRID, textIconContext,
833 (XPointer *)&widget) == XCSUCCESS)
834 {
835 return widget;
836 }
837
838 widget = XmCreateDragIcon(w, "XmTextualDragIcon",
839 NULL, 0);
840
841 XSaveContext(XtDisplay(w), XmTextualDragIconRID, textIconContext,
842 (XPointer)widget);
843
844 return widget;
845 }
846
847 void
_XmDestroyDefaultDragIcon(XmDragIconObject icon)848 _XmDestroyDefaultDragIcon(XmDragIconObject icon)
849 {
850 Screen *scr = XtScreenOfObject(XtParent(icon));
851
852 DEBUGOUT(_LtDebug0(__FILE__, NULL, "_XmDestroyDefaultDragIcon\n"));
853
854 if (DI_Pixmap(icon) != XmUNSPECIFIED_PIXMAP)
855 {
856 XmDestroyPixmap(scr, DI_Pixmap(icon));
857 DI_Pixmap(icon) = XmUNSPECIFIED_PIXMAP;
858 }
859
860 if (DI_Mask(icon) != XmUNSPECIFIED_PIXMAP)
861 {
862 XmDestroyPixmap(scr, DI_Mask(icon));
863 DI_Mask(icon) = XmUNSPECIFIED_PIXMAP;
864 }
865
866 XtDestroyWidget((Widget)icon);
867 }
868
869 Boolean
_XmDragIconIsDirty(XmDragIconObject icon)870 _XmDragIconIsDirty(XmDragIconObject icon)
871 {
872 DEBUGOUT(_LtDebug0(__FILE__, NULL, "_XmDragIconIsDirty\n"));
873
874 return DI_IsDirty(icon);
875 }
876
877 void
_XmDragIconClean(XmDragIconObject icon1,XmDragIconObject icon2,XmDragIconObject icon3)878 _XmDragIconClean(XmDragIconObject icon1,
879 XmDragIconObject icon2,
880 XmDragIconObject icon3)
881 {
882 DEBUGOUT(_LtDebug0(__FILE__, NULL, "_XmDragIconClean\n"));
883
884 if (icon1)
885 DI_IsDirty(icon1) = False;
886 if (icon2)
887 DI_IsDirty(icon2) = False;
888 if (icon3)
889 DI_IsDirty(icon3) = False;
890 }
891
892 Widget
XmCreateDragIcon(Widget widget,String name,ArgList arglist,Cardinal argcount)893 XmCreateDragIcon(Widget widget,
894 String name,
895 ArgList arglist,
896 Cardinal argcount)
897 {
898 DEBUGOUT(_LtDebug(__FILE__, widget, "XmCreateDragIcon\n"));
899
900 return XtCreateWidget(name, xmDragIconObjectClass,
901 widget, arglist, argcount);
902 }
903