annotate test/testcursor.c @ 4495:dbbfdb9ea716

Simplified clipboard API for sanity's sake. A complete clipboard implementation would support multiple formats that could be queried at runtime, events for when the clipboard contents changed, support for HTML, images, etc. We're not going that crazy, at least for now. :)
author Sam Lantinga <slouken@libsdl.org>
date Wed, 07 Jul 2010 23:54:03 -0700
parents 14d32495a502
children
rev   line source
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1 #include <stdio.h>
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
2 #include <stdlib.h>
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
3
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
4 #include "SDL.h"
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
5
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
6 /* This is an example 16x16 cursor
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
7 top left : black
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
8 top right : inverted color or black
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
9 bottom left: white
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
10 bottom right: transparent
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
11 (swap left and right for different endianness)
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
12 */
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
13
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
14 Uint16 cursor_data[16] = {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
15 0xffff,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
16 0xffff,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
17 0xffff,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
18 0xffff,
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
19
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
20 0xffff,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
21 0xffff,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
22 0xffff,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
23 0xffff,
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
24
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
25 0x0000,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
26 0x0000,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
27 0x0000,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
28 0x0000,
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
29
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
30 0x0000,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
31 0x0000,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
32 0x0000,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
33 0x0000
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
34 };
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
35
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
36 Uint16 cursor_mask[16] = {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
37 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
38 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
39 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
40 0xff00,
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
41
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
42 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
43 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
44 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
45 0xff00,
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
46
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
47 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
48 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
49 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
50 0xff00,
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
51
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
52 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
53 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
54 0xff00,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
55 0xff00
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
56 };
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
57
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1862
diff changeset
58 /* another test cursor: smaller than 16x16, and with an odd height */
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1862
diff changeset
59
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
60 Uint8 small_cursor_data[11] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
61 { 0x00, 0x18, 0x08, 0x38, 0x44, 0x54, 0x44, 0x38, 0x20, 0x20, 0x00 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
62 Uint8 small_cursor_mask[11] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
63 { 0x3C, 0x3C, 0x3C, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x78, 0x70, 0x70 };
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
64
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
65 /* XPM */
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
66 static const char *arrow[] = {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
67 /* width height num_colors chars_per_pixel */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
68 " 32 32 3 1",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
69 /* colors */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
70 "X c #000000",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
71 ". c #ffffff",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
72 " c None",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
73 /* pixels */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
74 "X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
75 "XX ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
76 "X.X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
77 "X..X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
78 "X...X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
79 "X....X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
80 "X.....X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
81 "X......X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
82 "X.......X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
83 "X........X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
84 "X.....XXXXX ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
85 "X..X..X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
86 "X.X X..X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
87 "XX X..X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
88 "X X..X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
89 " X..X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
90 " X..X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
91 " X..X ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
92 " XX ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
93 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
94 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
95 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
96 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
97 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
98 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
99 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
100 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
101 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
102 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
103 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
104 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
105 " ",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
106 "0,0"
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
107 };
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
108
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
109 static SDL_Cursor *
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
110 create_arrow_cursor()
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
111 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
112 int i, row, col;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
113 Uint8 data[4 * 32];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
114 Uint8 mask[4 * 32];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
115 int hot_x, hot_y;
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
116
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
117 i = -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
118 for (row = 0; row < 32; ++row) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
119 for (col = 0; col < 32; ++col) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
120 if (col % 8) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
121 data[i] <<= 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
122 mask[i] <<= 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
123 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
124 ++i;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
125 data[i] = mask[i] = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
126 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
127 switch (arrow[4 + row][col]) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
128 case 'X':
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
129 data[i] |= 0x01;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
130 mask[i] |= 0x01;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
131 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
132 case '.':
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
133 mask[i] |= 0x01;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
134 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
135 case ' ':
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
136 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
137 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
138 }
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
139 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
140 sscanf(arrow[4 + row], "%d,%d", &hot_x, &hot_y);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
141 return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
142 }
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
143
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
144
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
145 int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
146 main(int argc, char *argv[])
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
147 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
148 SDL_Surface *screen;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
149 SDL_bool quit = SDL_FALSE, first_time = SDL_TRUE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
150 SDL_Cursor *cursor[3];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
151 int current;
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
152
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
153 /* Load the SDL library */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
154 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
155 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
156 return (1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
157 }
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
158
3111
14d32495a502 Default video mode has been changed from 320x200 to 640x480, since fullscreen 320x200 is often unavailable.
Mike Gorchak <lestat@i.com.ua>
parents: 2088
diff changeset
159 screen = SDL_SetVideoMode(640, 480, 8, SDL_ANYFORMAT);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
160 if (screen == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
161 fprintf(stderr, "Couldn't initialize video mode: %s\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
162 SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
163 return (1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
164 }
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
165
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
166 SDL_FillRect(screen, NULL, 0x664422);
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
167
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
168 cursor[0] = SDL_CreateCursor((Uint8 *) cursor_data, (Uint8 *) cursor_mask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
169 16, 16, 8, 8);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
170 if (cursor[0] == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
171 fprintf(stderr, "Couldn't initialize test cursor: %s\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
172 SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
173 SDL_Quit();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
174 return (1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
175 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
176 cursor[1] = create_arrow_cursor();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
177 if (cursor[1] == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
178 fprintf(stderr, "Couldn't initialize arrow cursor: %s\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
179 SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
180 SDL_FreeCursor(cursor[0]);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
181 SDL_Quit();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
182 return (1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
183 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
184 cursor[2] = SDL_CreateCursor(small_cursor_data, small_cursor_mask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
185 8, 11, 3, 5);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
186 if (cursor[2] == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
187 fprintf(stderr, "Couldn't initialize test cursor: %s\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
188 SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
189 SDL_Quit();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
190 return (1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
191 }
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
192
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
193 current = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
194 SDL_SetCursor(cursor[current]);
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
195
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
196 while (!quit) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
197 SDL_Event event;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
198 while (SDL_PollEvent(&event)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
199 switch (event.type) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
200 case SDL_MOUSEBUTTONDOWN:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
201 current = (current + 1) % 3;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
202 SDL_SetCursor(cursor[current]);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
203 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
204 case SDL_KEYDOWN:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
205 if (event.key.keysym.sym == SDLK_ESCAPE) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
206 quit = SDL_TRUE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
207 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
208 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
209 case SDL_QUIT:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
210 quit = SDL_TRUE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
211 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
212 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
213 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
214 SDL_Flip(screen);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
215 SDL_Delay(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
216 }
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
217
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
218 SDL_FreeCursor(cursor[0]);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
219 SDL_FreeCursor(cursor[1]);
2088
3bdb1408f734 Merged r2960:2961 from branches/SDL-1.2...free all cursors in test/testcursor.c
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
220 SDL_FreeCursor(cursor[2]);
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
221
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
222 SDL_Quit();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
223 return (0);
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
224 }