Mercurial > sdl-ios-xcode
annotate docs/html/sdlcreatecursor.html @ 537:77b05010bb33
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 09 Nov 2002 05:51:13 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_CreateCursor</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="Video" | |
14 HREF="video.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_WarpMouse" | |
17 HREF="sdlwarpmouse.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_FreeCursor" | |
20 HREF="sdlfreecursor.html"></HEAD | |
21 ><BODY | |
22 CLASS="REFENTRY" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 WIDTH="100%" | |
32 BORDER="0" | |
33 CELLPADDING="0" | |
34 CELLSPACING="0" | |
35 ><TR | |
36 ><TH | |
37 COLSPAN="3" | |
38 ALIGN="center" | |
39 >SDL Library Documentation</TH | |
40 ></TR | |
41 ><TR | |
42 ><TD | |
43 WIDTH="10%" | |
44 ALIGN="left" | |
45 VALIGN="bottom" | |
46 ><A | |
47 HREF="sdlwarpmouse.html" | |
48 >Prev</A | |
49 ></TD | |
50 ><TD | |
51 WIDTH="80%" | |
52 ALIGN="center" | |
53 VALIGN="bottom" | |
54 ></TD | |
55 ><TD | |
56 WIDTH="10%" | |
57 ALIGN="right" | |
58 VALIGN="bottom" | |
59 ><A | |
60 HREF="sdlfreecursor.html" | |
61 >Next</A | |
62 ></TD | |
63 ></TR | |
64 ></TABLE | |
65 ><HR | |
66 ALIGN="LEFT" | |
67 WIDTH="100%"></DIV | |
68 ><H1 | |
69 ><A | |
70 NAME="SDLCREATECURSOR" | |
71 >SDL_CreateCursor</A | |
72 ></H1 | |
73 ><DIV | |
74 CLASS="REFNAMEDIV" | |
75 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
76 NAME="AEN2103" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_CreateCursor -- Creates a new mouse cursor.</DIV | |
81 ><DIV | |
82 CLASS="REFSYNOPSISDIV" | |
83 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
84 NAME="AEN2106" |
0 | 85 ></A |
86 ><H2 | |
87 >Synopsis</H2 | |
88 ><DIV | |
89 CLASS="FUNCSYNOPSIS" | |
90 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
91 NAME="AEN2107" |
0 | 92 ></A |
93 ><P | |
94 ></P | |
95 ><PRE | |
96 CLASS="FUNCSYNOPSISINFO" | |
97 >#include "SDL.h"</PRE | |
98 ><P | |
99 ><CODE | |
100 ><CODE | |
101 CLASS="FUNCDEF" | |
102 >SDL_Cursor *<B | |
103 CLASS="FSFUNC" | |
104 >SDL_CreateCursor</B | |
105 ></CODE | |
106 >(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);</CODE | |
107 ></P | |
108 ><P | |
109 ></P | |
110 ></DIV | |
111 ></DIV | |
112 ><DIV | |
113 CLASS="REFSECT1" | |
114 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
115 NAME="AEN2113" |
0 | 116 ></A |
117 ><H2 | |
118 >Description</H2 | |
119 ><P | |
120 >Create a cursor using the specified <TT | |
121 CLASS="PARAMETER" | |
122 ><I | |
123 >data</I | |
124 ></TT | |
125 > and <TT | |
126 CLASS="PARAMETER" | |
127 ><I | |
128 >mask</I | |
129 ></TT | |
130 > (in MSB format). | |
131 The cursor width must be a multiple of 8 bits.</P | |
132 ><P | |
133 >The cursor is created in black and white according to the following: | |
134 <DIV | |
135 CLASS="INFORMALTABLE" | |
136 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
137 NAME="AEN2119" |
0 | 138 ></A |
139 ><P | |
140 ></P | |
141 ><TABLE | |
142 BORDER="1" | |
143 CLASS="CALSTABLE" | |
144 ><THEAD | |
145 ><TR | |
146 ><TH | |
147 ALIGN="LEFT" | |
148 VALIGN="TOP" | |
149 >Data / Mask</TH | |
150 ><TH | |
151 ALIGN="LEFT" | |
152 VALIGN="TOP" | |
153 >Resulting pixel on screen</TH | |
154 ></TR | |
155 ></THEAD | |
156 ><TBODY | |
157 ><TR | |
158 ><TD | |
159 ALIGN="LEFT" | |
160 VALIGN="TOP" | |
161 >0 / 1</TD | |
162 ><TD | |
163 ALIGN="LEFT" | |
164 VALIGN="TOP" | |
165 >White</TD | |
166 ></TR | |
167 ><TR | |
168 ><TD | |
169 ALIGN="LEFT" | |
170 VALIGN="TOP" | |
171 >1 / 1</TD | |
172 ><TD | |
173 ALIGN="LEFT" | |
174 VALIGN="TOP" | |
175 >Black</TD | |
176 ></TR | |
177 ><TR | |
178 ><TD | |
179 ALIGN="LEFT" | |
180 VALIGN="TOP" | |
181 >0 / 0</TD | |
182 ><TD | |
183 ALIGN="LEFT" | |
184 VALIGN="TOP" | |
185 >Transparent</TD | |
186 ></TR | |
187 ><TR | |
188 ><TD | |
189 ALIGN="LEFT" | |
190 VALIGN="TOP" | |
191 >1 / 0</TD | |
192 ><TD | |
193 ALIGN="LEFT" | |
194 VALIGN="TOP" | |
195 >Inverted color if possible, black if not.</TD | |
196 ></TR | |
197 ></TBODY | |
198 ></TABLE | |
199 ><P | |
200 ></P | |
201 ></DIV | |
202 ></P | |
203 ><P | |
204 >Cursors created with this function must be freed with | |
205 <A | |
206 HREF="sdlfreecursor.html" | |
207 >SDL_FreeCursor</A | |
208 >.</P | |
209 ></DIV | |
210 ><DIV | |
211 CLASS="REFSECT1" | |
212 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
213 NAME="AEN2140" |
0 | 214 ></A |
215 ><H2 | |
216 >Example</H2 | |
217 ><PRE | |
218 CLASS="PROGRAMLISTING" | |
219 >/* Stolen from the mailing list */ | |
220 /* Creates a new mouse cursor from an XPM */ | |
221 | |
222 | |
223 /* XPM */ | |
224 static const char *arrow[] = { | |
225 /* width height num_colors chars_per_pixel */ | |
226 " 32 32 3 1", | |
227 /* colors */ | |
228 "X c #000000", | |
229 ". c #ffffff", | |
230 " c None", | |
231 /* pixels */ | |
232 "X ", | |
233 "XX ", | |
234 "X.X ", | |
235 "X..X ", | |
236 "X...X ", | |
237 "X....X ", | |
238 "X.....X ", | |
239 "X......X ", | |
240 "X.......X ", | |
241 "X........X ", | |
242 "X.....XXXXX ", | |
243 "X..X..X ", | |
244 "X.X X..X ", | |
245 "XX X..X ", | |
246 "X X..X ", | |
247 " X..X ", | |
248 " X..X ", | |
249 " X..X ", | |
250 " XX ", | |
251 " ", | |
252 " ", | |
253 " ", | |
254 " ", | |
255 " ", | |
256 " ", | |
257 " ", | |
258 " ", | |
259 " ", | |
260 " ", | |
261 " ", | |
262 " ", | |
263 " ", | |
264 "0,0" | |
265 }; | |
266 | |
267 static SDL_Cursor *init_system_cursor(const char *image[]) | |
268 { | |
269 int i, row, col; | |
270 Uint8 data[4*32]; | |
271 Uint8 mask[4*32]; | |
272 int hot_x, hot_y; | |
273 | |
274 i = -1; | |
275 for ( row=0; row<32; ++row ) { | |
276 for ( col=0; col<32; ++col ) { | |
277 if ( col % 8 ) { | |
278 data[i] <<= 1; | |
279 mask[i] <<= 1; | |
280 } else { | |
281 ++i; | |
282 data[i] = mask[i] = 0; | |
283 } | |
284 switch (image[4+row][col]) { | |
285 case 'X': | |
286 data[i] |= 0x01; | |
287 k[i] |= 0x01; | |
288 break; | |
289 case '.': | |
290 mask[i] |= 0x01; | |
291 break; | |
292 case ' ': | |
293 break; | |
294 } | |
295 } | |
296 } | |
297 sscanf(image[4+row], "%d,%d", &hot_x, &hot_y); | |
298 return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y); | |
299 }</PRE | |
300 ></DIV | |
301 ><DIV | |
302 CLASS="REFSECT1" | |
303 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
304 NAME="AEN2143" |
0 | 305 ></A |
306 ><H2 | |
307 >See Also</H2 | |
308 ><P | |
309 ><A | |
310 HREF="sdlfreecursor.html" | |
311 ><TT | |
312 CLASS="FUNCTION" | |
313 >SDL_FreeCursor</TT | |
314 ></A | |
315 >, | |
316 <A | |
317 HREF="sdlsetcursor.html" | |
318 ><TT | |
319 CLASS="FUNCTION" | |
320 >SDL_SetCursor</TT | |
321 ></A | |
322 >, | |
323 <A | |
324 HREF="sdlshowcursor.html" | |
325 ><TT | |
326 CLASS="FUNCTION" | |
327 >SDL_ShowCursor</TT | |
328 ></A | |
329 ></P | |
330 ></DIV | |
331 ><DIV | |
332 CLASS="NAVFOOTER" | |
333 ><HR | |
334 ALIGN="LEFT" | |
335 WIDTH="100%"><TABLE | |
336 WIDTH="100%" | |
337 BORDER="0" | |
338 CELLPADDING="0" | |
339 CELLSPACING="0" | |
340 ><TR | |
341 ><TD | |
342 WIDTH="33%" | |
343 ALIGN="left" | |
344 VALIGN="top" | |
345 ><A | |
346 HREF="sdlwarpmouse.html" | |
347 >Prev</A | |
348 ></TD | |
349 ><TD | |
350 WIDTH="34%" | |
351 ALIGN="center" | |
352 VALIGN="top" | |
353 ><A | |
354 HREF="index.html" | |
355 >Home</A | |
356 ></TD | |
357 ><TD | |
358 WIDTH="33%" | |
359 ALIGN="right" | |
360 VALIGN="top" | |
361 ><A | |
362 HREF="sdlfreecursor.html" | |
363 >Next</A | |
364 ></TD | |
365 ></TR | |
366 ><TR | |
367 ><TD | |
368 WIDTH="33%" | |
369 ALIGN="left" | |
370 VALIGN="top" | |
371 >SDL_WarpMouse</TD | |
372 ><TD | |
373 WIDTH="34%" | |
374 ALIGN="center" | |
375 VALIGN="top" | |
376 ><A | |
377 HREF="video.html" | |
378 >Up</A | |
379 ></TD | |
380 ><TD | |
381 WIDTH="33%" | |
382 ALIGN="right" | |
383 VALIGN="top" | |
384 >SDL_FreeCursor</TD | |
385 ></TR | |
386 ></TABLE | |
387 ></DIV | |
388 ></BODY | |
389 ></HTML | |
390 > |