home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / CUAMAP.C < prev    next >
Text File  |  1995-11-30  |  8KB  |  203 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   Cuamap.c                                                                */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*   All the Cua Mapping functions.                                          */
  8. /*                                                                           */
  9. /*...Release 1.01 (04/03/92)                                                 */
  10. /*...                                                                        */
  11. /*... 05/08/92  701   Srinivas  Cua Interface.                               */
  12. /*... 01/12/93  808   Selwyn    Profile fixes/improvements.                  */
  13. /*****************************************************************************/
  14. #include "all.h"
  15. uchar ScrollShade1[] =  {SHADEDARK,0};
  16. uchar ScrollShade2[] =  {Attrib(vaMenuCsr),' ',0};
  17. uchar hilite[]       =  {RepCnt(1),Attrib(vaMenuCsr),0};
  18. uchar hiatt[]        =  {RepCnt(1),Attrib(vaMenuSel),0};
  19. uchar badhilite[]    =  {RepCnt(1),Attrib(vaBadSel),0};
  20. uchar normal[]       =  {RepCnt(1),Attrib(vaMenuBar),0};
  21. uchar badnormal[]    =  {RepCnt(1),Attrib(vaBadAct),0};
  22. uchar Shadow[]       =  {RepCnt(1),Attrib(vaShadow),0};
  23. uchar ClearField[]   =  {RepCnt(1),' ',0};
  24. uchar InScrollMode   =  FALSE;
  25.  
  26. extern CmdParms cmd;
  27. extern UINT     MenuRow;
  28.  
  29. /*****************************************************************************/
  30. /* GetFuncsFromEvents()                                                      */
  31. /*                                                                           */
  32. /* Description:                                                              */
  33. /*                                                                           */
  34. /*  Get i/o events from the user and find the function he wants to exec.     */
  35. /*                                                                           */
  36. /* Parameters:                                                               */
  37. /*                                                                           */
  38. /*   none                                                                    */
  39. /*                                                                           */
  40. /* Return:                                                                   */
  41. /*                                                                           */
  42. /*   FuncCode   code of the function to be executed.                         */
  43. /*                                                                           */
  44. /*****************************************************************************/
  45. #define RETURN 1
  46.  
  47. int GetFuncsFromEvents( int EscKeyFlag , void * pParmBlk )
  48. {
  49.  int       FuncCode;
  50.  EVENT    *pEvent;
  51.  int       Choice;
  52.  static    uint      WaitTime = SEM_INDEFINITE_WAIT;
  53.  int       ( * FuncCodeGetter)(int , void *);
  54.  
  55.  FuncCode = 0;
  56.  FuncCodeGetter = CuaMenuBar;
  57.  for(;;)
  58.  {
  59.    /**************************************************************************/
  60.    /* Get an event from the "getter" of function codes.                      */
  61.    /*  - Based on the event and the interface in use, decide which           */
  62.    /*    "getter" to call.                                                   */
  63.    /*  - initialize a choice for the getter.                                 */
  64.    /**************************************************************************/
  65.    pEvent = GetEvent( WaitTime );
  66.    switch( pEvent->Type )
  67.    {
  68.     case TYPE_MOUSE_EVENT:
  69.  
  70.      WaitTime = SEM_INDEFINITE_WAIT;
  71.      switch( pEvent->Value )
  72.      {
  73.        case EVENT_BUTTON_2_DOWN:
  74.          if( MouseEventInActionBar( &Choice ) )
  75.          {
  76.            beep();
  77.            continue;
  78.          }
  79.          else
  80.            return( RIGHTMOUSECLICK );
  81.  
  82.        case EVENT_BUTTON_1_DOWN:
  83.        {
  84.          if( pEvent->Row == MenuRow )
  85.          {
  86.            switch( pEvent->Col )
  87.            {
  88.              case SHRINKUPARROWCOL:
  89.              case EXPANDDNARROWCOL:
  90.  
  91.               if( pEvent->FakeEvent == TRUE )
  92.                 WaitTime = SCROLL_REGULAR_WAIT;
  93.               else
  94.                 WaitTime = SCROLL_INITIAL_WAIT;
  95.  
  96.               if( pEvent->Col == SHRINKUPARROWCOL )
  97.                 return( SHRINKSTORAGE );
  98.  
  99.               if( pEvent->Col == EXPANDDNARROWCOL )
  100.                 return( EXPANDSTORAGE );
  101.  
  102.               break;
  103.  
  104.              default:
  105.               break;
  106.            }
  107.          }
  108.        }                                /* intentional fall - through        */
  109.  
  110.        goto case_EVENT_BUTTON_1_DOWN_MOVE;
  111. case_EVENT_BUTTON_1_DOWN_MOVE:
  112.  
  113.        case EVENT_BUTTON_1_DOWN_MOVE:
  114.          if( MouseEventInActionBar( &Choice ) )
  115.          {
  116.            if( pEvent->Value == EVENT_BUTTON_1_DOWN )
  117.              break;
  118.            else
  119.              continue;
  120.          }
  121.          else
  122.          if( pEvent->Value == EVENT_BUTTON_1_DOWN )
  123.            return( LEFTMOUSECLICK );
  124.          continue;
  125.  
  126.        default:
  127.          continue;
  128.      }
  129.      break;
  130.  
  131.     case TYPE_KBD_EVENT:
  132.  
  133.      WaitTime = SEM_INDEFINITE_WAIT;
  134.      Choice = pEvent->Value;
  135.      switch( Choice )
  136.      {
  137.        case ESC:
  138.         if( EscKeyFlag == RETURN )
  139.          return( ESCAPE );
  140.         else
  141.         {
  142.           if( KeyInActionBarExpressKeys( &Choice ) )
  143.             break;
  144.           FuncCodeGetter = (int (*)(int,void*))Convert;
  145.         }
  146.        break;
  147.  
  148.        case F10:
  149.         Choice = -1;
  150.         break;
  151.  
  152.        case  key_0:                  /* 0  0x0b30                         */
  153.        case  key_1:                  /* 1  0x0231                         */
  154.        case  key_2:                  /* 2  0x0332                         */
  155.        case  key_3:                  /* 3  0x0433                         */
  156.        case  key_4:                  /* 4  0x0534                         */
  157.        case  key_5:                  /* 5  0x0635                         */
  158.        case  key_6:                  /* 6  0x0736                         */
  159.        case  key_7:                  /* 7  0x0837                         */
  160.        case  key_8:                  /* 8  0x0938                         */
  161.        case  key_9:                  /* 9  0x0a39                         */
  162.         return(Choice);
  163.  
  164.  
  165.        default:
  166.         if( KeyInActionBarExpressKeys( &Choice ) )
  167.           break;
  168.  
  169.         FuncCodeGetter = (int (*)(int,void*))Convert;
  170. /*Supporting a command line interface using MSH.*/
  171. /*MSH   commandLine.nparms=0; */
  172.         break;
  173.      }
  174.      break;
  175.  
  176. #ifdef MSH
  177.   case TYPE_MSH_EVENT:
  178. /*Supporting a command line interface using MSH.*/
  179.      commandLine.nparms=0;
  180.      FuncCodeGetter = (int (*)(int,void*))MshSD386CommandProcessor;
  181.      break;
  182. #endif
  183.    }
  184.    FuncCode = FuncCodeGetter( Choice , pParmBlk);
  185.  
  186.    /********************************************************************* 808*/
  187.    /* If the function code returned is ExpressBar (ESC), we have to display  */
  188.    /* the action bar with the first pulldown.                                */
  189.    /**************************************************************************/
  190.    if( FuncCode == EXPRESSBAR )                                         /*808*/
  191.    {                                                                    /*808*/
  192.      Choice = 1;                                                        /*808*/
  193.      FuncCodeGetter = CuaMenuBar;                                       /*808*/
  194.      FuncCode = FuncCodeGetter( Choice , pParmBlk);                     /*808*/
  195. /*Supporting a command line interface using MSH.*/
  196. /*MSH   commandLine.nparms=0; */
  197. /*MSH   commandLine.nparms=0; */
  198.    }                                                                    /*808*/
  199. /* SD386Log(FuncCode,NULL); */
  200.    return( FuncCode );
  201.  }
  202. }
  203.