home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_02 / wmouselm.c < prev    next >
C/C++ Source or Header  |  1991-03-17  |  2KB  |  103 lines

  1. /* wmouse_limit ()
  2.  *    routine to limit mouse movement to the current window.
  3.  *        PARAMETER = OFF (=0) turns off limitation, mouse may roam freely
  4.  *                  = ON       limits mouse to current window.
  5.  */
  6. #include "wsys.h"
  7.  
  8.  
  9.     /* values for mouse driver to set limits
  10.      */
  11. #define X_LIMIT 0x07
  12. #define Y_LIMIT 0x08
  13.  
  14.  
  15. static void W_NEAR setlimit ( int min, int max, int xy, int charsize);
  16.  
  17. void wmouse_limit (int);        /* ON=limit to current window */
  18. void wmouse_limit (int onoff)
  19.     {
  20.     int max, min;
  21.     
  22.     
  23.     /* calc max & min in mickeys ( see wmouse.c for relation to mickeys )
  24.      */
  25.     if ( onoff )
  26.         {
  27.         /* setting limits ON 
  28.          */
  29.         min = w0->winleft;  
  30.         max = w0->winxmax + min;
  31.         }
  32.     else
  33.         {
  34.         /* setting limits OFF
  35.          */
  36.         min = 0;
  37.         max = wxabsmax;
  38.         }
  39.     
  40.  
  41.     setlimit ( min, max, X_LIMIT, wpxchar );
  42.  
  43.  
  44.  
  45.  
  46.  
  47.     /* now do same for y-coord */
  48.  
  49.     if ( onoff )
  50.         {
  51.         /* setting limits ON
  52.          */
  53.         min = w0->winleft;
  54.         max = w0->winymax + min;
  55.         }
  56.     else
  57.         {
  58.         /* setting limits OFF
  59.          */
  60.         min = 0;
  61.         max = wyabsmax;
  62.         }
  63.     setlimit ( min, max, Y_LIMIT, wpychar );
  64.         
  65.     
  66.     return;        /* wmouse_limit */
  67.     }
  68.  
  69.  
  70. static void W_NEAR setlimit ( int min, int max, int xy, int charsize )
  71.     {
  72.     PSEUDOREGS
  73.     
  74.     if ( wmode == 'T' )
  75.         {
  76.         /* in text modes, 8 mickeys per character onscreen.
  77.          */
  78.         min *= 8;
  79.         max *= 8;
  80.         }
  81.     #ifndef TEXTONLY
  82.     else    
  83.         {
  84.         min *=  charsize;
  85.         ++max;            /* include all bits of last character in gr. mode */
  86.         max *=  charsize;
  87.         }
  88.  
  89.     #endif    /* TEXTONLY */
  90.  
  91.  
  92.     _DX = max;
  93.     _CX = min;
  94.     _AX = xy;
  95.     INTERRUPT ( 0x33 );    
  96.     
  97.     
  98.  
  99.  
  100.     return;    /* setlimit */
  101.     }
  102.     
  103.     /*------------------- end of WMOUSELM.C ------------------*/