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

  1. /* WPOPFKEY.C hotkey routine to pop up an FKEY menu 
  2.  *         once the mouse center button is pressed.
  3.  */
  4. #include "wsys.h" 
  5.  
  6. static char **save_labels = NULL;
  7.  
  8. static int fkeylen[] = 
  9.     {3,3,3, 3,3,3, 3,3,3, 4,4,4};
  10. static int fkeyval[] =
  11.     {FKEY(1),FKEY(2),FKEY(3), FKEY(4),FKEY(5),FKEY(6), 
  12.      FKEY(7),FKEY(8),FKEY(9), FKEY(10),FKEY_11,FKEY_12 };
  13. static char *fkeyname[] =
  14.     {
  15.     "F1","F2","F3", "F4","F5","F6",      
  16.     "F7","F8","F9", "F10","F11","F12"
  17.     };     
  18. static int mouse_fkeys (void);
  19.     
  20.  
  21. void wpopfkey ( char **keylabels )
  22.     {
  23.     save_labels = keylabels;
  24.     wmspopup ( mouse_fkeys );
  25.     return;        /* wpopfkey () */
  26.     }
  27.     
  28. static int  mouse_fkeys (void)
  29.     {
  30.     int more_fkeys =1;
  31.     int n, row, col, key;
  32.     char *label;
  33.     
  34.     wopen ( 15, 5, 55, 14, LIGHTGRAY, SINGLE_BORDER, LIGHTGRAY, WSAVE2RAM );
  35.     wtitle ( " Function Keys " );
  36.     col =5; 
  37.     row =1;
  38.     for ( n=0; n<12; ++n )
  39.         {
  40.         /* note sequence quarantee operator to assign FKEY labels 
  41.          * until all are done
  42.          */
  43.         if ( ( more_fkeys != 0 ) && (NULL == (label=save_labels[n]) ) )
  44.             {
  45.             more_fkeys = 0;
  46.             }
  47.         if ( n==6 )
  48.             {
  49.             col = 30;
  50.             row = 1;
  51.             }    
  52.         wbutton_add (fkeyname[n], col, row, fkeylen[n], fkeyval[n], 0 );
  53.         wgoto ( col + 5, row );
  54.         wputfl ( label, 15 );
  55.         row +=2;
  56.         }
  57.     wbutton_add ( "ESCAPE", 22, 13, 7, ESCAPE, 0 );
  58.         
  59.     do { key = wgetc (); }    
  60.     while (  ! wbutton_test(key) );
  61.             
  62.     wclose ();    
  63.     if ( key == ESCAPE ) key =0;
  64.     return key;        /* mouse_fkeys() */
  65.     }     
  66.     
  67.     
  68. /*--------------------- end of WPOPFKEY.C ----------------------*/
  69.