home *** CD-ROM | disk | FTP | other *** search
/ ring.yamanashi.ac.jp/pub/pc/freem/action/ / action.zip / a7xpg0_11.zip / a7xpg / import / SDL_mouse.d < prev    next >
Text File  |  2003-09-20  |  4KB  |  115 lines

  1. /*
  2.     SDL - Simple DirectMedia Layer
  3.     Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public
  16.     License along with this library; if not, write to the Free
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19.     Sam Lantinga
  20.     slouken@devolution.com
  21. */
  22.  
  23. /* Include file for SDL mouse event handling */
  24.  
  25. import SDL_types;
  26. import SDL_video;
  27.  
  28. extern(C):
  29.  
  30. struct SDL_Cursor {
  31.     SDL_Rect area;            /* The area of the mouse cursor */
  32.     Sint16 hot_x, hot_y;        /* The "tip" of the cursor */
  33.     Uint8 *data;            /* B/W cursor data */
  34.     Uint8 *mask;            /* B/W cursor mask */
  35.     Uint8 *save[2];            /* Place to save cursor area */
  36.     void /*WMcursor*/ *wm_cursor;        /* Window-manager cursor */
  37. }
  38.  
  39. /* Function prototypes */
  40. /*
  41.  * Retrieve the current state of the mouse.
  42.  * The current button state is returned as a button bitmask, which can
  43.  * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
  44.  * current mouse cursor position.  You can pass NULL for either x or y.
  45.  */
  46. Uint8 SDL_GetMouseState(int *x, int *y);
  47.  
  48. /*
  49.  * Retrieve the current state of the mouse.
  50.  * The current button state is returned as a button bitmask, which can
  51.  * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
  52.  * mouse deltas since the last call to SDL_GetRelativeMouseState().
  53.  */
  54. Uint8 SDL_GetRelativeMouseState(int *x, int *y);
  55.  
  56. /*
  57.  * Set the position of the mouse cursor (generates a mouse motion event)
  58.  */
  59. void SDL_WarpMouse(Uint16 x, Uint16 y);
  60.  
  61. /*
  62.  * Create a cursor using the specified data and mask (in MSB format).
  63.  * The cursor width must be a multiple of 8 bits.
  64.  * 
  65.  * The cursor is created in black and white according to the following:
  66.  * data  mask    resulting pixel on screen
  67.  *  0     1       White
  68.  *  1     1       Black
  69.  *  0     0       Transparent
  70.  *  1     0       Inverted color if possible, black if not.
  71.  * 
  72.  * Cursors created with this function must be freed with SDL_FreeCursor().
  73.  */
  74. SDL_Cursor *SDL_CreateCursor
  75.         (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
  76.  
  77. /*
  78.  * Set the currently active cursor to the specified one.
  79.  * If the cursor is currently visible, the change will be immediately 
  80.  * represented on the display.
  81.  */
  82. void SDL_SetCursor(SDL_Cursor *cursor);
  83.  
  84. /*
  85.  * Returns the currently active cursor.
  86.  */
  87. SDL_Cursor * SDL_GetCursor();
  88.  
  89. /*
  90.  * Deallocates a cursor created with SDL_CreateCursor().
  91.  */
  92. void SDL_FreeCursor(SDL_Cursor *cursor);
  93.  
  94. /*
  95.  * Toggle whether or not the cursor is shown on the screen.
  96.  * The cursor start off displayed, but can be turned off.
  97.  * SDL_ShowCursor() returns 1 if the cursor was being displayed
  98.  * before the call, or 0 if it was not.  You can query the current
  99.  * state by passing a 'toggle' value of -1.
  100.  */
  101. int SDL_ShowCursor(int toggle);
  102.  
  103. /* Used as a mask when testing buttons in buttonstate
  104.    Button 1:    Left mouse button
  105.    Button 2:    Middle mouse button
  106.    Button 3:    Right mouse button
  107.  */
  108. uint SDL_BUTTON(uint X) { return SDL_PRESSED << (X-1); }
  109. const uint SDL_BUTTON_LEFT        = 1;
  110. const uint SDL_BUTTON_MIDDLE    = 2;
  111. const uint SDL_BUTTON_RIGHT        = 3;
  112. const uint SDL_BUTTON_LMASK        = SDL_PRESSED << (SDL_BUTTON_LEFT - 1);
  113. const uint SDL_BUTTON_MMASK        = SDL_PRESSED << (SDL_BUTTON_MIDDLE - 1);
  114. const uint SDL_BUTTON_RMASK        = SDL_PRESSED << (SDL_BUTTON_RIGHT - 1);
  115.