A big cursor?

Tom Mackey tomm at voodoo.UUCP
Fri Jan 4 10:06:25 AEST 1991


>
>I will be videotaping my program, so I'd like to make things bigger so they
>can be seen on the (poor quality) VHS tapesthat they ultimately will be dubbed
>to. 
>I can scale eveything in my program up a bit without much problem. I also
>would like to make the cursor big too.
>
>Defining a 32x32 bitmap cursor that looks like the standard arrow (except
>bigger) shouldn't be that hard, just a hassle to draw all the little dots and
>encode them. I was wondering though, if anyone done it already? Could you
>please send me the code? Does anyone have a cursor editing tool?
>
>Thanks,
>
>	Mike

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

    Wotdahell......  I got the basic idea from the net, so now its
    payback time.               -TomM-

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

/**********************************************************************\
*                                                                      *
*  FILE:  bit_defs.h                                                   *
*                                                                      *
*  DESCRIPTION:  include file containing defines for binary constants  *
*                                                                      *
\**********************************************************************/
#ifndef BIT_DEFS_H
#define BIT_DEFS_H

#ifndef lint
#ifdef RCS_INFO
static char RCS_bit_defs_h[] = "\
$Source: RCS/bit_defs.h,v $\
$Revision: 5.1 $\
$Date: 90/08/28 09:54:38 $\
$State: Exp $";
#endif RCS_INFO
#endif lint

#define	___	((((((((((((((((((((((((((((((((0
#define	__	((((((((((((((((0
#define _	<<1|0)
#define X	<<1|1)

/*
** These clever defines were found somewhere on UseNet sometime
** in 1987.  They provide an easy way to "see" what your patterns
** look like by making them human visible ascii patterns.  The
** usual approach is to use hex definitions which are hard to
** visualize.  The defines make the c-preprocessor do the hard work
** for you.  For each line you define a zero prefaced with a bunch
** of open-parens; then you give a series of left-shift-and-OR-with
** -zero-or-one-close-parens which define a hex value.  For example,
** here is how you would build a sailboat pattern.
**
**	static
**	Cursor	sailboat =
**		{
**		    __		_ _ _ _ _ _ X _ _ _ _ _ _ _ _ _		,
**		    __		_ _ _ _ _ _ X X _ _ _ _ _ _ _ _		,
**		    __		_ _ _ _ _ _ X _ X _ _ _ _ _ _ _		,
**		    __		_ _ _ _ _ _ X _ X _ _ _ _ _ _ _		,
**		    __		_ _ _ _ _ X X _ _ X _ _ _ _ _ _		,
**		    __		_ _ _ _ X _ X _ _ X _ _ _ _ _ _		,
**		    __		_ _ _ _ X _ X _ _ _ X _ _ _ _ _		,
**		    __		_ _ _ X _ _ X _ _ _ X _ _ _ _ _		,
**		    __		_ _ _ X _ _ X _ _ _ _ X _ _ _ _		,
**		    __		_ _ X _ _ _ X _ _ _ _ X _ _ _ _		,
**		    __		_ _ X _ _ _ X _ _ _ _ _ X _ _ _		,
**		    __		X X X X X X X X X X X X X X _ _		,
**		    __		_ _ X _ _ _ X _ _ _ _ _ _ X X _		,
**		    __		_ _ X X _ _ _ _ _ _ _ _ _ _ X _		,
**		    __		_ _ _ X X _ _ _ _ _ _ _ _ _ X _		,
**		    __		_ _ _ _ X X X X X X X X X X _ _
**		};
**
** The second line would really look like this:
**	((((((((((((((((0<<1|0)<<1|0)<<1|0)<<1|0)<<1|0)<<1|0)<<1|1) \
**           <<1|1)<<1|0)<<1|0)<<1|0)<<1|0)<<1|0)<<1|0)<<1|0)<<1|0) ,
**
** which is the hex value 0x0300
**
** Usually, working directly in an editor is good enough, but for
** tricky glyphs, you might want to work on graph paper first.
**
** One more thing:  These define the rows of the pattern in reverse
** order, and so will appear upside-down.  You can either build your
** patterns upside down, or use the flip_C16X1() and flip_C16X2()
** functions to flip your creations automagically.  These two functions
** are defined in the file cursors.c
**					-TomM- (tomm at voodoo.boeing.com)
*/

#endif BIT_DEFS_H

/**********************************************************************\
*                                                                      *
*  FILE:  cursors.c                                                    *
*                                                                      *
*  DESCRIPTION: Implementation file for cursor creation routines       *
*                                                                      *
\**********************************************************************/
#ifndef lint
#ifdef RCS_INFO
static char RCSinfo[] = "\
$Source: RCS/cursors.c,v $\
$Revision: 5.2 $\
$Date: 90/08/28 11:27:00 $\
$State: Exp $";
#endif RCS_INFO

#endif lint

#include <device.h>
#include <gl.h>

void flip_C16X1(c_array)
unsigned short	 c_array[][16];
{
    register
    int		 i, j;

    unsigned short tmp_array[1][16];

    for (i=0; i<16; i++)
	tmp_array[0][i] = c_array[0][i];

    j = 15;
    for (i=0; i<16; i++)
    {
	c_array[0][i] = tmp_array[0][j];
	j--;
    }
}

void flip_C16X2(c_array)
unsigned short	 c_array[][16];
{
    register
    int		 h, i, j;

    unsigned short tmp_array[2][16];

    for (h=0; h<2; h++)
    {
	for (i=0; i<16; i++)
	{
	    tmp_array[h][i] = c_array[h][i];
	}
    }

    for (h=0; h<2; h++)
    {
	j = 15;
	for (i=0; i<16; i++)
	{
	    c_array[h][i] = tmp_array[h][j];
	    j--;
	}
    }
}

/*
** flip_C32X[12] left as an excercise for the reader!
*/

/*************************************************************************\
*                                                                         *
*  FILE:  cursors.h                                                       *
*                                                                         *
*  DESCRIPTION:  include file containing cursor pattern definitions       *
*                This should give a good start to your own creative       *
*                flights of fantasy.  Note that the multi-color           *
*                cursors are useless on the 4D-2x series :-(              *
*                                                                         *
*  I'll take the credit, you take the blame! tomm at voodoo.boeing.com  ;^)  *
*                                                                         *
\*************************************************************************/
#ifndef CURSORS_H
#define CURSORS_H

#ifndef lint
#ifdef RCS_INFO
static char RCS_cursors_h[] = "\
$Source: RCS/cursors.h,v $\
$Revision: 5.2 $\
$Date: 90/11/27 11:56:10 $\
$State: Exp $";
#endif RCS_INFO
#endif lint

#include <device.h>
#include <gl.h>
#include "bit_defs.h"

extern	void		 flip_C16X1();
extern	void		 flip_C16X2();

/*
** The following pattern definitions must be flipped 180 degrees to
** provide proper input to defcursor().  Use either flip_C16X1() or
** filp_C16X2() to flip the cursor array from its visual orientation
** to the proper input orientation.
*/

static
unsigned short	cir_target[2][16] =	/* RED border, YELLOW target */
	{						/* 1's bits RED */
	    __		_ _ _ _ _ X X X X X _ _ _ _ _ _		,
	    __		_ _ _ X X X X X X X X X _ _ _ _		,
	    __		_ _ X X X _ _ _ _ _ X X X _ _ _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ X X _ _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ X X _ _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ X X _ _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ X X _ _		,
	    __		_ _ X X X _ _ _ _ _ X X X _ _ _		,
	    __		_ _ _ X X X X X X X X X _ _ _ _		,
	    __		_ _ _ _ _ X X X X X _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,

							/* 2's bits YELLOW */
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ X X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
	};

static
unsigned short	x_target_1[1][16] =
	{
	    __		_ _ _ X X X X X X X X X _ _ _ _		,
	    __		_ _ _ _ X X X X X X X _ _ _ _ _		,
	    __		_ _ _ _ _ X X X X X _ _ _ _ _ _		,
	    __		X _ _ _ _ _ X X X _ _ _ _ _ X _		,
	    __		X X _ _ _ _ _ X _ _ _ _ _ X X _		,
	    __		X X X _ _ _ _ _ _ _ _ _ X X X _		,
	    __		X X X X _ _ _ _ _ _ _ X X X X _		,
	    __		X X X X X _ _ _ _ _ X X X X X _		,
	    __		X X X X _ _ _ _ _ _ _ X X X X _		,
	    __		X X X _ _ _ _ _ _ _ _ _ X X X _		,
	    __		X X _ _ _ _ _ X _ _ _ _ _ X X _		,
	    __		X _ _ _ _ _ X X X _ _ _ _ _ X _		,
	    __		_ _ _ _ _ X X X X X _ _ _ _ _ _		,
	    __		_ _ _ _ X X X X X X X _ _ _ _ _		,
	    __		_ _ _ X X X X X X X X X _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
	};


static
unsigned short	clock[1][16] =
	{
	    __		_ _ _ _ _ X X X X X X _ _ _ _ _		,
	    __		_ _ _ X X _ _ _ _ _ _ X X _ _ _		,
	    __		_ _ X X _ _ _ X X _ _ _ X X _ _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		_ X _ _ _ _ _ _ _ _ _ _ _ _ X _		,
	    __		X _ _ _ _ X _ _ _ _ _ _ _ _ _ X		,
	    __		X _ _ _ _ _ X _ _ _ _ _ _ _ _ X		,
	    __		X _ X _ _ _ _ X X _ _ _ _ X _ X		,
	    __		X _ X _ _ _ _ X X _ _ _ _ X _ X		,
	    __		X _ _ _ _ _ _ _ X _ _ _ _ _ _ X		,
	    __		X _ _ _ _ _ _ _ _ X _ _ _ _ _ X		,
	    __		_ X _ _ _ _ _ _ _ X _ _ _ _ X _		,
	    __		_ X X _ _ _ _ _ _ _ X _ _ X X _		,
	    __		_ _ X X _ _ _ X X _ X _ X X _ _		,
	    __		_ _ _ X X _ _ _ _ _ _ X X _ _ _		,
	    __		_ _ _ _ _ X X X X X X _ _ _ _ _
	};

static
unsigned short	hourglass[2][16] =	  /* RED hourglass, YELLOW sand */
	{						/* 1's bits RED */
	    __		_ X X X X X X X X X X X X X _ _		,
	    __		_ X X X X X X X X X X X X X _ _		,
	    __		_ _ _ X X _ _ _ _ _ X X _ _ _ _		,
	    __		_ _ _ X X _ _ _ _ _ X X _ _ _ _		,
	    __		_ _ _ X X _ _ _ _ _ X X _ _ _ _		,
	    __		_ _ _ X X X _ _ _ X X X _ _ _ _		,
	    __		_ _ _ _ _ X X _ X X _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ X X _ X X _ _ _ _ _ _		,
	    __		_ _ _ X X X _ _ _ X X X _ _ _ _		,
	    __		_ _ _ X X _ _ _ _ _ X X _ _ _ _		,
	    __		_ _ _ X X _ _ _ _ _ X X _ _ _ _		,
	    __		_ _ _ X X _ _ _ _ _ X X _ _ _ _		,
	    __		_ X X X X X X X X X X X X X _ _		,
	    __		_ X X X X X X X X X X X X X _ _		,
							/* 2's bits YELLOW */
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ X X _ X X _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ X X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
	};

static
unsigned short	martini[2][16] =	   /* RED swizzle, YELLOW glass */
	{						/* 1's bits RED */
	    __		X _ _ _ _ _ _ _ _ _ _ _ _ _ _ X		,
	    __		_ X _ _ _ _ _ _ _ _ _ _ _ _ X _		,
	    __		_ _ X X X X X X X _ _ X X X _ _		,
	    __		_ _ _ X _ _ _ _ _ _ _ _ X _ _ _		,
	    __		_ _ _ _ X _ _ _ _ _ _ X _ _ _ _		,
	    __		_ _ _ _ _ X _ _ _ _ X _ _ _ _ _		,
	    __		_ _ _ _ _ _ X _ _ X _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ X X _ _ _ _ _ _ _		,
	    __		_ _ _ X X X X X X X X X X _ _ _		,
							/* 2's bits YELLOW */
	    __		_ _ _ _ _ _ _ _ _ _ _ X _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ X _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ X _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ X X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ X X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
	};

static
unsigned short	coffee_cup[1][16] =
	{
	    __		_ _ _ _ X _ _ X _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ X _ _ X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ X _ _ X _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ X _ _ X _ _ _ _ _ _		,
	    __		_ _ _ _ X X X X X X _ _ _ _ _ _		,
	    __		_ _ X X _ X _ _ X _ X X _ _ _ _		,
	    __		_ X _ _ _ X _ _ X _ _ _ X _ X _		,
	    __		_ X _ _ _ _ _ _ _ _ _ _ X X _ X		,
	    __		_ X X X _ _ _ _ _ _ X X X _ _ X		,
	    __		_ X _ _ X X X X X X _ _ X _ _ X		,
	    __		_ _ X _ _ _ _ _ _ _ _ X _ _ _ X		,
	    __		_ _ X _ _ _ _ _ _ _ _ X _ _ X _		,
	    __		_ _ X _ _ _ _ _ _ _ _ X _ X _ _		,
	    __		_ _ X _ _ _ _ _ _ _ _ X X _ _ _		,
	    __		_ _ X X _ _ _ _ _ _ X X _ _ _ _		,
	    __		_ _ _ _ X X X X X X _ _ _ _ _ _
	};


static
unsigned short	circle_dot[1][16] =
	{
	    __		_ _ _ _ _ X X X X X _ _ _ _ _ _		,
	    __		_ _ _ X X X X X X X X X _ _ _ _		,
	    __		_ _ X X X _ _ _ _ _ X X X _ _ _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ X X _ _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ X X _ _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		X X _ _ _ _ _ X _ _ _ _ _ X X _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		X X _ _ _ _ _ _ _ _ _ _ _ X X _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ X X _ _		,
	    __		_ X X _ _ _ _ _ _ _ _ _ X X _ _		,
	    __		_ _ X X X _ _ _ _ _ X X X _ _ _		,
	    __		_ _ _ X X X X X X X X X _ _ _ _		,
	    __		_ _ _ _ _ X X X X X _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
	};


static
unsigned short	blank[1][16] =
	{
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _		,
	    __		_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
	};


#endif CURSORS_H

    --------- Then you do something like this somewhere --------
    _________ in your initialization routines.          --------

#include "cursors.h"

void map_cursor_colors()
{
    mapcolor(1, 255,   0,   0);	/* RED */
    mapcolor(2, 255, 255,   0);	/* YELLOW */
    mapcolor(3,   0,   0, 255);	/* BLUE */
}

void
init_cursors()
{
    long	saved_mode;

    saved_mode = getdrawmode();
    drawmode(CURSORDRAW);

    map_cursor_colors();

    curstype(C16X2);

    flip_C16X2(cir_target);
    defcursor(1, cir_target);
    curorigin(1, 7, 8);

    flip_C16X2(hourglass);
    defcursor(2, hourglass);
    curorigin(2, 7, 7);

    flip_C16X2(martini);
    defcursor(3, martini);
    curorigin(3, 7, 8);

    curstype(C16X1);

    flip_C16X1(x_target_1);
    defcursor(4, x_target_1);
    curorigin(4, 7, 8);

    flip_C16X1(clock);
    defcursor(5, clock);
    curorigin(5, 7, 8);

    flip_C16X1(coffee_cup);
    defcursor(6, coffee_cup);
    curorigin(6, 7, 7);

    flip_C16X1(circle_dot);
    defcursor(7, circle_dot);
    curorigin(7, 7, 8);

    defcursor(8, blank);
    curorigin(8, 7, 8);

    drawmode(saved_mode);
}
-- 
Tom Mackey       (206) 865-6575        tomm at voodoo.boeing.com
Boeing Computer Services         ....uunet!bcstec!voodoo!tomm
M/S 7K-20,     P.O. Box 24346,     Seattle, WA     98124-0346



More information about the Comp.sys.sgi mailing list