home *** CD-ROM | disk | FTP | other *** search
- /*
- g4menu.c (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- The activate parameter of each menu item must be the
- negative of its menu item reference number.
- */
-
- #include "d4base.h"
- #include "w4.h"
- #include "g4char.h"
- #include "u4error.h"
- #include "p4misc.h"
-
- #include <string.h>
-
- extern CB_WINDOW *v4window_ptr ;
- extern MENU *v4menu ;
-
- g4menu( GET *get_ptr, char *data_buffer, int window_ref )
- {
- int rc, len_menu_data, old_window_ref ;
- char *menu_data ;
-
- g4message_do( "" ) ;
-
- old_window_ref = w4select( -1 ) ;
- w4select( window_ref ) ;
-
- if ( get_ptr->width_data < 0 || get_ptr->width_data >= MAX_GET_WIDTH )
- u4error( E_INTERNAL, "g4menu", (char *) 0 ) ;
-
- rc = n4search( data_buffer ) ;
- if ( rc >= 0 )
- v4window_ptr->start_item = rc ;
-
- rc = n4activate( window_ref ) ;
- w4select( old_window_ref ) ;
- if ( rc == 0x7FFF ) rc = 0 ;
-
- if ( rc > 0 )
- {
- switch( rc )
- {
- case PGUP:
- case PGDN:
- case ESC:
- case CTRL_C:
- case CTRL_HOME:
- case CTRL_END:
- case CTRL_R:
- case CTRL_N:
- case CTRL_B:
- case CTRL_Q:
- return( rc ) ;
-
- case LEFT:
- case UP:
- case CTRL_S:
- case CTRL_E:
- case CTRL_Z:
- case SHIFT_TAB:
- return( SHIFT_TAB ) ;
-
- default:
- return( RETURN ) ;
- }
- }
-
- menu_data = v4menu[-rc].item_ptr ;
- len_menu_data = (int) strlen(menu_data) ;
- if ( len_menu_data > MAX_GET_WIDTH )
- len_menu_data = MAX_GET_WIDTH ;
-
- memset( data_buffer, (int) ' ', (size_t) MAX_GET_WIDTH ) ;
- memcpy( data_buffer, menu_data, (size_t) len_menu_data ) ;
-
- g4message_do( get_ptr->message ) ;
-
- return( RETURN ) ;
- }
-
-
- g4menu_help( GET *get_ptr, char *data_buffer, int window_ref )
- {
- int rc ;
-
- rc = g4char() ;
-
- if ( rc == F1 || rc == CTRL_L )
- {
- rc = g4menu( get_ptr, data_buffer, window_ref ) ;
- if ( rc == ESC || rc == CTRL_Q ) rc = -1 ;
- return( rc ) ;
- }
- else
- return( rc ) ;
- }
-