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