Article # 243, added by Geoworks, historical record
| first | previous | index | next | last |

How to set mouse pointer images




There are several ways to set the pointer image for the mouse.  Which
one you use will depend on what you are trying to do.  In a nutshell,
the options are:
 1. Set the busy/wait cursor with MARK_BUSY messages
 2. Drag/drop cursor
 2. Specify an image while the cursor is over a GenViewClass object
 3. Specify an image while the cursor is over any given object

1. Setting the busy/wait cursor:
The system puts up a busy cursor whenever MSG_GEN_SYSTEM_MARK_BUSY or
MSG_GEN_APPLICATION_MARK_BUSY is sent.  The busy cursor is cancelled
with MSG_GEN_APPLICATION_MARK_NOT_BUSY and MSG_GEN_SYSTEM_MARK_NOT_BUSY.

2. You can set the cursor to the standard drag and drop images by
calling ClipboardSetQuickTransferFeedback() or initiating a clipboard
action with ClipboardStartQuickTransfer().  ClipboardEndQuickTransfer()
will reset the image.

3. Specify point image to display in GenViewClass object.  
Send MSG_GEN_VIEW_SET_PTR_IMAGE to the object.  See Defining A Cursor 
Image and Mask below.

4. Specify image for an object
One can change the cursor when handling mouse messages.  Each of the
mouse message's MouseReturnParams *retVal structure can take an optr
to a new cursor image, if retVal->flags includes MRF_SET_POINTER_IMAGE.
Generally, if you are handling the mouse message, you will want to
return
	retVal->flags = MRF_PROCESSED | MRF_SET_POINTER_IMAGE;

To reset the default pointer image, use MRF_CLEAR_POINTER_IMAGE.

See Defining A Cursor Image and Mask below.


Defining A Cursor Image and Mask
--------------------------------
To define a cursor image and mask, use the PointerDef16, PointerDef32, 
or PointerDef64 structures which are defined in graphics.h.  Here is
an example of a simple cross using the most common pointer size:

@chunk PointerDef16 CrossHair = {
	16, /* pointer width */
	16, /* pointer height */
	8,  /* X offset to hot spot from left */
	8,  /* Y offset to hot spot from top of image */
	/* PD_mask */
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	0x00, 0x00,
	/* PD_image */
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0xFF, 0xFF,
	0xFF, 0xFF,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80,
	0x01, 0x80 };

The picture data for the pointer is organized as two buffers
that immediately follow the PointerDef structure.  The first buffer
is the mask, the second buffer is the image.  Each buffer is 
organized in scan line order, left to right and top to bottom.  
The bits in the mask and image combine with the existing screen 
contents in the following way:

		mask	image	->	screen
		pixel	pixel		pixel
		-----	-----		------
		  0	  0		unchanged
		  0	  1		xor
		  1	  0		black
		  1	  1		white