🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #37811

Re: Pointer over image?

#37811
From: Heather Rose
Date: Wed, 07 Mar 1990 21:11
82 lines
2899 bytes
In article <1787@gannet.cl.cam.ac.uk> smgf@cl.cam.ac.uk (Steve Freeman) writes:
>I'm beginning work on a system which will need pointers (ie. arrows of
>some sort) which can be moved around over an image and left in place.
>These pointers are not the same as the cursor (ie. mouse) pointer - the
>mouse cursor will be used to drag these pointers around. Anyway, any
>suggestions for a neat way to do this before I have to find one myself?
>I'll be using the HP widget set most likely.

The XView toolkit supplies this functionality already.  Just create a
cursor object from an X11 bitmap and set the new cursor to the window.
Here's an example that creates a cursor from the Sun logo.  Just name
an X11 bitmap file "logo.bm" to compile.  You probably don't want the
Sun logo image file, so I won't waste the bandwidth.

CURSOR_XHOT and CURSOR_YHOT define the hot point for the cursor.  The
XView toolkit is included with the X11R4 distribution.

Regards,

Heather

------------------------

/*
 * simple_cursor.c -- create a cursor (the Sun logo) and
 * assign it to a canvas window.
 */
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/cursor.h>
#include <xview/svrimage.h>

#include "logo.bm"

main(argc, argv)
int argc;
char *argv[];
{
    Frame        frame;
    Canvas       canvas;
    Xv_Cursor    cursor;
    Server_image svr_image;

    xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);

    /*
     * create a server image to use as the cursor's image.
     */
    svr_image = (Server_image)xv_create(XV_NULL, SERVER_IMAGE,
        XV_WIDTH,               logo_width,
        XV_HEIGHT,              logo_height,
        SERVER_IMAGE_X_BITS,    logo_bits,
        NULL);
    /*
     * create a cursor based on the image just created
     */
    cursor = (Xv_Cursor)xv_create(XV_NULL, CURSOR,
        CURSOR_IMAGE,           svr_image,
	CURSOR_XHOT,		32,
	CURSOR_YHOT,		32,
        NULL);

    /*
     * Create a base frame and a canvas
     */
    frame = (Frame)xv_create(XV_NULL, FRAME,
	XV_LABEL,		"Cursor",
	XV_X,			10,
	XV_Y,			10,
        NULL);

    canvas = (Canvas)xv_create(frame, CANVAS,
        XV_WIDTH,               400,
        XV_HEIGHT,              400,
	CANVAS_PAINTWINDOW_ATTRS,
        	WIN_CURSOR,     cursor,
		NULL,
        NULL);

    window_fit(frame);
    window_main_loop(frame);
}
Technical Details
Message-ID: <132646@sun.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!texbell!texsun!newstop!sun!kimba!hvr
References: <1787@gannet.cl.cam.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!texbell!texsun!newstop!sun!kimba!hvr
From: hvr@kimba.Sun.COM (Heather Rose)
Newsgroups: comp.windows.x
Subject: Re: Pointer over image?
Summary: XView custom cursors
Message-ID: <132646@sun.Eng.Sun.COM>
Date: 7 Mar 90 21:11:23 GMT
References: <1787@gannet.cl.cam.ac.uk>
Sender: news@sun.Eng.Sun.COM
Reply-To: hvr@sun.UUCP (Heather Rose)
Organization: Sun Microsystems, Mountain View
Lines: 82