Skip to Main Content
Volume 7A: XView Programming Manual
book

Volume 7A: XView Programming Manual

by Dan Heller
October 1994
Intermediate to advanced content levelIntermediate to advanced
770 pages
22h 58m
English
O'Reilly Media, Inc.
Content preview from Volume 7A: XView Programming Manual
Example 13-2. The hot_spot.c program (continued)
/*
* create_cursor() creates a bull’s eye cursor and assigns it
* to the window (parameter).
*/
create_cursor(window)
Xv_Window window;
{
Xv_Cursor cursor;
Server_image image;
Pixmap pixmap;
Display *dpy = (Display *)xv_get(window, XV_DISPLAY);
GC gc;
XGCValues gcvalues;
image = (Server_image)xv_create(XV_NULL, SERVER_IMAGE,
XV_WIDTH, 16,
XV_HEIGHT, 16,
NULL);
pixmap = (Pixmap)xv_get(image, XV_XID);
/* Create GC with reversed foreground and background colors to
* clear pixmap first. Use 1 and 0 because pixmap is 1-bit deep.
*/
gcvalues.foreground = 0;
gcvalues.background = 1;
gc = XCreateGC(dpy, pixmap, GCForeground|GCBackground, &gcvalues);
XFillRectangle(dpy, pixmap, gc, 0, 0, 16, 16);
/*
* Reset foreground and background values for XDrawArc() routines.
*/
gcvalues.foreground = 1;
gcvalues.background = 0;
XChangeGC(dpy, gc, GCForeground | GCBackground, &gcvalues);
XDrawArc(dpy, pixmap, gc, 2, 2, 12, 12, 0, 360 * 64);
XDrawArc(dpy, pixmap, gc, 6, 6, 4, 4, 0, 360 * 64);
/* Create cursor and assign it to the window (parameter) */
cursor = xv_create(XV_NULL, CURSOR,
CURSOR_IMAGE, image,
CURSOR_XHOT, 7,
CURSOR_YHOT, 7,
NULL);
xv_set(window, WIN_CURSOR, cursor, NULL);
/* free the GC -- the cursor and the image must not be freed. */
XFreeGC(dpy, gc);
}
When the program is running, each time the panel button is pushed, it prints the cursor’s
position relative to the panel’s window ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Volume 6A: Motif Programming Manual

Volume 6A: Motif Programming Manual

David Brennan, Dan Heller, Paula Ferguson
Java™ Media APIs: Cross-Platform Imaging, Media, and Visualization

Java™ Media APIs: Cross-Platform Imaging, Media, and Visualization

Alejandro Terrazas, John Ostuni, Michael Barlow

Publisher Resources

ISBN: 9780937175873