aboutsummaryrefslogtreecommitdiff
path: root/CURSOR.C
blob: aa731d0ad586828fe618840141a5865dc294a441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*----------------------------------------------------------------------*/
/*  									*/
/*        cursor.c -- Plug in different cursors				*/
/*  									*/
/*----------------------------------------------------------------------*/

#include <system.h>
#include <prism.h>

extern struct Window *mainW;
extern BOOL inside;
extern SHORT curpen;

extern UWORD fillCurs[],crossCurs[],zzz[],size[], pick[];

typedef struct { SHORT w,h,xoffs,yoffs; UWORD *bits; } CursDesc;

CursDesc cursDir[] = { 
    {13,17,7,16, fillCurs},
    {15,15,8,7, crossCurs},
    {16,25,8,12, zzz},
    {8,31,0,0, size},
    {11,43,1,0, pick}
    };

    
static SHORT nullSprite[2] = {0};

SHORT curCursor = DEFCURSOR; 	/* the actual cursor now showing */
SHORT curPaintCursor = DEFCURSOR;  	/* the painting cursor */
SHORT paintCursOn = YES;		/* is the painting cursor showing */

    
/* these ignore the Painting cursor */
HideCursor() { SetPointer(mainW, nullSprite, 0, 0, 0, 0);}
DefaultCursor() {ClearPointer(mainW);}

JamCursor(n) int n; {
    CursDesc *cd = &cursDir[n-2];
    SetPointer(mainW, cd->bits,cd->h,cd->w,-cd->xoffs,-cd->yoffs); 
    }

void SetCursor(n) {
    curCursor = n;
    if (n==NOCURSOR) HideCursor();
    else if (n==DEFCURSOR) DefaultCursor();  else JamCursor(n);
    }
    
/* this affects the Painting cursor */
void SetPaintCursor(n) int n; {
    curPaintCursor = n;
    if (!inside) SetCursor(DEFCURSOR); 
    else SetCursor((paintCursOn||!((n==DEFCURSOR)||(n==CROSSCURSOR)))? n: NOCURSOR);
    }

DefaultPaintCursor() {
    SetPaintCursor( (curpen==USERBRUSH)? DEFCURSOR: CROSSCURSOR);
    }

/* restore cursor to current Paint Cursor state */
ResetCursor() { 
    if ( (curPaintCursor ==DEFCURSOR) || (curPaintCursor == CROSSCURSOR))
	DefaultPaintCursor();
    else SetPaintCursor(curPaintCursor); 
    }

/* Change the Paint Cursor from showing to not or vice versa */
TogCursor() {  paintCursOn = !paintCursOn;  ResetCursor();  }

/* These must work event outside of paint window */

ZZZCursor() {  JamCursor(ZZZCURSOR); }
UnZZZCursor() { SetCursor(curCursor); }