home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / DEMO / RIM22 / MACROS / MOUSE.RM < prev    next >
Text File  |  1993-11-14  |  4KB  |  146 lines

  1. /*
  2. ** Macro module: mouse.rm - Mouse handling
  3. **
  4. ** Copyright (C) 1993 Brian L. Smith
  5. ** Copyright (C) 1993 RimStar Technology, Inc.
  6. ** All rights reserved internationally.
  7. ** Unlicensed use is a violation of applicable laws.
  8. **
  9. ** This source code is provided to licensed users of RimStar's products
  10. ** for the purpose of allowing the user to customize and/or enhance RimStar's
  11. ** products. The source code remains the property of the copyright holders
  12. ** with all rights reserved internationally.
  13. ** Any modifications to the source code are considered derivative works and
  14. ** all rights thereto are reserved to the copyright holders except
  15. ** that the purchaser may use the derivitive work in the same manner
  16. ** as permitted by the license governing the unmodified product.
  17. ** Distribution in any manner of any part of the original source code,
  18. ** whether in source or object form, is expressly prohibited without the
  19. ** express written permission of the copyright holders.
  20. **
  21. */
  22.  
  23. #define INCL_EVENT
  24. #define INCL_MOUSE
  25. #include "macro.h"
  26.  
  27. extern int cxChar;
  28. extern int cyChar;
  29.  
  30.  
  31. int
  32. MouEvent(USHORT event, PMOUSEINFO pInfo) {
  33.     static int    B1LastX, B1LastY;
  34.     int    type;
  35.  
  36.     switch ( pInfo->usEvent ) {
  37.  
  38.     case WM_MOUSEMOVE:    /* this event only gen'd if a button is down */
  39.         if ( !(pInfo->usButtonState & MOU_BUTTON1) )
  40.             return 0;    /* Not button 1 - so ignore */
  41.         if ( ((B1LastX - pInfo->x) & 0x7FFF) > cxChar/2 ||
  42.               ((B1LastY - pInfo->y) & 0x7FFF) > cyChar/2
  43.             ) {
  44.             B1LastX = pInfo->x;
  45.             B1LastY = pInfo->y;
  46.             if ( !MarkQuerySelType() ) {    /* Begin selection */
  47.                 if ( !pInfo->usShiftState )
  48.                     MarkBeginSel(SELECT_NORMAL);
  49.                 else if ( pInfo->usShiftState & CTRL_DOWN )
  50.                     MarkBeginSel(SELECT_COLUMN);
  51.                 else if ( pInfo->usShiftState & SHIFT_DOWN )
  52.                     MarkBeginSel(SELECT_LINE);
  53.                 else if ( pInfo->usShiftState & ALT_DOWN )
  54.                     MarkBeginSel(SELECT_EXCLUSIVE);
  55.             } else
  56.                 MovToMouse();
  57.         }
  58.         break;
  59.  
  60.     case WM_BUTTON1DOWN:    /* All button down events capture the mouse */
  61.         MovToMouse();
  62.         B1LastX = pInfo->x;
  63.         B1LastY = pInfo->y;
  64.         break;
  65.  
  66.     case WM_BEGINSELECT:
  67.     #if 0
  68.         /* WM_BEGINSELECT comes a bit to late for our liking
  69.         ** so we have chosen to detect selection using
  70.         ** WM_MOUSEMOVE instead.
  71.         */
  72.         /*
  73.         ** Start a selection if there is none,
  74.         ** else move to mouse (extends/contracts selection)
  75.         */
  76.         MovToMouse();
  77.         if ( !MarkQuerySelType() ) {
  78.             if ( !pInfo->usShiftState )
  79.                 MarkBeginSel(SELECT_EXCLUSIVE);
  80.             else if ( pInfo->usShiftState & CTRL_DOWN )
  81.                 MarkBeginSel(SELECT_COLUMN);
  82.             else if ( pInfo->usShiftState & SHIFT_DOWN )
  83.                 MarkBeginSel(SELECT_LINE);
  84.             else if ( pInfo->usShiftState & ALT_DOWN )
  85.                 MarkBeginSel(SELECT_NORMAL);
  86.         }
  87.     #endif
  88.         break;
  89.  
  90.     case WM_BUTTON2DOWN:
  91.         if ( !(type = MarkQuerySelType()) )    /* No selection in progress */
  92.             break;
  93.         if ( pInfo->usButtonState & MOU_BUTTON1 ) {
  94.             switch ( type ) {
  95.             case SELECT_EXCLUSIVE:    /* Convert from Exculsive to Column marking */
  96.                 MarkColumn();
  97.                 break;
  98.             case SELECT_COLUMN:        /* Change from Column to Line marking */
  99.                 MarkLine();
  100.                 break;
  101.             case SELECT_LINE:            /* Convert from Line to Normal(stream) marking */
  102.                 MarkNormal();
  103.                 break;
  104.             case SELECT_NORMAL:        /* Convert from Normal to Exclusive marking */
  105.                 MarkExclusive();
  106.                 break;
  107.             } /* end switch */
  108.         } else
  109.             MarkRemoveSel();
  110.         break;
  111.  
  112.     case WM_BUTTON1DBLCLK:
  113.         /* If in error output window jump to error */
  114.         if ( (BufQueryFlags() & BUFFER_TYPE) == BUFTYPE_TEMP )
  115.             ErrJumpToError();
  116.         break;
  117.     case WM_ENDSELECT:    /* User released button to end selection */
  118.         /* If you wanted a selection to be closed
  119.         **    when the mouse is released you could process
  120.         ** this message
  121.         */
  122.     case WM_BUTTON1UP:
  123.     case WM_BUTTON2UP:
  124.     case WM_BUTTON2DBLCLK:
  125.     case WM_BUTTON3DOWN:
  126.     case WM_BUTTON3UP:
  127.     case WM_BUTTON3DBLCLK:
  128.     case WM_BUTTON1CLICK:
  129.     case WM_BUTTON2CLICK:
  130.     case WM_BUTTON3CLICK:
  131.     case WM_BEGINDRAG:
  132.     case WM_ENDDRAG:
  133.     case WM_SINGLESELECT:
  134.     case WM_OPEN:            /* Generated after a double-click of button 1 */
  135.     case WM_CONTEXTMENU:
  136.     default:
  137.         return 0;
  138.     } /* end switch */
  139.     return 1;
  140. } /* end MouEvent */
  141.  
  142.  
  143. /*
  144. ** End macro: mouse.rm
  145. */
  146.