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 librararies 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;
185 unsigned int cHeight;
186 int useLargeCursors = 0;
187 static Cursor waitCursor=0;
189 _DtHelpProcessLock();
193 _DtHelpProcessUnlock();
197 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
198 32, 32, &cWidth, &cHeight))
200 if ((cWidth >= 32) && (cHeight >= 32))
208 width = noenter32_width;
209 height = noenter32_height;
210 bits = (char *) noenter32_bits;
211 maskBits = (char *) noenter32m_bits;
212 xHotspot = noenter32_x_hot;
213 yHotspot = noenter32_y_hot;
217 width = noenter16_width;
218 height = noenter16_height;
219 bits = (char *) noenter16_bits;
220 maskBits = (char *) noenter16m_bits;
221 xHotspot = noenter16_x_hot;
222 yHotspot = noenter16_y_hot;
225 pixmap = XCreateBitmapFromData (dpy,
226 DefaultRootWindow(dpy), bits,
230 maskPixmap = XCreateBitmapFromData (dpy,
231 DefaultRootWindow(dpy), maskBits,
234 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
235 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
238 DefaultColormapOfScreen(DefaultScreenOfDisplay
241 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
242 &(xcolors[0]), &(xcolors[1]),
244 XFreePixmap (dpy, pixmap);
245 XFreePixmap (dpy, maskPixmap);
247 _DtHelpProcessUnlock();
251 /*************************************<->*************************************
253 * Cursor _DtHelpGetHourGlassCursor ()
258 * Builds and returns the appropriate Hourglass cursor
271 * None. (None doesn't count as a comment)
273 *************************************<->***********************************/
275 _DtHelpGetHourGlassCursor(
282 unsigned int xHotspot;
283 unsigned int yHotspot;
289 unsigned int cHeight;
290 int useLargeCursors = 0;
291 static Cursor waitCursor=0;
297 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
298 32, 32, &cWidth, &cHeight))
300 if ((cWidth >= 32) && (cHeight >= 32))
308 width = time32_width;
309 height = time32_height;
310 bits = (char *) time32_bits;
311 maskBits = (char *) time32m_bits;
312 xHotspot = time32_x_hot;
313 yHotspot = time32_y_hot;
317 width = time16_width;
318 height = time16_height;
319 bits = (char *) time16_bits;
320 maskBits = (char *) time16m_bits;
321 xHotspot = time16_x_hot;
322 yHotspot = time16_y_hot;
325 pixmap = XCreateBitmapFromData (dpy,
326 DefaultRootWindow(dpy), bits,
330 maskPixmap = XCreateBitmapFromData (dpy,
331 DefaultRootWindow(dpy), maskBits,
334 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
335 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
338 DefaultColormapOfScreen(DefaultScreenOfDisplay
341 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
342 &(xcolors[0]), &(xcolors[1]),
344 XFreePixmap (dpy, pixmap);
345 XFreePixmap (dpy, maskPixmap);
351 /*************************************<->*************************************
353 * void _DtSetHourGlass
358 * sets the window cursor to an hourglass
371 * None. (None doesn't count as a comment)
373 *************************************<->***********************************/
376 _DtHelpTurnOnHourGlass(
381 cursor = _DtHelpGetHourGlassCursor(XtDisplay(w));
383 XDefineCursor(XtDisplay(w), XtWindow(w), cursor);
384 XFlush(XtDisplay(w));
388 /*************************************<->*************************************
390 * void _DtHelpTurnOffHourGlass
395 * Removed the hourglass cursor from a window
408 * None. (None doesn't count as a comment)
410 *************************************<->***********************************/
413 _DtHelpTurnOffHourGlass(
417 XUndefineCursor(XtDisplay(w), XtWindow(w));
418 XFlush(XtDisplay(w));
421 /*************************************<->*************************************
423 * void _DtHelpTurnOnNoEnter
428 * sets the window cursor to a 'no enter' sign
441 * None. (None doesn't count as a comment)
443 *************************************<->***********************************/
446 _DtHelpTurnOnNoEnter(
451 cursor = GetNoEnterCursor(XtDisplay(w));
453 XDefineCursor(XtDisplay(w), XtWindow(w), cursor);
454 XFlush(XtDisplay(w));
458 /*************************************<->*************************************
460 * void _DtHelpTurnOffNoEnter
465 * Removed the 'no enter' cursor from a window
478 * None. (None doesn't count as a comment)
480 *************************************<->***********************************/
483 _DtHelpTurnOffNoEnter(
487 XUndefineCursor(XtDisplay(w), XtWindow(w));
488 XFlush(XtDisplay(w));