home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / G4MENU.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  2.0 KB  |  98 lines

  1. /*
  2.    g4menu.c  (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3.  
  4.    The activate parameter of each menu item must be the 
  5.    negative of its menu item reference number.
  6. */
  7.  
  8. #include "d4base.h"
  9. #include "w4.h"
  10. #include "g4char.h"
  11. #include "u4error.h"
  12. #include "p4misc.h"
  13.  
  14. #include <string.h>
  15.  
  16. extern  CB_WINDOW  *v4window_ptr ;
  17. extern  MENU       *v4menu ;
  18.  
  19. g4menu( GET *get_ptr, char *data_buffer, int window_ref )
  20. {
  21.    int      rc, len_menu_data, old_window_ref ;
  22.    char    *menu_data ;
  23.  
  24.    g4message_do( "" ) ;
  25.  
  26.    old_window_ref =  w4select( -1 ) ;
  27.    w4select( window_ref ) ;
  28.  
  29.    if ( get_ptr->width_data < 0  ||  get_ptr->width_data >= MAX_GET_WIDTH )
  30.       u4error( E_INTERNAL, "g4menu", (char *) 0 ) ;
  31.  
  32.    rc =  n4search( data_buffer ) ;
  33.    if ( rc >= 0 )
  34.       v4window_ptr->start_item =  rc ;
  35.  
  36.    rc =  n4activate( window_ref ) ;
  37.    w4select( old_window_ref ) ;
  38.    if ( rc == 0x7FFF )  rc = 0 ;
  39.  
  40.    if ( rc > 0 )
  41.    {
  42.       switch( rc )
  43.       {
  44.      case  PGUP:
  45.      case  PGDN:
  46.      case  ESC:
  47.      case  CTRL_C:
  48.      case  CTRL_HOME:
  49.      case  CTRL_END:
  50.      case  CTRL_R:
  51.      case  CTRL_N:
  52.      case  CTRL_B:
  53.      case  CTRL_Q:
  54.         return( rc ) ;
  55.  
  56.      case  LEFT:
  57.      case  UP:
  58.      case  CTRL_S:
  59.      case  CTRL_E:
  60.      case  CTRL_Z:
  61.      case  SHIFT_TAB:
  62.         return( SHIFT_TAB ) ;
  63.  
  64.      default:
  65.         return( RETURN ) ;
  66.       }
  67.    }
  68.  
  69.    menu_data =  v4menu[-rc].item_ptr ;
  70.    len_menu_data =  (int) strlen(menu_data) ;
  71.    if ( len_menu_data > MAX_GET_WIDTH )
  72.       len_menu_data =  MAX_GET_WIDTH ;
  73.  
  74.    memset( data_buffer, (int) ' ', (size_t) MAX_GET_WIDTH ) ;
  75.    memcpy( data_buffer, menu_data, (size_t) len_menu_data ) ;
  76.  
  77.    g4message_do( get_ptr->message ) ;
  78.  
  79.    return( RETURN ) ;
  80. }
  81.  
  82.  
  83. g4menu_help( GET *get_ptr, char *data_buffer, int window_ref )
  84. {
  85.    int  rc ;
  86.  
  87.    rc =  g4char() ;
  88.  
  89.    if ( rc == F1 || rc == CTRL_L )
  90.    {
  91.       rc =  g4menu( get_ptr, data_buffer, window_ref ) ;
  92.       if ( rc == ESC || rc == CTRL_Q )  rc = -1 ;
  93.       return( rc ) ;
  94.    }
  95.    else
  96.       return( rc ) ;
  97. }
  98.