The R Project SVN R

Rev

Rev 45017 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 45017 Rev 76910
Line 49... Line 49...
49
    0x00000000L,
49
    0x00000000L,
50
    0x00FFFFFFL,
50
    0x00FFFFFFL,
51
    0xFFFFFFFFL,
51
    0xFFFFFFFFL,
52
};
52
};
53
 
53
 
54
static byte hand_pixels [] = {
54
static GAbyte hand_pixels [] = {
55
    2,2,2,2,2,2,0,0,0,2,2,2,2,2,2,2,
55
    2,2,2,2,2,2,0,0,0,2,2,2,2,2,2,2,
56
    2,2,2,2,2,0,1,1,0,0,2,2,2,2,2,2,
56
    2,2,2,2,2,0,1,1,0,0,2,2,2,2,2,2,
57
    2,2,2,2,2,0,1,1,0,0,2,2,2,2,2,2,
57
    2,2,2,2,2,0,1,1,0,0,2,2,2,2,2,2,
58
    2,2,2,2,2,0,1,1,0,0,2,2,2,2,2,2,
58
    2,2,2,2,2,0,1,1,0,0,2,2,2,2,2,2,
59
    2,2,2,2,2,0,1,1,0,0,2,2,2,2,2,2,
59
    2,2,2,2,2,0,1,1,0,0,2,2,2,2,2,2,
Line 114... Line 114...
114
}
114
}
115
 
115
 
116
/*
116
/*
117
 *  Public constructors.
117
 *  Public constructors.
118
 */
118
 */
119
cursor createcursor(point offset, byte *white, byte *black)
119
cursor createcursor(point offset, GAbyte *white, GAbyte *black)
120
{
120
{
121
    cursor c;
121
    cursor c;
122
    HCURSOR hc;
122
    HCURSOR hc;
123
    byte *andmask;	/* andmask = ~blackmask & ~whitemask */
123
    GAbyte *andmask;	/* andmask = ~blackmask & ~whitemask */
124
    byte *xormask;	/* xormask = ~blackmask &  whitemask */
124
    GAbyte *xormask;	/* xormask = ~blackmask &  whitemask */
125
    int w, y;
125
    int w, y;
126
    int max_width, max_height, row_bytes;
126
    int max_width, max_height, row_bytes;
127
 
127
 
128
    /* Library cursors: D = (D | whitemask) & ~blackmask */
128
    /* Library cursors: D = (D | whitemask) & ~blackmask */
129
    /* MS-Windows does: D = (D & andmask) ^ xormask */
129
    /* MS-Windows does: D = (D & andmask) ^ xormask */
Line 132... Line 132...
132
    max_width  = GetSystemMetrics(SM_CXCURSOR);
132
    max_width  = GetSystemMetrics(SM_CXCURSOR);
133
    max_height = GetSystemMetrics(SM_CYCURSOR);
133
    max_height = GetSystemMetrics(SM_CYCURSOR);
134
    row_bytes  = (max_width + 7) / 8;
134
    row_bytes  = (max_width + 7) / 8;
135
 
135
 
136
    /* Create the data arrays: */
136
    /* Create the data arrays: */
137
    andmask = array(max_height * row_bytes, byte);
137
    andmask = array(max_height * row_bytes, GAbyte);
138
    xormask = array(max_height * row_bytes, byte);
138
    xormask = array(max_height * row_bytes, GAbyte);
139
 
139
 
140
    /* Assign the data into the arrays: */
140
    /* Assign the data into the arrays: */
141
    for (y=0; y < max_height; y++) {
141
    for (y=0; y < max_height; y++) {
142
	for (w=0; w < row_bytes; w++) {
142
	for (w=0; w < row_bytes; w++) {
143
	    if ((w<2) && (y<16)) {
143
	    if ((w<2) && (y<16)) {
Line 163... Line 163...
163
    discard(xormask);
163
    discard(xormask);
164
 
164
 
165
    return c;
165
    return c;
166
}
166
}
167
 
167
 
168
static byte form_and_byte(image img, int x, int y)
168
static GAbyte form_and_byte(image img, int x, int y)
169
{
169
{
170
    int i;
170
    int i;
171
    rgb pixel;
171
    rgb pixel;
172
    byte result = 0x00;
172
    GAbyte result = 0x00;
173
 
173
 
174
    for (i=0; i<8; i++) {
174
    for (i=0; i<8; i++) {
175
	result <<= 1;
175
	result <<= 1;
176
	pixel = get_monochrome_pixel(img, x+i, y);
176
	pixel = get_monochrome_pixel(img, x+i, y);
177
	if (pixel == Transparent)
177
	if (pixel == Transparent)
178
	    result |= 0x01;
178
	    result |= 0x01;
179
    }
179
    }
180
    return result;
180
    return result;
181
}
181
}
182
 
182
 
183
static byte form_xor_byte(image img, int x, int y)
183
static GAbyte form_xor_byte(image img, int x, int y)
184
{
184
{
185
    int i;
185
    int i;
186
    rgb pixel;
186
    rgb pixel;
187
    byte result = 0x00;
187
    GAbyte result = 0x00;
188
 
188
 
189
    for (i=0; i<8; i++) {
189
    for (i=0; i<8; i++) {
190
	result <<= 1;
190
	result <<= 1;
191
	pixel = get_monochrome_pixel(img, x+i, y);
191
	pixel = get_monochrome_pixel(img, x+i, y);
192
	if (pixel == White)
192
	if (pixel == White)
Line 197... Line 197...
197
 
197
 
198
cursor newcursor(point p, image img)
198
cursor newcursor(point p, image img)
199
{
199
{
200
    cursor c;
200
    cursor c;
201
    HCURSOR hc;
201
    HCURSOR hc;
202
    byte *andmask;
202
    GAbyte *andmask;
203
    byte *xormask;
203
    GAbyte *xormask;
204
    int w, y;
204
    int w, y;
205
    int max_width, max_height, row_bytes;
205
    int max_width, max_height, row_bytes;
206
 
206
 
207
    if (! img) return NULL;
207
    if (! img) return NULL;
208
 
208
 
Line 210... Line 210...
210
    max_width  = GetSystemMetrics(SM_CXCURSOR);
210
    max_width  = GetSystemMetrics(SM_CXCURSOR);
211
    max_height = GetSystemMetrics(SM_CYCURSOR);
211
    max_height = GetSystemMetrics(SM_CYCURSOR);
212
    row_bytes  = (max_width + 7) / 8;
212
    row_bytes  = (max_width + 7) / 8;
213
 
213
 
214
    /* Create the data arrays: */
214
    /* Create the data arrays: */
215
    andmask = array(max_height * row_bytes, byte);
215
    andmask = array(max_height * row_bytes, GAbyte);
216
    xormask = array(max_height * row_bytes, byte);
216
    xormask = array(max_height * row_bytes, GAbyte);
217
 
217
 
218
    /* Assign the data into the arrays: */
218
    /* Assign the data into the arrays: */
219
    for (y=0; y < max_height; y++) {
219
    for (y=0; y < max_height; y++) {
220
	for (w=0; w < row_bytes; w++) {
220
	for (w=0; w < row_bytes; w++) {
221
	    andmask[w+y*row_bytes] = form_and_byte(img, w*8, y);
221
	    andmask[w+y*row_bytes] = form_and_byte(img, w*8, y);