home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / contrib / libgrx / include / mousex.h < prev   
Encoding:
C/C++ Source or Header  |  1993-12-06  |  5.4 KB  |  179 lines

  1. /**
  2.  ** MOUSEX.H
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #ifndef _MOUSEX_H_
  25. #define _MOUSEX_H_
  26.  
  27. #ifndef _GRX_H_
  28. # include <grx.h>
  29. #endif
  30.  
  31. /*
  32.  * MOUSE event flag bits
  33.  * (changed to reflect MS mouse driver conventions)
  34.  */
  35. #ifndef M_MOTION            /* "eventque.h" also defines these */
  36.  
  37. #define M_MOTION    0x001
  38. #define M_LEFT_DOWN    0x002
  39. #define M_LEFT_UP    0x004
  40. #define M_RIGHT_DOWN    0x008
  41. #define M_RIGHT_UP    0x010
  42. #define M_MIDDLE_DOWN    0x020
  43. #define M_MIDDLE_UP    0x040
  44. #define M_BUTTON_DOWN    (M_LEFT_DOWN | M_MIDDLE_DOWN | M_RIGHT_DOWN)
  45. #define M_BUTTON_UP    (M_LEFT_UP   | M_MIDDLE_UP   | M_RIGHT_UP)
  46. #define M_BUTTON_CHANGE (M_BUTTON_UP | M_BUTTON_DOWN )
  47.  
  48. /*
  49.  * MOUSE button status bits
  50.  */
  51. #define M_LEFT        1
  52. #define M_RIGHT        2
  53. #define M_MIDDLE    4
  54.  
  55. #endif  /* M_MOTION */
  56.  
  57. #define M_KEYPRESS    0x080
  58. #define M_POLL        0x100
  59. #define M_NOPAINT    0x200
  60. #define M_EVENT        (M_MOTION | M_KEYPRESS | M_BUTTON_DOWN | M_BUTTON_UP)
  61.  
  62.  
  63. /*
  64.  * KEYBOARD status word bits
  65.  */
  66. #ifndef KB_SHIFT            /* "eventque.h" also defines these */
  67.  
  68. #define KB_RIGHTSHIFT    0x01        /* right shift key depressed */
  69. #define KB_LEFTSHIFT    0x02        /* left shift key depressed */
  70. #define KB_CTRL        0x04        /* CTRL depressed */
  71. #define KB_ALT        0x08        /* ALT depressed */
  72. #define KB_SCROLLOCK    0x10        /* SCROLL LOCK active */
  73. #define KB_NUMLOCK    0x20        /* NUM LOCK active */
  74. #define KB_CAPSLOCK    0x40        /* CAPS LOCK active */
  75. #define KB_INSERT    0x80        /* INSERT state active */
  76.  
  77. #define KB_SHIFT    (KB_LEFTSHIFT | KB_RIGHTSHIFT)
  78.  
  79. #endif  /* KB_SHIFT */
  80.  
  81. /*
  82.  * MOUSE CURSOR modes:
  83.  *  M_CUR_NORMAL -- just the cursor
  84.  *  M_CUR_RUBBER -- rectangular rubber band (XOR-d to the screen)
  85.  *  M_CUR_LINE     -- line attached to the cursor
  86.  *  M_CUR_BOX     -- rectangular box dragged by the cursor
  87.  */
  88. #define M_CUR_NORMAL    0
  89. #define M_CUR_RUBBER    1
  90. #define M_CUR_LINE    2
  91. #define M_CUR_BOX    3
  92.  
  93. #ifdef __cplusplus
  94. extern "C" {
  95. #endif
  96.  
  97. /*
  98.  * mouse event buffer structure
  99.  */
  100. typedef struct {
  101.     int  flags;                /* flags (see above) */
  102.     int  x,y;                /* coordinates */
  103.     int  buttons;            /* button state */
  104.     int  key;                /* key code from keyboard */
  105.     int  kbstat;            /* keybd status (ALT, CTRL, etc..) */
  106.     long time;                /* time stamp of the event */
  107. } MouseEvent;
  108.  
  109. /*
  110.  * graphics cursor structure
  111.  */
  112. typedef struct {
  113.     GrVidRAM  cr_andmask;        /* cursor bitmap to AND */
  114.     GrVidRAM  cr_ormask;        /* cursor bitmap to OR */
  115.     GrVidRAM  cr_work;            /* work area */
  116.     GrVidRAM  cr_save;            /* screen save area */
  117.     int      cr_xcord,cr_ycord;        /* cursor position on screen */
  118.     int      cr_xsize,cr_ysize;        /* cursor size */
  119.     int      cr_xoffs,cr_yoffs;        /* LU corner to hot point offset */
  120.     int      cr_xwork,cr_ywork;        /* save/work area sizes */
  121.     int      cr_xwpos,cr_ywpos;        /* save/work area position on screen */
  122.     int      cr_displayed;            /* set if displayed */
  123. } GrCursor;
  124.  
  125. int  getkey(void);
  126. int  getxkey(void);
  127. int  getkbstat(void);
  128.  
  129. #ifdef __GNUC__
  130.   int  kbhit(void);
  131.   long clock(void);
  132.   long rawclock(void);
  133. #endif
  134.  
  135. GrCursor *GrBuildCursor(char *data,int w,int h,int xo,int yo,GrColorTableP c);
  136. GrCursor *GrLoadCursor(char *fname,GrColorTableP colors);
  137. void GrDestroyCursor(GrCursor *cursor);
  138. void GrDisplayCursor(GrCursor *cursor);
  139. void GrEraseCursor(GrCursor *cursor);
  140. void GrMoveCursor(GrCursor *cursor,int x,int y);
  141.  
  142. int  MouseDetect(void);
  143. void MouseEventMode(int use_interrupts);
  144. void MouseInit(void);
  145. void MouseUnInit(void);
  146. void MouseSetSpeed(int speed);
  147. void MouseSetAccel(int thresh,int accel);
  148. void MouseSetLimits(int x1,int y1,int x2,int y2);
  149. void MouseGetLimits(int *x1,int *y1,int *x2,int *y2);
  150. void MouseWarp(int x,int y);
  151. void MouseEventEnable(int enable_kb,int enable_ms);
  152. void MouseGetEvent(int flags,MouseEvent *event);
  153. int  MousePendingEvent(void);
  154.  
  155. GrCursor *MouseGetCursor(void);
  156. void MouseSetCursor(GrCursor *cursor);
  157. void MouseSetColors(int fg,int bg);
  158. void MouseSetCursorMode(int mode,...);
  159. void MouseDisplayCursor(void);
  160. void MouseEraseCursor(void);
  161. int  MouseBlock(GrContext *c,int x1,int y1,int x2,int y2);
  162. void MouseUnBlock(int return_value_from_MouseBlock);
  163. int  MouseCursorIsDisplayed(void);
  164.  
  165. /*
  166.  * call formats for 'MouseSetCursorMode': (all args are integers)
  167.  *  MouseSetCursorMode(M_CUR_NORMAL);
  168.  *  MouseSetCursorMode(M_CUR_RUBBER,xanchor,yanchor,color);
  169.  *  MouseSetCursorMode(M_CUR_LINE,xanchor,yanchor,color);
  170.  *  MouseSetCursorMode(M_CUR_BOX,dx1,dy1,dx2,dy2,color);
  171.  */
  172.  
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177. #endif /* _MOUSEX_H_ */
  178.  
  179.