2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: HourGlass.c /main/6 1996/04/13 11:55:39 ageorge $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: coe Dt Utility function
31 ** Description: This module contains a simple function for
32 ** creating an hourglass cursor.
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 International Business Machines Corp.
38 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
39 ** (c) Copyright 1993, 1994 Novell, Inc.
43 ****************************************************************************
44 ************************************<+>*************************************/
48 #include <X11/Intrinsic.h>
52 #define time32_width 32
53 #define time32_height 32
54 #define time32_x_hot 15
55 #define time32_y_hot 15
56 static unsigned char time32_bits[] = {
57 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
58 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
59 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
60 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
61 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
62 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
63 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
64 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
65 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
66 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
67 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
69 #define time32m_width 32
70 #define time32m_height 32
71 static unsigned char time32m_bits[] = {
72 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
73 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
74 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
75 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
76 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
77 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
78 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
79 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
80 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
81 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
82 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
85 #define time16_x_hot 7
86 #define time16_y_hot 7
87 #define time16_width 16
88 #define time16_height 16
89 static unsigned char time16_bits[] = {
90 0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
91 0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
92 0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
94 #define time16m_width 16
95 #define time16m_height 16
96 static unsigned char time16m_bits[] = {
97 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
98 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
99 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
101 #define noenter32_width 32
102 #define noenter32_height 32
103 #define noenter32_x_hot 15
104 #define noenter32_y_hot 15
106 static unsigned char noenter32_bits[] = {
107 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xfc, 0x3f, 0x00,
108 0x00, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x03,
109 0xe0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x1f,
110 0xf8, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
111 0xfc, 0xff, 0xff, 0x3f, 0x06, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x60,
112 0x06, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x60,
113 0x06, 0x00, 0x00, 0x60, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
114 0xfc, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f,
115 0xf0, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0x07, 0xc0, 0xff, 0xff, 0x03,
116 0x80, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfc, 0x3f, 0x00,
117 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00};
119 static unsigned char noenter32m_bits[] = {
120 0x00, 0xe0, 0x07, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x00,
121 0x80, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
122 0xf0, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0x3f,
123 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
124 0xfe, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
125 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
126 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
127 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
128 0xf8, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0x07,
129 0xc0, 0xff, 0xff, 0x03, 0x80, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0x00,
130 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xe0, 0x07, 0x00};
132 #define noenter16_width 16
133 #define noenter16_height 16
134 #define noenter16_x_hot 7
135 #define noenter16_y_hot 7
137 static unsigned char noenter16_bits[] = {
138 0x00, 0x00, 0xc0, 0x03, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfc, 0x3f,
139 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0xfc, 0x3f, 0xfc, 0x3f,
140 0xf8, 0x1f, 0xf0, 0x0f, 0xc0, 0x03, 0x00, 0x00};
142 static unsigned char noenter16m_bits[] = {
143 0xc0, 0x03, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f,
144 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f,
145 0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xc0, 0x03};
147 /*************************************<->*************************************
149 * Cursor GetNoEnterCursor ()
154 * Builds and returns the appropriate Hourglass cursor
167 * None. (None doesn't count as a comment)
169 *************************************<->***********************************/
178 unsigned int xHotspot;
179 unsigned int yHotspot;
184 unsigned int cHeight;
185 int useLargeCursors = 0;
186 static Cursor waitCursor=0;
188 _DtHelpProcessLock();
192 _DtHelpProcessUnlock();
196 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
197 32, 32, &cWidth, &cHeight))
199 if ((cWidth >= 32) && (cHeight >= 32))
207 width = noenter32_width;
208 height = noenter32_height;
209 bits = (char *) noenter32_bits;
210 maskBits = (char *) noenter32m_bits;
211 xHotspot = noenter32_x_hot;
212 yHotspot = noenter32_y_hot;
216 width = noenter16_width;
217 height = noenter16_height;
218 bits = (char *) noenter16_bits;
219 maskBits = (char *) noenter16m_bits;
220 xHotspot = noenter16_x_hot;
221 yHotspot = noenter16_y_hot;
224 pixmap = XCreateBitmapFromData (dpy,
225 DefaultRootWindow(dpy), bits,
229 maskPixmap = XCreateBitmapFromData (dpy,
230 DefaultRootWindow(dpy), maskBits,
233 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
234 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
237 DefaultColormapOfScreen(DefaultScreenOfDisplay
240 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
241 &(xcolors[0]), &(xcolors[1]),
243 XFreePixmap (dpy, pixmap);
244 XFreePixmap (dpy, maskPixmap);
246 _DtHelpProcessUnlock();
250 /*************************************<->*************************************
252 * Cursor _DtHelpGetHourGlassCursor ()
257 * Builds and returns the appropriate Hourglass cursor
270 * None. (None doesn't count as a comment)
272 *************************************<->***********************************/
274 _DtHelpGetHourGlassCursor(
281 unsigned int xHotspot;
282 unsigned int yHotspot;
287 unsigned int cHeight;
288 int useLargeCursors = 0;
289 static Cursor waitCursor=0;
295 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
296 32, 32, &cWidth, &cHeight))
298 if ((cWidth >= 32) && (cHeight >= 32))
306 width = time32_width;
307 height = time32_height;
308 bits = (char *) time32_bits;
309 maskBits = (char *) time32m_bits;
310 xHotspot = time32_x_hot;
311 yHotspot = time32_y_hot;
315 width = time16_width;
316 height = time16_height;
317 bits = (char *) time16_bits;
318 maskBits = (char *) time16m_bits;
319 xHotspot = time16_x_hot;
320 yHotspot = time16_y_hot;
323 pixmap = XCreateBitmapFromData (dpy,
324 DefaultRootWindow(dpy), bits,
328 maskPixmap = XCreateBitmapFromData (dpy,
329 DefaultRootWindow(dpy), maskBits,
332 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
333 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
336 DefaultColormapOfScreen(DefaultScreenOfDisplay
339 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
340 &(xcolors[0]), &(xcolors[1]),
342 XFreePixmap (dpy, pixmap);
343 XFreePixmap (dpy, maskPixmap);
349 /*************************************<->*************************************
351 * void _DtSetHourGlass
356 * sets the window cursor to an hourglass
369 * None. (None doesn't count as a comment)
371 *************************************<->***********************************/
374 _DtHelpTurnOnHourGlass(
379 cursor = _DtHelpGetHourGlassCursor(XtDisplay(w));
381 XDefineCursor(XtDisplay(w), XtWindow(w), cursor);
382 XFlush(XtDisplay(w));
386 /*************************************<->*************************************
388 * void _DtHelpTurnOffHourGlass
393 * Removed the hourglass cursor from a window
406 * None. (None doesn't count as a comment)
408 *************************************<->***********************************/
411 _DtHelpTurnOffHourGlass(
415 XUndefineCursor(XtDisplay(w), XtWindow(w));
416 XFlush(XtDisplay(w));
419 /*************************************<->*************************************
421 * void _DtHelpTurnOnNoEnter
426 * sets the window cursor to a 'no enter' sign
439 * None. (None doesn't count as a comment)
441 *************************************<->***********************************/
444 _DtHelpTurnOnNoEnter(
449 cursor = GetNoEnterCursor(XtDisplay(w));
451 XDefineCursor(XtDisplay(w), XtWindow(w), cursor);
452 XFlush(XtDisplay(w));
456 /*************************************<->*************************************
458 * void _DtHelpTurnOffNoEnter
463 * Removed the 'no enter' cursor from a window
476 * None. (None doesn't count as a comment)
478 *************************************<->***********************************/
481 _DtHelpTurnOffNoEnter(
485 XUndefineCursor(XtDisplay(w), XtWindow(w));
486 XFlush(XtDisplay(w));