/* * COPYRIGHT NOTICE * Copyright (c), Integrated Computer Solutions 1989-1997 * * hourCursor.c - routines to put up an hourglass cursor */ #include #include #include /****************************************************************************** * DEFINES ******************************************************************************/ /****************************************************************************** * STATIC FUNCS ******************************************************************************/ /****************************************************************************** * EXTERNS ******************************************************************************/ /**************************************************************************** * STATIC DATA ****************************************************************************/ #define time32_width 32 #define time32_height 32 static unsigned char time32_bits[] = { 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30, 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30, 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30, 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32, 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32, 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00}; #define time32m_width 32 #define time32m_height 32 static unsigned char time32m_bits[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70, 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70, 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70, 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76, 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76, 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; #define time16_width 16 #define time16_height 16 static unsigned char time16_bits[] = { 0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24, 0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28, 0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00}; #define time16m_width 16 #define time16m_height 16 static unsigned char time16m_bits[] = { 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff}; /***************************************************************************** * FUNCTIONS *****************************************************************************/ /* Function Name: * HourGlass_SetShellCursor(widget, busy) * Description: * Set the time cursor on a shell widget. * Arguments: * widget-Widget:do it to this one. * busy - Boolean : define watch cursor or undefine it. * Returns: * NONE. */ void HourGlass_SetShellCursor(Widget shell, Boolean busy) { static Cursor cursor=(Cursor)0; /* cursor to set */ /* Weed out the bad. */ if (shell == NULL || !XtIsRealized(shell)) return; if( busy ) { /* Create the cursor if we need to. */ if(cursor == (Cursor)0) { /* * cursor = XCreateFontCursor(XtDisplay(shell), XC_watch); */ Cardinal ac; Arg args[5]; Screen *screen; Colormap cmap; Pixmap source, mask; XColor fg, bg; unsigned int width, height; char *data, *maskData; XQueryBestCursor(XtDisplay(shell), XtWindow(shell), time32_width, time32_height, &width, &height); if(width >= time32_width && height >= time32_height) { width = time32_width; height = time32_height; data = (char *)time32_bits; maskData = (char *)time32m_bits; } else { width = time16_width; height = time16_height; data = (char *)time16_bits; maskData = (char *)time16m_bits; } ac = 0; XtSetArg(args[ac], XmNscreen, &screen); ac++; XtSetArg(args[ac], XmNcolormap, &cmap); ac++; XtGetValues(shell, args, ac); source = XCreateBitmapFromData(XtDisplay(shell), XtWindow(shell), data, width, height); mask = XCreateBitmapFromData(XtDisplay(shell), XtWindow(shell), maskData, width, height); fg.pixel = XBlackPixelOfScreen(screen); bg.pixel = XWhitePixelOfScreen(screen); XQueryColor(XtDisplay(shell), cmap, &fg); XQueryColor(XtDisplay(shell), cmap, &bg); cursor = XCreatePixmapCursor(XtDisplay(shell), source, mask, &fg, &bg, width/2, height/2); } /* Really set it. */ XDefineCursor(XtDisplay(shell), XtWindow(shell), cursor); } else { XUndefineCursor(XtDisplay(shell), XtWindow(shell)); } } /* Function Name: * HourGlass_SetShellCursorHierarchy(widget, busy) * Description: * Set the time cursor across a hierarcy of widgets. * Arguments: * widget-Widget:the shell from which to start. * busy - Boolean : define or undefine. * Returns: * NONE. */ void HourGlass_SetShellCursorHierarchy(Widget widget, Boolean busy) { WidgetList children; /* kids */ Cardinal num; /* count of */ int i; /* loop index */ if (widget == NULL) return; if ( XtIsComposite(widget) ) { Arg args[10]; Cardinal ac; num = ac = 0; XtSetArg(args[ac], XmNchildren, &children); ac++; XtSetArg(args[ac], XmNnumChildren, &num); ac++; XtGetValues(widget, args, ac); for (i = 0; i < num ; i++ ) { HourGlass_SetShellCursorHierarchy(children[i], busy); } } /* Now go thru popups. */ if( XtIsWidget(widget)) { children = ((WidgetRec*)widget)->core.popup_list; num = ((WidgetRec*)widget)->core.num_popups; for( i = 0; i < num; i++ ) { HourGlass_SetShellCursorHierarchy(children[i], busy); } } /* Now actually set the cursor. */ if(XtIsShell(widget)) { HourGlass_SetShellCursor(widget, busy); } }