1 /* $XConsortium: HourGlass.c /main/3 1995/11/08 09:18:28 rswiston $ */
2 /************************************<+>*************************************
3 ****************************************************************************
7 ** Project: CDE dthelpdemo sample program.
9 ** Description: This module contains a simple function for
10 ** creating an hourglass cursor.
12 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
13 ** Hewlett-Packard Company
14 ** (c) Copyright 1993, 1994 International Business Machines Corp.
15 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
16 ** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
21 ****************************************************************************
22 ************************************<+>*************************************/
26 #include <X11/Intrinsic.h>
28 #define time32_width 32
29 #define time32_height 32
30 #define time32_x_hot 15
31 #define time32_y_hot 15
32 static unsigned char time32_bits[] = {
33 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
34 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
35 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
36 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
37 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
38 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
39 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
40 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
41 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
42 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
43 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
45 #define time32m_width 32
46 #define time32m_height 32
47 static unsigned char time32m_bits[] = {
48 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
49 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
50 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
51 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
52 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
53 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
54 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
55 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
56 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
57 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
58 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
61 #define time16_x_hot 7
62 #define time16_y_hot 7
63 #define time16_width 16
64 #define time16_height 16
65 static unsigned char time16_bits[] = {
66 0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
67 0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
68 0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
70 #define time16m_width 16
71 #define time16m_height 16
72 static unsigned char time16m_bits[] = {
73 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
74 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
75 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
78 /******** End Public Function Declarations ********/
80 /*************************************<->*************************************
82 * Cursor GetHourGlassCursor ()
87 * Builds and returns the appropriate Hourglass cursor
100 * None. (None doesn't count as a comment)
102 *************************************<->***********************************/
103 static Cursor GetHourGlassCursor(
111 unsigned int xHotspot;
112 unsigned int yHotspot;
118 unsigned int cHeight;
119 int useLargeCursors = 0;
120 static Cursor waitCursor=0;
126 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
127 32, 32, &cWidth, &cHeight))
129 if ((cWidth >= 32) && (cHeight >= 32))
137 width = time32_width;
138 height = time32_height;
139 bits = (char *) time32_bits;
140 maskBits = (char *) time32m_bits;
141 xHotspot = time32_x_hot;
142 yHotspot = time32_y_hot;
146 width = time16_width;
147 height = time16_height;
148 bits = (char *) time16_bits;
149 maskBits = (char *) time16m_bits;
150 xHotspot = time16_x_hot;
151 yHotspot = time16_y_hot;
154 pixmap = XCreateBitmapFromData (dpy,
155 DefaultRootWindow(dpy), bits,
159 maskPixmap = XCreateBitmapFromData (dpy,
160 DefaultRootWindow(dpy), maskBits,
163 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
164 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
167 DefaultColormapOfScreen(DefaultScreenOfDisplay
170 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
171 &(xcolors[0]), &(xcolors[1]),
173 XFreePixmap (dpy, pixmap);
174 XFreePixmap (dpy, maskPixmap);
180 /*************************************<->*************************************
182 * void TurnOnHourGlass
187 * sets the window cursor to an hourglass
200 * None. (None doesn't count as a comment)
202 *************************************<->***********************************/
203 void TurnOnHourGlass(
208 cursor = GetHourGlassCursor(XtDisplay(w));
210 XDefineCursor(XtDisplay(w), XtWindow(w), cursor);
211 XFlush(XtDisplay(w));
215 /*************************************<->*************************************
217 * void TurnOffHourGlass
222 * Removed the hourglass cursor from a window
235 * None. (None doesn't count as a comment)
237 *************************************<->***********************************/
238 void TurnOffHourGlass(
243 XUndefineCursor(XtDisplay(w), XtWindow(w));
244 XFlush(XtDisplay(w));