2
* cursors.c -- $Id: cursors.c,v 1.1 2003/03/08 15:26:49 travo Exp $
3
* p_cursor for MS Windows
5
* Copyright (c) 1999. See accompanying LEGAL file for details.
8
/* is this really necessary to get OCR_NORMAL?? (==32512) */
13
/* need to create P_S, P_E, P_W, P_ROTATE, P_DEATH, P_HAND cursors
14
* -- may as well do P_N as well for consistent look
17
* (1) the 326-byte \windows\cursors\*.cur files are 32x32 bitmaps
18
* stored most significant bit first, least significant byte first,
20
* (2) SM_CXCURSOR = SM_CYCURSOR = 32 on my Win95 box
21
* (3) AND mask: 0 where cursor drawn, 1 where not
22
* (4) XOR mask: 0 black/screen, 1 white/invert (where AND bit 0/1)
23
* (5) CreateBitmap documentation states that each scan line
24
* of a bitmap should be word (2-byte) aligned
27
typedef struct w_curshape w_curshape;
30
unsigned char amsk[32], xmsk[32];
33
static w_curshape w_narrow = {
35
{ 0xfe, 0xff, 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x1f,
36
0xe0, 0x0f, 0xe0, 0x0f, 0xf8, 0x3f, 0xf8, 0x3f,
37
0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f,
38
0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f },
39
{ 0x01, 0x00, 0x02, 0x80, 0x04, 0x40, 0x08, 0x20,
40
0x10, 0x10, 0x1d, 0x70, 0x05, 0x40, 0x05, 0x40,
41
0x05, 0x40, 0x05, 0x40, 0x05, 0x40, 0x05, 0x40,
42
0x05, 0x40, 0x05, 0x40, 0x05, 0x40, 0x05, 0x40 } };
44
static w_curshape w_sarrow = {
46
{ 0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f,
47
0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f,
48
0xf8, 0x3f, 0xf8, 0x3f, 0xe0, 0x0f, 0xe0, 0x0f,
49
0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, 0xff },
50
{ 0x05, 0x40, 0x05, 0x40, 0x05, 0x40, 0x05, 0x40,
51
0x05, 0x40, 0x05, 0x40, 0x05, 0x40, 0x05, 0x40,
52
0x05, 0x40, 0x05, 0x40, 0x1d, 0x70, 0x10, 0x10,
53
0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01, 0x00 } };
55
static w_curshape w_earrow = {
57
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf,
58
0xff, 0xc7, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00,
59
0x00, 0x01, 0x00, 0x03, 0xff, 0xc7, 0xff, 0xcf,
60
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
61
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
62
0x00, 0x28, 0xff, 0xe4, 0x00, 0x02, 0xff, 0xe1,
63
0x00, 0x02, 0xff, 0xe4, 0x00, 0x28, 0x00, 0x30,
64
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
66
static w_curshape w_warrow = {
68
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff,
69
0xe3, 0xff, 0xc0, 0x00, 0x80, 0x00, 0x00, 0x00,
70
0x80, 0x00, 0xc0, 0x00, 0xe3, 0xff, 0xf3, 0xff,
71
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
72
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
73
0x14, 0x00, 0x27, 0xff, 0x40, 0x00, 0x87, 0xff,
74
0x40, 0x00, 0x27, 0xff, 0x14, 0x00, 0x0c, 0x00,
75
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
77
static w_curshape w_rotate = {
79
{ 0x38, 0x1f, 0x10, 0x0f, 0x00, 0x07, 0x00, 0x03,
80
0x03, 0xe3, 0x00, 0xf3, 0x00, 0xff, 0x00, 0xff,
81
0xff, 0x00, 0xff, 0x00, 0xcf, 0x80, 0xc7, 0xc0,
82
0xc0, 0x00, 0xe0, 0x00, 0xf0, 0x08, 0xf8, 0x1c },
83
{ 0xc7, 0xe0, 0xa8, 0x10, 0x90, 0x08, 0x83, 0xe4,
84
0xb4, 0x14, 0xb3, 0x0c, 0x81, 0x00, 0xff, 0x00,
85
0x00, 0xff, 0x00, 0x81, 0x30, 0x4d, 0x28, 0x2d,
86
0x27, 0xc1, 0x10, 0x09, 0x08, 0x15, 0x07, 0xe3 } };
88
static w_curshape w_death = {
90
{ 0xf0, 0x3f, 0xe0, 0x1f, 0xc0, 0x0f, 0x80, 0x07,
91
0x80, 0x07, 0xc0, 0x0f, 0xe0, 0x1f, 0x70, 0x3e,
92
0x70, 0x38, 0x30, 0x30, 0x08, 0x63, 0x87, 0x87,
93
0xf8, 0x7f, 0x80, 0x1c, 0x00, 0x00, 0x0f, 0xc1 },
94
{ 0x08, 0x40, 0x10, 0x20, 0x20, 0x10, 0x4c, 0xc8,
95
0x4c, 0xc8, 0x20, 0x10, 0x10, 0x20, 0x88, 0x41,
96
0x08, 0x43, 0x48, 0x49, 0xb4, 0x94, 0x40, 0x08,
97
0x00, 0x00, 0x60, 0x01, 0x0f, 0xc1, 0x70, 0x3a } };
99
static w_curshape w_hand = {
101
{ 0xfe, 0x7f, 0xe4, 0x0f, 0xc0, 0x07, 0xc0, 0x05,
102
0xe0, 0x00, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00,
103
0x00, 0x01, 0x80, 0x01, 0xc0, 0x01, 0xc0, 0x03,
104
0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x07, 0xf8, 0x07 },
105
{ 0x00, 0x00, 0x01, 0x80, 0x19, 0xb0, 0x19, 0xb0,
106
0x0d, 0xb2, 0x0d, 0xb6, 0x17, 0xf6, 0x67, 0xfe,
107
0x77, 0xfc, 0x3f, 0xfc, 0x1f, 0xfc, 0x1f, 0xf8,
108
0x0f, 0xf8, 0x07, 0xf0, 0x03, 0xf0, 0x03, 0xf0 } };
110
static w_curshape *w_curs[7] = {
111
&w_narrow, &w_sarrow, &w_earrow, &w_warrow, &w_rotate, &w_death, &w_hand };
112
static unsigned char *w_cursbits = 0;
124
w_curshape *cs = w_curs[i];
125
int w = GetSystemMetrics(SM_CXCURSOR); /* bits per scan line */
126
int h = GetSystemMetrics(SM_CYCURSOR); /* number of scan lines */
127
int wb = ((w+15)/16)*2; /* number of bytes per scan line */
128
unsigned char *and_msk = w_cursbits, *xor_msk;
131
if (and_msk) HeapFree(GetProcessHeap(), 0, and_msk);
132
w_cursbits = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS,
134
and_msk = w_cursbits;
135
xor_msk = and_msk + wb*h;
136
for (j=k=0 ; j<h ; j++,k+=wb) {
138
for (i=0 ; i<wb ; i++) {
140
and_msk[k+i] = cs->amsk[2*j+i];
141
xor_msk[k+i] = cs->xmsk[2*j+i];
148
for (i=0 ; i<wb ; i++) {
154
c = CreateCursor(w_app_instance, cs->xhot, cs->yhot, w, h,
157
HeapFree(GetProcessHeap(), 0, and_msk);
159
c = LoadCursor(0, IDC_ARROW);
160
/* c = LoadImage(0, MAKEINTRESOURCE(OCR_NORMAL),
161
* IMAGE_CURSOR, 0, 0, LR_DEFAULTCOLOR); */