home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / WINMOUTK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-10  |  2.8 KB  |  111 lines

  1. /*
  2.     winmoutk.c  6/05/90
  3.  
  4.     % winmou_Track
  5.  
  6.     The generic window mouse handler.
  7.     When a mouse button is clicked over the window, the stuffcode
  8.     is set to MOU_CLICK.
  9.  
  10.     OWL 3.2
  11.     Copyright (c) 1990 by Oakland Group, Inc.
  12.     ALL RIGHTS RESERVED.
  13.  
  14.     Revision History:
  15.     -----------------
  16.      7/25/90 jmd    put in the library
  17.      8/08/90 ted    Changed references from disp_SetMouseCode to kb_Stuff.
  18.      8/08/90 jdc    remove unused variable fld
  19. */
  20.  
  21. #include "oakhead.h"
  22. #include "odisp.h"
  23. #include "scancode.h"        /* for MOU codes */
  24.  
  25. int winmou_Track(win_type win, int msg, mev_struct *mev)
  26. /*
  27.     Messages a mouse handler receives when its window is current
  28.     MEV_REQUEST            someone else wants to be it
  29.     MEV_STARTEVENT        current, mouse entered
  30.     MEV_EVENT            current, event in win
  31.     MEV_ENDEVENT        current, mouse left
  32.     Messages a mouse handler receives when its window is not current
  33.     MEV_STARTOFFER        not current, mouse entered
  34.     MEV_OFFER            not current, event in win
  35.     MEV_ENDOFFER        not current, mouse left
  36. */
  37. {
  38.     switch (msg) {
  39.     case MEV_STARTOFFER:           /* we're not the current window */
  40.         win_SetDebounced(win, mev_IsButtonDown(mev));
  41.  
  42.         if (mev_IsFake()) {        /* ignore 'fake' events */
  43.             mev_ClearEvent(mev);
  44.             break;
  45.         }
  46.         /* no break, fall through */
  47.  
  48.     case MEV_OFFER:                /* we're not the current window */
  49.         /* Accept the offer */
  50.         if (!mev_IsButtonDown(mev)) {
  51.             win_SetDebounced(win, FALSE);
  52.         }
  53.         else {
  54.             if (!win_GetDebounced(win)) {
  55.                 win_SetDebounced(win, TRUE);
  56.  
  57.                 /* Set the mouse code to tell us that the mouse was clicked
  58.                  *    when our window is eventually activated
  59.                  */
  60.                 if (!mev_IsFake()) { /* ignore 'fake' clicks */
  61.                     kb_Stuff(MOU_CLICK);
  62.                 }
  63.             }
  64.         }
  65.         /* We don't care what code we return because we accepted the
  66.          *    offer, which means the REQUEST message gets to decide what
  67.          *    to return from this particular kb_Read call
  68.          */
  69.         break;
  70.  
  71.     case MEV_ENDOFFER:                   /* we're not the current window */
  72.         break;
  73.  
  74.     case MEV_REQUEST:    /* we're the current window;
  75.                             another window was selected by the mouse. */
  76.         winmev_grantrequest(win, mev);
  77.  
  78.         /* Return MOU_THERE as a scancode to kb_Read to tell the win
  79.             about the request so it can exit */
  80.         return(MOU_THERE);
  81.  
  82.     case MEV_STARTEVENT:
  83.         win_SetDebounced(win, mev_IsButtonDown(mev));
  84.         if (mev_IsFake() && !kb_WasMouse()) {
  85.             break;        /* ignore 'fake' events */
  86.         }
  87.  
  88.         /* no break, fall through */
  89.  
  90.     case MEV_EVENT:                    /* we're the current window */
  91.         if (!mev_IsButtonDown(mev)) {
  92.             win_SetDebounced(win, FALSE);
  93.         }
  94.         else {
  95.             if (!win_GetDebounced(win)) {
  96.                 win_SetDebounced(win, TRUE);
  97.  
  98.                 /* return MOU_CLICK so our window knows the mouse was clicked */
  99.                 return(MOU_CLICK);
  100.             }
  101.         }
  102.         break;
  103.  
  104.     case MEV_ENDEVENT:                   /* we're the current window */
  105.         break;
  106.     }
  107.  
  108.     return(MOU_IGNORE);        /* Ignore this mouse event */
  109. }
  110.  
  111.