home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !SDL / man / SDL_CreateCursor.3 < prev    next >
Encoding:
Text File  |  2006-09-20  |  3.9 KB  |  147 lines

  1. <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
  2. <!-- available at http://polyglotman.sourceforge.net/ -->
  3.  
  4. <html>
  5. <head>
  6. <title>"SDL_CreateCursor"("3") manual page</title>
  7. </head>
  8. <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
  9. <a href='#toc'>Table of Contents</a><p>
  10.  
  11. <h2><a name='sect0' href='#toc0'>Name</a></h2>
  12. SDL_CreateCursor- Creates a new mouse cursor. 
  13. <h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
  14. <p>
  15. <b>#include "SDL.h"
  16. <p>
  17. </b><b>SDL_Cursor *<b>SDL_CreateCursor</b></b>(<b>Uint8 *data, Uint8 *mask, int w, int h, int
  18. hot_x, int hot_y</b>); 
  19. <h2><a name='sect2' href='#toc2'>Description</a></h2>
  20. <p>
  21. Create a cursor using the specified <b>data</b>
  22. and <b>mask</b> (in MSB format). The cursor width must be a multiple of 8 bits.
  23. <p>
  24. The cursor is created in black and white according to the following:  
  25. <dl>
  26.  
  27. <dt><b>Data
  28. / Mask</b> </dt>
  29. <dd><b>Resulting pixel on screen</b> </dd>
  30.  
  31. <dt>0 / 1 </dt>
  32. <dd>White </dd>
  33.  
  34. <dt>1 / 1 </dt>
  35. <dd>Black </dd>
  36.  
  37. <dt>0 / 0 </dt>
  38. <dd>Transparent
  39. </dd>
  40.  
  41. <dt>1 / 0 </dt>
  42. <dd>Inverted color if possible, black if not. </dd>
  43. </dl>
  44. <p>
  45. Cursors created with this
  46. function must be freed with <i>SDL_FreeCursor</i>. 
  47. <h2><a name='sect3' href='#toc3'>Example</a></h2>
  48. <p>
  49. <br>
  50. <pre>CW/* Stolen from the mailing list */
  51. /* Creates a new mouse cursor from an XPM */
  52. /* XPM */
  53. static const char *arrow[] = {
  54.   /* width height num_colors chars_per_pixel */
  55.   "    32    32        3            1",
  56.   /* colors */
  57.   "X c #000000",
  58.   ". c #ffffff",
  59.   "  c None",
  60.   /* pixels */
  61.   "X                               ",
  62.   "XX                              ",
  63.   "X.X                             ",
  64.   "X..X                            ",
  65.   "X...X                           ",
  66.   "X....X                          ",
  67.   "X.....X                         ",
  68.   "X......X                        ",
  69.   "X.......X                       ",
  70.   "X........X                      ",
  71.   "X.....XXXXX                     ",
  72.   "X..X..X                         ",
  73.   "X.X X..X                        ",
  74.   "XX  X..X                        ",
  75.   "X    X..X                       ",
  76.   "     X..X                       ",
  77.   "      X..X                      ",
  78.   "      X..X                      ",
  79.   "       XX                       ",
  80.   "                                ",
  81.   "                                ",
  82.   "                                ",
  83.   "                                ",
  84.   "                                ",
  85.   "                                ",
  86.   "                                ",
  87.   "                                ",
  88.   "                                ",
  89.   "                                ",
  90.   "                                ",
  91.   "                                ",
  92.   "                                ",
  93.   "0,0"
  94. };
  95. static SDL_Cursor *init_system_cursor(const char *image[])
  96. {
  97.   int i, row, col;
  98.   Uint8 data[4*32];
  99.   Uint8 mask[4*32];
  100.   int hot_x, hot_y;
  101.   i = -1;
  102.   for ( row=0; row<32; ++row ) {
  103.     for ( col=0; col<32; ++col ) {
  104.       if ( col % 8 ) {
  105.         data[i] <<= 1;
  106.         mask[i] <<= 1;
  107.       } else {
  108.         ++i;
  109.         data[i] = mask[i] = 0;
  110.       }
  111.       switch (image[4+row][col]) {
  112.         case 'X':
  113.           data[i] |= 0x01;
  114.           k[i] |= 0x01;
  115.           break;
  116.         case '.':
  117.           mask[i] |= 0x01;
  118.           break;
  119.         case ' ':
  120.           break;
  121.       }
  122.     }
  123.   }
  124.   sscanf(image[4+row], "%d,%d", &hot_x, &hot_y);
  125.   return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
  126. }
  127. </pre><p>
  128.  
  129. <h2><a name='sect4' href='#toc4'>See Also</a></h2>
  130. <p>
  131. <i><b>SDL_FreeCursor</b></i>, <i><b>SDL_SetCursor</b></i>, <i><b>SDL_ShowCursor</b></i> 
  132. <!--
  133.   
  134.  <p>
  135.  
  136. <hr><p>
  137. <a name='toc'><b>Table of Contents</b></a><p>
  138. <ul>
  139. <li><a name='toc0' href='#sect0'>Name</a></li>
  140. <li><a name='toc1' href='#sect1'>Synopsis</a></li>
  141. <li><a name='toc2' href='#sect2'>Description</a></li>
  142. <li><a name='toc3' href='#sect3'>Example</a></li>
  143. <li><a name='toc4' href='#sect4'>See Also</a></li>
  144. </ul>
  145. </body>
  146. </html>
  147.