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/3 1995/11/08 09:18:28 rswiston $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: CDE dthelpdemo sample program.
31 ** Description: This module contains a simple function for
32 ** creating an hourglass cursor.
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
35 ** Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 International Business Machines Corp.
37 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
38 ** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
43 ****************************************************************************
44 ************************************<+>*************************************/
48 #include <X11/Intrinsic.h>
50 #define time32_width 32
51 #define time32_height 32
52 #define time32_x_hot 15
53 #define time32_y_hot 15
54 static unsigned char time32_bits[] = {
55 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
56 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
57 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
58 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
59 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
60 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
61 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
62 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
63 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
64 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
65 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
67 #define time32m_width 32
68 #define time32m_height 32
69 static unsigned char time32m_bits[] = {
70 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
71 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
72 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
73 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
74 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
75 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
76 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
77 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
78 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
79 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
80 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
83 #define time16_x_hot 7
84 #define time16_y_hot 7
85 #define time16_width 16
86 #define time16_height 16
87 static unsigned char time16_bits[] = {
88 0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
89 0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
90 0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
92 #define time16m_width 16
93 #define time16m_height 16
94 static unsigned char time16m_bits[] = {
95 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
96 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
97 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
100 /******** End Public Function Declarations ********/
102 /*************************************<->*************************************
104 * Cursor GetHourGlassCursor ()
109 * Builds and returns the appropriate Hourglass cursor
122 * None. (None doesn't count as a comment)
124 *************************************<->***********************************/
125 static Cursor GetHourGlassCursor(
133 unsigned int xHotspot;
134 unsigned int yHotspot;
140 unsigned int cHeight;
141 int useLargeCursors = 0;
142 static Cursor waitCursor=0;
148 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
149 32, 32, &cWidth, &cHeight))
151 if ((cWidth >= 32) && (cHeight >= 32))
159 width = time32_width;
160 height = time32_height;
161 bits = (char *) time32_bits;
162 maskBits = (char *) time32m_bits;
163 xHotspot = time32_x_hot;
164 yHotspot = time32_y_hot;
168 width = time16_width;
169 height = time16_height;
170 bits = (char *) time16_bits;
171 maskBits = (char *) time16m_bits;
172 xHotspot = time16_x_hot;
173 yHotspot = time16_y_hot;
176 pixmap = XCreateBitmapFromData (dpy,
177 DefaultRootWindow(dpy), bits,
181 maskPixmap = XCreateBitmapFromData (dpy,
182 DefaultRootWindow(dpy), maskBits,
185 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
186 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
189 DefaultColormapOfScreen(DefaultScreenOfDisplay
192 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
193 &(xcolors[0]), &(xcolors[1]),
195 XFreePixmap (dpy, pixmap);
196 XFreePixmap (dpy, maskPixmap);
202 /*************************************<->*************************************
204 * void TurnOnHourGlass
209 * sets the window cursor to an hourglass
222 * None. (None doesn't count as a comment)
224 *************************************<->***********************************/
225 void TurnOnHourGlass(
230 cursor = GetHourGlassCursor(XtDisplay(w));
232 XDefineCursor(XtDisplay(w), XtWindow(w), cursor);
233 XFlush(XtDisplay(w));
237 /*************************************<->*************************************
239 * void TurnOffHourGlass
244 * Removed the hourglass cursor from a window
257 * None. (None doesn't count as a comment)
259 *************************************<->***********************************/
260 void TurnOffHourGlass(
265 XUndefineCursor(XtDisplay(w), XtWindow(w));
266 XFlush(XtDisplay(w));