home *** CD-ROM | disk | FTP | other *** search
-
- /* Screen I/O Example Program w4example.c
- (c)Copyright Sequiter Software Inc., 1987, 1988, 1989. All rights reserved.
- */
-
- #include "d4all.h" /* For Conversion Routine Prototype */
- #include "w4.h"
- #include "g4char.h"
-
- #include <string.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include <time.h>
-
- #ifdef TURBO
- unsigned int _stklen = 10000 ;
- #endif
-
- static int a_pulldown(int) ;
- static int b_pulldown(int) ;
- static int lotus_example(int) ;
- static int menu_entry(int) ;
- static int double_example(int) ;
- static int date_example(int) ;
- static int valid_example(int) ;
- static int delimiter_example(int) ;
- static int handle_example(int) ;
- static int position_window(int) ;
- static int search_example(int) ;
- static int color_menu(int) ;
- static int skipping(int) ;
- static int row_column(int) ;
- static int random_menu(int) ;
- static int get_entry_help(int) ;
- static int lotus_help(int) ;
- static int search_help(int) ;
- static int display_item(int) ;
- static int select_file(char *) ;
- static int skipping_help(int) ;
- static int row_column_display(int) ;
-
- static int is_date_valid( GET * ) ;
- static int plus_or_minus( GET *) ;
- static int before_t( GET *) ;
- static int n_valid( GET *) ;
- static int minus_four( GET *) ;
-
- extern int v4default_window ;
- extern MENU *v4menu ;
-
-
- main()
- {
- int main_menu, w_ref, w_get_example ;
-
- w_ref = w4define( 5,10, 19,68 ) ;
- w4clear( -1 ) ;
- w4cursor( -1,-1 ) ;
- w4activate( w_ref ) ;
-
- w4centre( 1, "Code Base" ) ;
- w4centre( 3, "Window, Menu and Data Entry Examples" ) ;
- w4centre( 5, "(c)Copyright Sequiter Software Inc., 1987, 1988, 1989" ) ;
- w4centre( 9, "Source to this example is in file \'w4example.c\'" ) ;
- w4centre( 11,"Press a key to continue" ) ;
-
- g4char() ;
-
- /* Main Menu Definition */
- main_menu = w4define( -1,-1,-1,-1 ) ;
- w4title( 0,-1, " Main Menu ", F_WHITE | F_INTENSE ) ;
-
- n4skip_over( n4( "" ), 1 ) ;
- n4( "Pulldown Menu - Type A" ) ; n4action( a_pulldown) ;
- n4key( 'P', 0,0 ) ;
- n4( "Pulldown Menu - Type B" ) ; n4action( b_pulldown) ;
- n4key( 'P', 0,0 ) ;
- n4( "Lotus-style Menu" ) ; n4action( lotus_example) ;
- n4key( 'L', 0,0 ) ;
- n4( "Get Examples" ) ; n4action( n4sub_menu );
- n4ptr_save( &w_get_example ) ;
- n4key( 'G', 0,0 ) ;
- n4( "File Name Search" ) ; n4action( search_example) ;
- n4key( 'F', 0,0 ) ;
- #ifndef UNIX
- n4( "Color Menu" ) ; n4action( color_menu) ;
- n4key( 'C', 0,0 ) ;
- #endif
- n4( "Menu Item Skipping" ) ; n4action( skipping) ;
- n4key( 'M', 0,0 ) ;
- n4( "Columns and Rows" ) ; n4action( row_column ) ;
- n4key( 'C', 0,0 ) ;
- n4( "Random Menu" ) ; n4action( random_menu ) ;
- n4key( 'R', 0,0 ) ;
- n4skip_over( n4( "" ), 1 ) ;
- n4( "Exit" ) ; n4parm( -1 ) ;
- n4key( 'E', 0,0 ) ;
- n4skip_over( n4( "" ), 1 ) ;
-
-
- w_get_example = w4define(-1,-1,-1,-1) ;
-
- n4( "F1 - Data Entry with Menus" ) ; n4action( menu_entry) ;
- n4key( F1, 1, -1 ) ;
- n4( "F2 - Numeric Entry" ) ; n4action( double_example) ;
- n4key( F2, 1, -1 ) ;
- n4( "F3 - Date Entry" ) ; n4action( date_example) ;
- n4key( F3, 1, -1 ) ;
- n4( "F4 - Data Validation" ) ; n4action( valid_example) ;
- n4key( F4, 1, -1 ) ;
- n4( "F5 - Delimiters and Attributes"); n4action( delimiter_example) ;
- n4key( F5, 1, -1 ) ;
- n4( "F6 - Printer/Handle Example" ) ; n4action( handle_example) ;
- n4key( F6, 1, -1 ) ;
-
- n4calc( main_menu, 4,1 ) ;
-
- w4select( main_menu ) ;
- w4border( DOUBLE_TOP, F_WHITE ) ;
-
- n4activate( main_menu ) ;
-
- w4exit(0) ;
- }
-
- static int get_entry_help( int junk_parm )
- {
- int w_ref, c ;
-
- w4cursor( -1,-1 ) ;
-
- w_ref = w4define( 7,13 ,19,67 ) ;
- w4title( 0,-1, " Using Menus with Entry Areas ", F_WHITE | F_INTENSE ) ;
- w4border( DOUBLE, F_WHITE ) ;
- w4popup() ;
-
- w4activate( w_ref ) ;
-
- c = 2 ;
- w4( 1,c, "It is possible to move between entry areas, even" ) ;
- w4( w4row()+1,c, "when using menus, using the following commands:" ) ;
-
- w4( w4row()+2,c, "<Ctrl Home> - Move to the top entry area." ) ;
- w4( w4row()+1,c, "<Ctrl End> - Move to the bottom entry area." ) ;
- w4( w4row()+1,c, "<Tab> - Move to the next entry area." ) ;
- w4( w4row()+1,c, "<Shift Tab> - Move to the previous entry area." ) ;
-
- w4( w4row()+2,c, "Under Unix use <Ctrl Z> if there is no" ) ;
- w4( w4row()+1,c, "<Shift Tab> key." ) ;
- g4char() ;
-
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
-
- return 0 ;
- }
-
-
- static int menu_entry(int junk_parm)
- {
- char name_data[21], subject_data[11], date_data[10] ;
- int grade_data, name_window, subject_window, grade_window, entry_window ;
- int save_row ;
-
- /* Initialize the Data */
- memset( name_data, (int) ' ', sizeof(name_data) ) ;
- name_data[20] = '\0' ;
- memset( subject_data,(int) ' ', sizeof(subject_data) ) ;
- subject_data[10] = '\0' ;
- memset( date_data, (int) ' ', sizeof(date_data) ) ;
- date_data[8] = '\0' ;
- grade_data = 0 ;
-
- /* Define the Windows for the Menu Data Entry */
- name_window = w4define(-1,-1,-1,-1) ;
-
- n4( "Menu Entry Help" ) ;
- n4action( get_entry_help ) ;
- n4skip_over( n4(""), 1 ) ;
-
- n4( "Alice Wonder" ) ;
- n4( "Fred Calvert" ) ;
- n4( "Jim Roberts" ) ;
- n4( "John Short" ) ;
- n4( "Lucy Williams" ) ;
- n4( "Tony Smith" ) ;
-
- subject_window = w4define(-1,-1,-1,-1) ;
-
- n4( "Menu Entry Help" ) ;
- n4action( get_entry_help ) ;
- n4skip_over( n4(""), 1 ) ;
-
- n4( "Biology " ) ;
- n4( "Chemistry" ) ;
- n4( "English " ) ;
- n4( "History " ) ;
- n4( "Math " ) ;
- n4( "Physics " ) ;
-
- grade_window = w4define(-1,-1,-1,-1) ;
-
- n4( "Menu Entry Help" ) ;
- n4action( get_entry_help ) ;
- n4skip_over( n4(""), 1 ) ;
-
- n4( " 85 (A)" ) ; n4key( 'A', 1, 6 ) ;
- n4( " 75 (B)" ) ; n4key( 'B', 1, 6 ) ;
- n4( " 65 (C)" ) ; n4key( 'C', 1, 6 ) ;
- n4( " 55 (D)" ) ; n4key( 'D', 1, 6 ) ;
- n4( " 45 (F)" ) ; n4key( 'F', 1, 6 ) ;
-
- /* Specify the GET Screen */
- entry_window = w4define( 5,10, 21,70 ) ;
- w4border( SINGLE, F_WHITE ) ;
- w4popup() ;
-
- w4activate( entry_window ) ;
-
- w4centre( 2, "Example Entry Screen Using Menus" ) ;
-
- #define C1 4
- #define C2 13
- #define C3 36
-
- w4( 5,C1, "Name" ) ;
- w4( w4row(),C3, "(May use menu)" ) ;
- g4( w4row(),C2, name_data ) ;
- g4call( g4menu_help, name_window ) ;
- g4message( "Press F1 for Entry Possibilities" ) ;
-
- w4( w4row()+2,C1, "Subject" ) ;
- w4( w4row(),C3, "(Must use menu)" ) ;
- g4( w4row(),C2, subject_data ) ;
- g4call( g4menu, subject_window ) ;
-
- w4( w4row()+2,C1, "Grade" ) ;
- w4( w4row(),C3, "(May use menu)" ) ;
- g4int( w4row(),C2, &grade_data ) ;
- g4picture( "999" ) ;
- g4call( g4menu_help, grade_window ) ;
- g4message( "Press F1 for Entry Possibilities" ) ;
-
- w4( w4row()+2,C1, "Date" ) ;
- w4( w4row(),C3, "(No menu available)") ;
- g4date( w4row(),C2, date_data ) ;
- g4picture( "MMM DD/CCYY" ) ;
- g4message( "The format is MMM DD/CCYY; Example: Mar 30/1989" ) ;
- save_row = w4row() ;
-
- n4get_calc( entry_window ) ;
- g4read() ;
-
- w4( save_row+2,C2, "Press any key to continue" ) ;
- g4char() ;
-
- w4deactivate( entry_window ) ;
- w4close( entry_window ) ;
- w4close( name_window ) ;
- w4close( subject_window ) ;
- w4close( grade_window ) ;
-
- w4cursor( -1,-1 ) ;
-
- return 0 ;
- }
-
-
- static int double_example(int junk_parm)
- {
- double d1, d2, d4 ;
- char n1[10], n2[10], n3[10], n4[10] ;
-
- int r, save_r, c1, c2, c4, w_ref ;
-
- w_ref = w4define( 0,0,23,79 ) ;
- w4popup() ;
- w4border( DOUBLE, B_WHITE ) ;
- w4activate( w_ref ) ;
-
- r = 4 ; c1 = 20 ; c2 = 34 ; c4 = 50 ;
- d1 = 1234.0 ; d2 = -4.2 ; d4 = 0.0 ;
-
- w4attribute( F_WHITE | F_INTENSE ) ;
- w4centre( r++, "Double/Numeric Examples" ) ;
- w4attribute( F_WHITE ) ;
- ++r ;
-
- w4( ++r,c1, "Picture" ) ; w4( r,c2, "Data" ) ; w4( r,c4, "Results" ) ;
-
- save_r = ++r ;
-
- w4( ++r, c1, "Default" ) ;
- g4double( r, c2, &d4 ) ;
- g4message( "2 Decimals, 8 Width" ) ;
-
- w4( ++r, c1, "9999" ) ;
- g4double( r, c2, &d1 ) ;
- g4picture( "9999" ) ;
- g4message( "All Digits" ) ;
-
- w4( ++r, c1, "####.#" ) ;
- g4double( r, c2, &d2 ) ;
- g4picture( "####.#" ) ;
- g4message( "One Decimal" ) ;
-
- w4( ++r, c1, "Default" ) ;
- strcpy( n1, " -34.678" ) ;
- g4numeric( r, c2, n1 ) ;
- g4message( "Numeric Example" ) ;
-
- w4( ++r, c1, "####" ) ;
- strcpy( n2, "8431" ) ;
- g4numeric( r, c2, n2 ) ;
- g4picture( "####" ) ;
-
- w4( ++r, c1, "9.9999" ) ;
- strcpy( n3, " " ) ;
- g4numeric( r, c2, n3 ) ;
- g4picture( "9.9999" ) ;
- g4message( "Initially Blank" ) ;
-
- w4( ++r, c1, "999.99" ) ;
- strcpy( n4, " 1.23" ) ;
- g4numeric( r, c2, n4 ) ;
- g4picture( "999.99" ) ;
-
- g4read() ;
-
- r = save_r ;
-
- w4double( ++r, c4, d4, 8, 2 ) ;
- w4double( ++r, c4, d1, 4, 0 ) ;
- w4double( ++r, c4, d2, 6, 1 ) ;
- w4( ++r, c4, n1 ) ;
- w4( ++r, c4, n2 ) ;
- w4( ++r, c4, n3 ) ;
- w4( ++r, c4, n4 ) ;
- ++r ;
- w4( ++r, c1, "Press any key to continue ..." ) ;
- w4cursor( -1,-1 ) ;
- g4char() ;
-
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
-
- return 0 ;
- }
-
-
- static int date_example(int junk_parm)
- {
- int r, save_r, i_data, c1, c2, c4, i, w_ref ;
- char date_data[6][8] ;
-
- w_ref = w4define( 0,0, 23,79 ) ;
- w4popup() ;
- w4border( PANEL, F_WHITE ) ;
- w4activate( w_ref ) ;
-
- memcpy( date_data[0], "19890228", 8 ) ;
- memcpy( date_data[1], "19881030", 8 ) ;
- memcpy( date_data[2], "19420622", 8 ) ;
- memcpy( date_data[3], " ", 8 ) ;
- memcpy( date_data[4], "19670701", 8 ) ;
-
- r = 4 ; i_data = 0 ; c1 = 20 ; c2 = 34 ; c4 = 50 ;
-
- w4attribute( F_WHITE | F_INTENSE ) ;
- w4centre( r++, "Date Entry Examples" ) ;
- w4attribute( F_WHITE ) ;
- ++r ;
-
- w4( ++r, c1, "Picture" ) ; w4( r, c2, "Data" ) ; w4( r, c4, "Results") ;
-
- save_r = ++r ;
-
- w4( ++r, c1, DEFAULT_DATE ) ;
- g4date( r, c2, date_data[i_data++] ) ;
- g4message( "This is the default date picture." ) ;
-
- w4( ++r, c1, "CCYY.MM.DD" ) ;
- g4date( r, c2, date_data[i_data++] ) ;
- g4picture( "CCYY.MM.DD" ) ;
-
- w4( ++r, c1, "MM/DD/YY" ) ;
- g4date( r, c2, date_data[i_data++] ) ;
- g4picture( "MM/DD/YY" ) ;
-
- w4( ++r, c1, "MMM DD/CCYY" ) ;
- g4date( r, c2, date_data[i_data++] ) ;
- g4picture( "MMM DD/CCYY" ) ;
- g4message( "A possible entry is \'Jan 01/1989\'" ) ;
-
- w4( ++r, c1, "DD/MMM" ) ;
- g4date( r, c2, date_data[i_data++] ) ;
- g4picture( "DD/MMM" ) ;
-
- g4read() ;
-
- for ( i= 0; i< i_data; i++ )
- w4num( save_r+i+1, c4, date_data[i], 8 ) ;
-
- ++r ;
- w4( ++r, c1, "Press any key to continue ..." ) ;
- w4cursor( -1,-1 ) ;
- g4char() ;
-
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
-
- return 0 ;
- }
-
-
- static int delimiter_example(int junk_parm)
- {
- char data1[10], data2[10], data3[8], data4[10] ;
- int r, save_r, c1, c2, c4, l1, l2, w_ref ;
-
- w_ref = w4define( 0,0, 23,79 ) ;
- w4popup() ;
- w4border( SINGLE, F_GREEN ) ;
- w4activate( w_ref ) ;
-
- r = 4 ; c1 = 14; c2 = 36 ; c4 = 52 ;
-
- w4attribute( F_WHITE | F_INTENSE ) ;
- w4centre( r++, "Color/Screen/Delimiter Examples" ) ;
- w4attribute( F_BLUE | F_GREEN ) ;
- ++r ;
-
- w4( ++r,c1, "Description" ) ; w4( r,c2, "Data") ; w4( r,c4, "Results" ) ;
-
- save_r = ++r ;
-
- w4( ++r,c1, "Small Screen Width" ) ;
- g4delimiter( "[]" ) ;
- g4attribute( F_RED | F_BLUE ) ;
- strcpy( data1, "abcdefgh" ) ;
- g4( r, c2, data1 ) ;
- g4width( 6, 4 ) ;
- g4message( "The data width is 6 and the screen width is 4" ) ;
-
- w4( ++r,c1, "Phone" ) ;
- g4delimiter( "!!" ) ;
- g4attribute( F_WHITE | F_INTENSE | B_WHITE | B_BLINK ) ;
- strcpy( data2, "444444444" ) ;
- g4( r, c2, data2 ) ;
- g4picture( "999-9999" ) ;
- g4message( "North American Phone Number" ) ;
-
- w4( ++r,c1, "Postal Code" ) ;
- strcpy( data3, "T6E 0T8" ) ;
- g4delimiter( " " ) ;
- g4attribute( F_RED | F_GREEN ) ;
- g4( r,c2, data3 ) ;
- g4picture( "!9! 9!9" ) ;
- g4message( "Canadian Postal Code (Picture: \"!9! 9!9\" )" ) ;
-
- w4( ++r,c1, "Variety" ) ;
- strcpy( data4, "a1 jT8kN" ) ;
- g4( r,c2, data4 ) ;
- g4picture( "!9#ALNXY" ) ;
- g4message( "Read with a variety of picture characters: \'!9#ALNXY\'") ;
-
- /* Logical Reads */
- l1 = 0 ; l2 = 1 ;
- g4delimiter( "##" ) ;
-
- w4( ++r,c1, "Logical One" ) ;
- g4logical( r,c2, &l1 ) ;
- g4picture( "L" ) ;
- g4message( "Logical Read using \'g4logical\' with Picture \"L\"" ) ;
-
- w4( ++r,c1, "Logical Two" ) ;
- g4logical( r,c2, &l2 ) ;
- g4picture( "Y" ) ;
- g4message( "Logical Read using \'g4logical\' with Picture \"Y\"" ) ;
-
- g4read() ;
-
- w4attribute( F_WHITE ) ; /* Back to the defaults */
- g4attribute( B_WHITE ) ;
- g4delimiter( "\x00\x00" ) ;
-
- r = save_r ;
-
- w4num( ++r, c4, data1, 6 ) ;
- w4num( ++r, c4, data2, 8 ) ;
- w4num( ++r, c4, data3, 7 ) ;
- w4num( ++r, c4, data4, 7 ) ;
- w4int( ++r, c4, l1, 1 ) ;
- w4int( ++r, c4, l2, 1 ) ;
-
- ++r ;
- w4( ++r, c1, "Press any key to continue ..." ) ;
- w4cursor( -1,-1 ) ;
- g4char() ;
-
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
-
- return 0 ;
- }
-
-
- static int is_date_valid( GET *get_ptr )
- {
- if ( memcmp( (char *) get_ptr->data+ 2, "80", 2 ) >= 0 )
- {
- w4display( " Date Entry Error ", "The Date Must be Before 1980", (char *) 0) ;
- return -1 ;
- }
- return 0 ;
- }
-
-
- static int minus_four( GET *get_ptr )
- {
- if ( * ((int *)get_ptr->data) < -4 ) return 0 ;
- w4display( " Entry Error ", "Must be Less Than -4", (char *) 0 ) ;
- return -1 ;
- }
-
-
- static int plus_or_minus( GET *get_ptr )
- {
- switch( get_ptr->type )
- {
- case 'l':
- if ( *((long *)get_ptr->data) > 1 ||
- *((long *)get_ptr->data) < -1 ) return 0 ;
- break ;
-
- case 'd':
- if ( *((double *)get_ptr->data) > 1.0 ||
- *((double *)get_ptr->data) <-1.0 ) return 0 ;
- break ;
- }
- w4display( " Entry Error ", "Not less than -1 or greater than 1", (char *) 0 ) ;
- return -1 ;
- }
-
-
- static int before_t( GET *get_ptr )
- {
- if ( *((char *)get_ptr->data) <= 'S' ) return 0 ;
- w4display( " Illegal Letter ", "Must start with a letter before \'T\'", (char *) 0 ) ;
- return -1 ;
- }
-
-
- static int n_valid( GET *get_ptr )
- {
- if ( c4atod( (char *) get_ptr->data, get_ptr->width_data) < -18.5 ) return 0 ;
- w4display( " Illegal Number ", "Must be less than -18.5", (char *) 0 ) ;
- return -1 ;
- }
-
-
- static int valid_example(int junk_parm)
- {
- int i_data, r, save_r, c1, c2, c4, w_ref ;
- long l_data ;
- double d_data ;
- char dt_data[10], c_data[10], n_data[10] ;
-
- w_ref = w4define( 0,0, 23,79 ) ;
- w4popup() ;
- w4border( PANEL, F_WHITE ) ;
- w4activate( w_ref ) ;
-
- c1 = 20 ; c2 = 34 ; c4 = 50 ;
- r = 4 ;
-
- i_data = -4 ;
- l_data = 2 ;
- d_data = -2.0 ;
-
- strcpy( n_data, " -19.234" ) ;
- strcpy( c_data, "TEST DATA" ) ;
- strcpy( dt_data, "19790101" ) ;
-
- w4attribute( F_WHITE | F_INTENSE ) ;
- w4centre( r++, "User Defined Validation Examples" ) ;
- w4attribute( F_WHITE ) ;
- ++r ;
-
- w4( ++r,c1, "Picture" ) ; w4( r,c2, "Data" ) ; w4( r,c4, "Results") ;
-
- save_r = ++r ;
-
- w4( ++r,c1, "Date:" ) ;
- g4date( r,c2, dt_data ) ;
- g4valid( is_date_valid ) ;
- g4message( "The date must be before 1980" ) ;
-
- w4( ++r, c1, "Integer:" ) ;
- g4int( r, c2, &i_data ) ;
- g4valid( minus_four ) ;
- g4message( "This integer must be less than -4" ) ;
-
- w4( ++r, c1, "Long:" ) ;
- g4long(r, c2, &l_data ) ;
- g4valid( plus_or_minus ) ;
- g4message( "This long must be less than -1 or greater than 1" ) ;
-
- w4( ++r, c1, "Double:" ) ;
- g4double(r, c2, &d_data ) ;
- g4valid( plus_or_minus ) ;
- g4message( "This double must be less than -1 or greater than 1") ;
-
- w4( ++r, c1, "Character:" ) ;
- g4( r, c2, c_data ) ;
- g4upper() ;
- g4valid( before_t ) ;
- g4message( "The first character must be less than \'T\'" ) ;
-
- w4( ++r, c1, "Numeric:" ) ;
- g4numeric(r, c2, n_data ) ;
- g4valid( n_valid ) ;
- g4message( "This numeric character string must be less than -18.5" ) ;
-
- g4read() ;
-
- r = save_r ;
-
- w4( ++r, c4, dt_data ) ;
- w4int( ++r, c4, i_data, 4 ) ;
- w4long( ++r, c4, l_data, 8 ) ;
- w4double( ++r, c4, d_data, 8,2 ) ;
- w4( ++r, c4, c_data ) ;
- w4( ++r, c4, n_data ) ;
-
- ++r ;
- w4( ++r, c1, "Press any key to continue ...") ;
- w4cursor( -1,-1 ) ;
- g4char() ;
-
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
-
- return 0 ;
- }
-
-
- static int handle_example( int junk_parm )
- {
- int r, choice, w_ref ;
-
- #ifndef UNIX
- char save_screen[4000] ;
-
- /* Save the complete screen as writing to the screen with handles
- destroys it. */
- w4read( 0,0, save_screen, sizeof(save_screen) ) ;
- #endif
-
- w_ref = w4define( 0,0,0,60 ) ; /* The Window Width is Important */
- w4handle( 1 ) ;
- w4cursor( 24,0 ) ; /* Move the cursor to the end of the screen */
-
- r = 0 ;
- ++r ;
-
- w4( ++r,0, " This output is going to handle \'1\'. Observe that" ) ;
- w4( ++r,0, "output to a handle is completely different than direct" ) ;
- w4( ++r,0, "screen output." ) ;
- ++r ;
- w4( ++r,0, "Press a key to continue ..." ) ;
-
- g4char() ;
-
- r += 3 ;
- w4( ++r,0, "Notice that output is quite a bit slower." ) ;
-
- r += 2 ;
- w4( ++r, 10, "Selections: " ) ;
- ++r ;
- w4( ++r, 13, "S - Screen Output" ) ;
- w4( ++r, 13, "P - Printer Output" ) ;
-
- ++r ;
- w4( ++r, 10, "Press key according to selection ... " ) ;
-
- choice = toupper( g4char() ) ;
-
- if ( choice == (int) 'P' )
- {
- r = 0 ;
- w4handle( 4 ) ;
- w4centre( r, "PRINTER OUTPUT" ) ;
- }
- else
- {
- w4handle( 1 ) ;
- r += 5 ;
- w4centre( r, "SCREEN OUTPUT" ) ;
- }
-
- ++r ;
- w4( ++r,0, "Now some other output routines will be executed:" ) ;
- ++r ;
- w4( ++r,0, "w4int - " ) ;
- w4int( r, w4col(), 4, 8 ) ;
-
- w4( ++r,0, "w4long - " ) ;
- w4long(r, w4col(), -10L, 8 ) ;
- w4(++r,0, "w4double - " ) ;
- w4double( r, w4col(), 4.4, 8, 2 ) ;
-
- if ( choice == (int) 'P' ) w4eject() ;
-
- w4handle( 1 ) ;
- r = w4row()+1 ;
- w4( ++r,0, "Press a key to restore the saved screen" ) ;
- w4( ++r,0, "and to return to the main menu" ) ;
- g4char() ;
-
- w4close( w_ref ) ;
-
- #ifdef UNIX
- /* Force a Complete Screen Redraw */
- w_ref = w4define( 0,0, 24,79 ) ;
- w4activate( w_ref ) ;
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
- #else
- /* Restore the screen */
- w4write( 0,0, save_screen, sizeof(save_screen) ) ;
- w4cursor( -1,-1 ) ;
- #endif
-
- return 0 ;
- }
-
- static int start_row = 10, start_col = 20, end_row = 14, end_col = 59 ;
-
- static int position_window( int command )
- {
- int pop_window, rc ;
-
- switch ( command )
- {
- case 0: /* Move Up */
- start_row-- ;
- if ( start_row >= 0 ) end_row-- ;
- break ;
-
- case 1: /* Move Down */
- end_row++ ;
- if ( end_row <= 23 ) start_row++ ;
- break ;
-
- case 2: /* Move Right */
- end_col++ ;
- if ( end_col <= 79 ) start_col++ ;
- break ;
-
- case 3: /* Move Left */
- start_col-- ;
- if ( start_col >= 0 ) end_col-- ;
- break ;
-
- case 4: /* Size Up */
- start_row-- ;
- break ;
-
- case 5: /* Size Down */
- if ( start_row < end_row ) start_row++ ;
- break ;
-
- case 6: /* Size Right */
- end_col++ ;
- break ;
-
- case 7: /* Size Left */
- if ( start_col < end_col ) end_col-- ;
- break ;
- }
-
- if ( start_row < 0 ) start_row = 0 ;
- if ( end_row > 23 ) end_row = 23 ;
- if ( start_col < 0 ) start_col = 0 ;
- if ( end_col > 79 ) end_col = 79 ;
-
- pop_window = w4define( start_row, start_col, end_row, end_col ) ;
- w4attribute( F_INTENSE | F_BLUE | F_GREEN ) ;
- w4popup() ;
- w4border( PANEL, F_GREEN ) ;
- w4activate( pop_window ) ;
-
- if ( w4height(-1) > 0 && w4width(-1) > 0 )
- w4centre( (end_row-start_row-2)/2, "Enter a menu command character.") ;
- rc = g4char() ;
-
- w4deactivate( pop_window ) ;
- w4close( pop_window ) ;
-
- return( rc ) ;
- }
-
- static int a_pulldown(int junk_parm)
- {
- int mov , size, pop_menu ;
-
- n4key_special( ESC, CTRL_C, 0x100, 0x7FFF ) ;
-
- pop_menu = w4define( -1,-1,-1,-1 ) ;
- n4( "Move <Alt M>");
- n4reaction( n4sub_menu);
- n4ptr_save( &mov) ;
- n4key( ALT_M,0,10);
-
- n4( "Size <Alt S>");
- n4reaction( n4sub_menu);
- n4ptr_save( &size) ;
- n4key( ALT_S,0,10);
-
- n4( "Exit <Alt X>");
- n4parm( ALT_X);
- n4key( ALT_X,1,10);
-
- mov = w4define( -1,-1,-1,-1 ) ;
- n4( "Up" ) ; n4reaction( position_window); n4parm(0) ;
- n4( "Down" ) ; n4reaction( position_window); n4parm(1) ;
- n4( "Right" ) ; n4reaction( position_window); n4parm(2) ;
- n4( "Left" ) ; n4reaction( position_window); n4parm(3) ;
-
- size = w4define( -1,-1,-1,-1 ) ;
- n4( "Up" ) ; n4reaction( position_window); n4parm(4) ;
- n4( "Down" ) ; n4reaction( position_window); n4parm(5) ;
- n4( "Right" ) ; n4reaction( position_window); n4parm(6) ;
- n4( "Left" ) ; n4reaction( position_window); n4parm(7) ;
-
- n4pulldown( pop_menu ) ;
-
- n4activate( pop_menu ) ;
-
- w4close( mov ) ;
- w4close( size ) ;
- w4close( pop_menu ) ;
-
- return( 0 ) ;
- }
-
- static int b_pulldown(int junk_parm)
- {
- int mov , size, pop_menu ;
-
- n4key_special( ESC, CTRL_C, 0, 0 ) ;
-
- pop_menu = w4define( 0,0, 0,79 ) ;
- w4popup() ; n4horizontal() ;
- n4item_width( 8 ) ;
- n4( "Move" ); n4action( n4sub_menu) ;
- n4ptr_save( &mov ) ;
- n4key(0,0,-1);
-
- n4( "Size" );
- n4action( n4sub_menu) ;
- n4ptr_save( &size ) ;
- n4key(0,0,-1);
-
- n4( "Exit" ) ;
- n4parm( ALT_X ) ;
- n4key(0,0,-1);
-
- mov = w4define( 1,0, 6,8 ) ;
- w4popup() ; w4border( SINGLE, F_WHITE ) ; n4arrow_exit() ;
-
- n4( "Up" ) ;
- n4action( position_window ) ;
- n4parm(0) ;
- n4key( 0,0, -1 ) ;
-
- n4( "Down" ) ;
- n4action( position_window ) ;
- n4parm( 1 ) ;
- n4key( 0,0, -1 ) ;
-
- n4( "Right" ) ;
- n4action( position_window ) ;
- n4parm( 2 ) ;
- n4key( 0,0, -1 ) ;
-
- n4( "Left" ) ;
- n4action( position_window ) ;
- n4parm( 3 ) ;
- n4key( 0,0, -1 ) ;
-
- size = w4define( 1,8, 6,16 ) ;
- w4popup() ; w4border( SINGLE, F_WHITE ) ; n4arrow_exit() ;
-
- n4( "Up" ) ;
- n4action( position_window ) ;
- n4parm( 4 ) ;
- n4key( 0,0, -1 ) ;
-
- n4( "Down" ) ;
- n4action( position_window ) ;
- n4parm( 5 ) ;
- n4key( 0,0, -1 ) ;
-
- n4( "Right" ) ;
- n4action( position_window ) ;
- n4parm( 6 ) ;
- n4key( 0,0, -1 ) ;
-
- n4( "Left" ) ;
- n4action( position_window ) ;
- n4parm( 7 ) ;
- n4key( 0,0, -1 ) ;
-
- n4pulldown( pop_menu ) ;
-
- n4activate( pop_menu ) ;
-
- w4close( mov ) ;
- w4close( size ) ;
- w4close( pop_menu ) ;
-
- return( 0 ) ;
- }
-
-
- static int language_display( int ) ;
-
- static int language_display( int item_ref )
- {
- char buffer[80] ;
- char *ptr ;
- int i ;
-
- ptr = (char *) n4ptr_get(item_ref) ;
- i = n4int_get(item_ref) ;
-
- memset( buffer, (int) 0, sizeof(buffer) ) ;
- strcpy( buffer, ptr ) ;
- c4ltoa( (long) i, buffer+strlen(buffer), 2 ) ;
-
- return( w4display( "", buffer, (char *) 0 ) ) ;
- }
-
-
- static int lotus_help( int junk_parm )
- {
- int w_ref, r, c ;
-
- w_ref = w4define( 3,10, 21,69 ) ;
- w4popup() ;
- w4border( DOUBLE, B_GREEN ) ;
-
- w4title( 0, -1, " Lotus-style Menu Help Window ", F_WHITE | F_INTENSE ) ;
-
- w4activate( w_ref ) ;
-
- r = 1 ; c = 4 ;
- w4( ++r,c, "The Lotus-style Menus have an user interface which" ) ;
- w4( ++r,c, "operates the same manner as Lotus 123 Menus. You" ) ;
- w4( ++r,c, "have the following options:" ) ;
- ++r ;
- w4( ++r,c, " 1. Arrow left or right and then press <Enter>." ) ;
- ++r ;
- w4( ++r,c, " 2. Press the highlighted key." ) ;
- ++r ;
- w4( ++r,c, " 3. <Esc> moves up one menu." ) ;
- ++r ;
- w4( ++r,c, " 4. '/' moves to the top menu." ) ;
- ++r ;
- w4( ++r,c, "Press any key to continue ..." ) ;
-
- g4char() ;
-
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
-
- return 0 ;
- }
-
- extern int v4menu_row, v4menu_col ;
-
- /* Implements Some Lotus Style Menuing */
- static int lotus_example(int junk_parm)
- {
- int language, french, english, german ;
- #define RETURN_CODE -2
-
- language = w4define( -1,-1,-1,-1 ) ;
- n4( "French" ); n4message( "Un, Deux, Trois, Quatre, Cinq, Six" ) ;
- n4action( n4sub_menu ) ;
- n4ptr_save( &french ) ;
- n4( "English" ); n4message( "One, Two, Three, Four" ) ;
- n4action( n4sub_menu) ;
- n4ptr_save( &english ) ;
- n4( "German" ); n4message( "Eins, Zwei, Drei, Fier, Fuenf" ) ;
- n4action( n4sub_menu ) ;
- n4ptr_save( &german ) ;
- n4( "Help") ; n4message( "Lotus-style Menu Help" ) ;
- n4action( lotus_help ) ;
- n4( "Return" ); n4message( "Return from the Lotus menu example." ) ;
- n4parm( RETURN_CODE ) ;
-
- french = w4define( -1,-1,-1,-1 ) ;
- n4( "Un"); n4message( "Le nombre est un.") ;
- n4action( language_display ) ;
- n4ptr_save( "Le nombre est" ) ;
- n4int_save( 1 ) ;
- n4( "Deux"); n4message( "Le nombre est deux." ) ;
- n4action( language_display ) ;
- n4ptr_save( "Le nombre est" ) ;
- n4int_save( 2 ) ;
- n4( "Trois"); n4message( "Le nombre est trois." ) ;
- n4action( language_display ) ;
- n4ptr_save( "Le nombre est" ) ;
- n4int_save( 3 ) ;
- n4( "Quatre"); n4message( "Le nombre est quatre." ) ;
- n4action( language_display ) ;
- n4ptr_save( "Le nombre est" ) ;
- n4int_save( 4 ) ;
- n4( "Cinq"); n4message( "Le nombre est cinq." ) ;
- n4action( language_display ) ;
- n4ptr_save( "Le nombre est" ) ;
- n4int_save( 5 ) ;
- n4( "Six"); n4message( "Le nombre est six." ) ;
- n4action( language_display ) ;
- n4ptr_save( "Le nombre est" ) ;
- n4int_save( 6 ) ;
- n4( "Help") ; n4message( "Lotus-style Menu Help" ) ;
- n4action( lotus_help) ;
-
- english = w4define( -1,-1,-1,-1 ) ;
- n4( "One"); n4message( "You are on number one." ) ;
- n4action( language_display ) ;
- n4ptr_save( "The number is" ) ;
- n4int_save( 1 ) ;
- n4( "Two"); n4message( "You are on number two." ) ;
- n4action( language_display ) ;
- n4ptr_save( "The number is" ) ;
- n4int_save( 2 ) ;
- n4( "Three"); n4message( "You are on number three." ) ;
- n4action( language_display ) ;
- n4ptr_save( "The number is" ) ;
- n4int_save( 3 ) ;
- n4( "Four"); n4message( "You are on number four." ) ;
- n4action( language_display ) ;
- n4ptr_save( "The number is" ) ;
- n4int_save( 4 ) ;
- n4( "Help"); n4message( "Lotus-style Menu Help" ) ;
- n4action( lotus_help ) ;
-
- german = w4define( -1,-1,-1,-1 ) ;
- n4( "Eins"); n4message( "Sie sind auf Nummer einz" ) ;
- n4action( language_display ) ;
- n4ptr_save( "Sie sind auf Nummer" ) ;
- n4int_save( 1 ) ;
- n4( "Zwei"); n4message( "Sie sind auf Nummer zwei" ) ;
- n4action( language_display ) ;
- n4ptr_save( "Sie sind auf Nummer" ) ;
- n4int_save( 2 ) ;
- n4( "Drei"); n4message( "Sie sind auf Nummer drei" ) ;
- n4action( language_display ) ;
- n4ptr_save( "Sie sind auf Nummer" ) ;
- n4int_save( 3 ) ;
- n4( "Fier"); n4message( "Sie sind auf Nummer fier" ) ;
- n4action( language_display ) ;
- n4ptr_save( "Sie sind auf Nummer" ) ;
- n4int_save( 4 ) ;
- n4( "Fuenf"); n4message( "Sie sind auf Nummer fuenf" ) ;
- n4action( language_display ) ;
- n4ptr_save( "Sie sind auf Nummer" ) ;
- n4int_save( 5 ) ;
- n4( "Help") ; n4message( "Lotus-style Menu Help" ) ;
- n4action( lotus_help ) ;
-
- n4lotus( language ) ;
-
- while( n4activate( language ) != RETURN_CODE ) ;
-
- w4close( language ) ;
- w4close( french ) ;
- w4close( english ) ;
- w4close( german ) ;
-
- v4menu_row = 24 ;
- v4menu_col = 0 ;
-
- return 0 ;
- }
-
-
- /* File Searching Example */
-
- static int search_help( int junk_parm )
- {
- w4display( " Search Help ",
- " In this search example, you are able to type a",
- "file name. The menu highlighting bar is automatically",
- "positioned to the menu entry corresponding to the",
- "letters typed.",
- "",
- " If you type the wrong character, <Back Space> will",
- "reverse the character entry.",
- "",
- " To select a different set of files, select the search",
- "pattern menu option.",
- (char *) 0 ) ;
-
- return 0 ;
- }
-
- static int display_item( int item_ref )
- {
- w4display( " Selected File: ", v4menu[item_ref].item_ptr, (char *) 0 ) ;
- return 0 ;
- }
-
- static int select_file( char *pattern )
- {
- int w_ref, n_data, i, rc ;
- char count_data[14], *data ;
-
- for( rc = u4file_first(pattern,count_data), n_data= 0; rc == 0; n_data +=14)
- rc = u4file_next( count_data ) ;
-
- if ( n_data == 0 )
- {
- w4display( " No Files for Pattern ", pattern, (char *) 0 ) ;
- return 0 ;
- }
-
- w_ref = w4define( -1,-1,-1,-1 ) ;
-
- n4skip_over( n4(""), 1 ) ;
-
- n4( "Help" ) ;
- n4action( search_help ) ;
-
- n4skip_over( n4(""), 1 ) ;
- n4skip_over( n4( "Search" ), 1 ) ;
- n4skip_over( n4( "Pattern:" ), 1 ) ;
- n4( pattern ) ;
- n4parm( -2 ) ;
-
- n4skip_over( n4(""), 1 ) ;
-
- /* Allocate Enough File Memory */
- data = (char *) h4alloc( n_data ) ;
-
- rc = u4file_first(pattern, data ) ;
- n4( data ) ;
- n4action( display_item ) ;
-
- for ( i= 14; i< n_data ; i+= 14 )
- {
- if ( u4file_next( data+i ) != 0 ) break ;
- n4( data+i ) ;
- n4action( display_item ) ;
- }
-
- n4calc( w_ref, 2,79 ) ; /* Put in upper right hand corner */
- n4key_set( 2,1 ) ; /* ** Searching On ** */
- w4border( DOUBLE, F_WHITE ) ;
- w4title( 0,-1, " File Search ", F_WHITE ) ;
- rc = n4activate( w_ref ) ;
- w4close( w_ref ) ;
- h4free_memory( data ) ;
-
- return rc ;
- }
-
-
- static int search_example( int junk_parm )
- {
- char pattern[14] ;
- int rc, w_ref, len ;
-
- strcpy( pattern, "*.*" ) ;
-
- for( rc = select_file(pattern); rc == -2; rc = select_file(pattern) )
- {
- /* Change Pattern Selected */
- w_ref = w4define( 5,50, 9, 79 ) ;
- w4popup() ;
- w4border( DOUBLE, F_WHITE ) ;
- w4activate( w_ref ) ;
-
- w4( 1,3, "Pattern: " ) ;
- len = (int) strlen(pattern) ;
- memset( pattern+len, (int) ' ', 12-len ) ;
- pattern[12] = '\0' ;
- g4( w4row(),w4col(), pattern ) ;
- g4message( "Enter a new file pattern" ) ;
- g4upper() ;
-
- g4read() ;
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
- }
- return 0 ;
- }
-
- #ifndef UNIX
- /* Color Example */
-
- typedef struct color_data_st
- {
- char text[19] ;
- char status[4] ;
- long attribute ;
- int item_ref ;
- int mask ;
- } COLOR_DATA ;
-
- static COLOR_DATA color_data[] =
- {
- { "Foreground Blue: ", "", F_WHITE, 0, 0x01 },
- { "Foreground Green: ", "", F_WHITE, 0, 0x02 },
- { "Foreground Red: ", "", F_WHITE, 0, 0x04 },
- { "Intensity: ", "", F_WHITE, 0, 0x08 },
- { "Background Blue: ", "", F_WHITE, 0, 0x10 },
- { "Background Green: ", "", F_WHITE, 0, 0x20 },
- { "Background Red: ", "", F_WHITE, 0, 0x40 },
- { "Blinking: ", "", F_WHITE, 0, 0x80 },
- } ;
-
- typedef struct att_choice_st
- {
- char text[20] ;
- long attribute ;
- } ATT_CHOICE ;
-
- static ATT_CHOICE att_choices[] =
- {
- { "Window Attribute", 0x70L },
- { "Title Attribute", 0x0FL },
- { "Border Attribute", 0x0FL },
- } ;
-
- static char choice_data[20] ;
- static long *attribute_ptr ;
- static int explain_color(int) ;
- static int change_bits(int) ;
- static int change_choice(int) ;
- static void init_all_bits(void) ;
-
- static int explain_color(int junk_parm)
- {
- int rc, w_ref, r,c ;
-
- w_ref = w4define( 2,30, 22,79 ) ;
- w4attribute( att_choices[0].attribute ) ;
- w4title( 0,-1, " Color Window ", att_choices[1].attribute ) ;
- w4border( PANEL, att_choices[2].attribute ) ;
- w4popup() ;
- w4activate( w_ref ) ;
-
- r=0 ; c=2 ;
-
- w4( ++r,c, " You may select a menu option to toggle its" ) ;
- w4( ++r,c, "setting. For example, \'Foreground Blue\'" ) ;
- w4( ++r,c, "can be ON or OFF. As each of these eight" ) ;
- w4( ++r,c, "menu options in the Color Menu corresponds");
- w4( ++r,c, "to a bit in an attribute byte, you are" ) ;
- w4( ++r,c, "flipping the bits in the attribute bytes" ) ;
- w4( ++r,c, "being displayed. This lets you observe" ) ;
- w4( ++r,c, "all of the color possibilities." ) ;
- ++r ;
- w4( ++r,c, " You may also change the color of this" ) ;
- w4( ++r,c, "windows title or border by selecting the" ) ;
- w4( ++r,c, "\'Choice\' option." ) ;
- ++r ;
- w4( ++r,c, " Note that Code Base can also be programmed" ) ;
- w4( ++r,c, "to set the color attribute of individual menu" ) ;
- w4( ++r,c, "items or the color attribute of the currently" ) ;
- w4( ++r,c, "selected menu item." ) ;
-
- rc = g4char() ;
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
-
- return rc ;
- }
-
- static int change_bits_ptr( COLOR_DATA * ) ;
-
- static int change_bits( int item_ref )
- {
- return( change_bits_ptr( (COLOR_DATA *) n4ptr_get(item_ref)) ) ;
- }
-
- static int change_bits_ptr( COLOR_DATA *data_ptr )
- {
- *attribute_ptr ^= data_ptr->mask ;
-
- if ( *attribute_ptr & data_ptr->mask )
- {
- strcpy( data_ptr->status, "ON " ) ;
- n4attribute_item( data_ptr->item_ref, data_ptr->attribute | F_INTENSE) ;
- }
- else
- {
- strcpy( data_ptr->status, "OFF" ) ;
- n4attribute_item( data_ptr->item_ref, data_ptr->attribute ) ;
- }
-
- return 0 ;
- }
-
- static void init_all_bits()
- {
- int i ;
- *attribute_ptr ^= 0xFF ;
- for ( i=0; i< 8; i++ )
- change_bits_ptr( color_data+i ) ;
- }
-
- static int change_choice( int item_ref )
- {
- ATT_CHOICE *choice_ptr ;
- choice_ptr = (ATT_CHOICE *) n4ptr_get( item_ref ) ;
-
- attribute_ptr = &choice_ptr->attribute ;
- memcpy( choice_data, choice_ptr->text, (int) sizeof(choice_data) ) ;
- return -2 ; /* Return from 'n4activate' with this -2 code */
- }
-
- static int color_menu( int junk_parm )
- {
- int w_ref, choice_ref, i, i_ref ;
-
- n4key_special( ESC, CTRL_C, 0,0 ) ;
-
- w_ref = w4define( -1,-1,-1,-1 ) ;
- w4border( SINGLE, F_WHITE ) ;
- w4title( 0,-1, " Color Menu ", B_WHITE ) ;
-
- n4skip_over( n4( "Currently Changing:"), 1 ) ;
-
- n4( choice_data ) ;
- n4key( 0,0,-1 ) ;
- n4reaction( explain_color ) ;
- n4action( n4sub_menu ) ;
- n4ptr_save( &choice_ref ) ;
-
- n4skip_over( n4(""), 1 ) ;
-
- for ( i=0; i< 8; i++ )
- {
- color_data[i].item_ref = n4( color_data[i].text ) ;
- n4reaction( explain_color ) ;
- n4action( change_bits ) ;
- n4ptr_save( color_data+i ) ;
- n4key( 0,0, -1 ) ;
- }
-
-
- choice_ref = w4define( -1,-1,-1,-1 ) ;
- w4border( SINGLE, F_WHITE ) ;
- for ( i=2; i >= 0; i-- )
- {
- i_ref = n4( att_choices[i].text ) ;
- n4action( change_choice ) ;
- n4ptr_save( att_choices+i ) ;
- }
-
- change_choice( i_ref ) ;
- init_all_bits() ;
- n4calc( w_ref, 12,2 ) ;
-
- while( n4activate(w_ref) == -2 ) init_all_bits() ;
-
- w4close( w_ref ) ;
- w4close( choice_ref ) ;
-
- return 0 ;
- }
- #endif
-
-
- /* Skipping Example */
-
- static int main_window_ref, on_window_ref ;
-
- typedef struct count_data_st
- {
- char ptr[10] ;
- int main_item_ref, on_item_ref ;
- } COUNT_DATA ;
-
- COUNT_DATA count_data[] =
- {
- {"One"},
- {"Two"},
- {"Three"},
- {"Four"},
- } ;
-
- static int change_status( int ) ;
-
- static int change_status( int item_ref )
- {
- COUNT_DATA *count_ptr ;
- int main_on_flag ;
-
- count_ptr = (COUNT_DATA *) n4ptr_get( item_ref ) ;
- main_on_flag = n4int_get( item_ref ) ;
-
- n4skip_over( count_ptr->main_item_ref, ! main_on_flag ) ;
-
- if ( main_on_flag )
- {
- n4attribute_item( count_ptr->main_item_ref, F_WHITE | F_INTENSE ) ;
- n4attribute_item( count_ptr->on_item_ref, F_WHITE ) ;
- n4refresh( main_window_ref ) ;
- }
- else
- {
- n4attribute_item( count_ptr->main_item_ref, F_WHITE ) ;
- n4attribute_item( count_ptr->on_item_ref, F_WHITE | F_INTENSE ) ;
- }
-
- return DOWN ;
- }
-
-
- static int skipping_help( int junk_parm )
- {
- w4display( " Help for Menu Item Skipping ",
-
- " This example illustrates how individual menu items",
- "can interactively be turned on and off. When a menu item",
- "is turned off, it can no longer be chosen. This is",
- "useful when a menu item is temporarily not needed.",
- "",
- " Menu items \'One\', \'Two\', \'Three\' and \'Four\' can",
- "all be temporarily turned off by selecting them. To turn",
- "one of these menu items back on, choose option \'Turn On\'.",
- (char *) 0 ) ;
- return 0 ;
- }
-
- static int skipping( int junk_parm )
- {
- int i, item_ref ;
-
- main_window_ref = w4define( -1,-1,-1,-1 ) ;
- w4border( DOUBLE, F_WHITE ) ;
- w4popup() ;
- n4key_set( 0,0 ) ;
-
- item_ref = n4( "Help" ) ;
- n4attribute_item( item_ref, F_WHITE | F_INTENSE ) ;
- n4action( skipping_help ) ;
-
- n4skip_over( n4( "" ), 1 ) ;
-
- item_ref = n4( "Turn On") ;
- n4attribute_item( item_ref, F_WHITE | F_INTENSE ) ;
- n4action( n4sub_menu ) ;
- n4ptr_save( &on_window_ref ) ;
- n4skip_over( n4( "" ), 1) ;
-
- for ( i=0; i<4; i++ )
- {
- count_data[i].main_item_ref = n4( count_data[i].ptr ) ;
- n4action( change_status ) ;
- n4ptr_save( count_data+i ) ;
- n4int_save( 0 ) ;
- n4attribute_item( count_data[i].main_item_ref, F_WHITE | F_INTENSE ) ;
- }
-
- on_window_ref = w4define( -1,-1,-1,-1 ) ;
- w4border( DOUBLE, F_WHITE ) ;
- w4popup() ;
- n4key_set( 0,0 ) ;
-
- for ( i=0; i<4; i++ )
- {
- count_data[i].on_item_ref = n4( count_data[i].ptr ) ;
- n4action( change_status ) ;
- n4ptr_save( count_data+i ) ;
- n4int_save( 1 ) ;
- }
-
- n4calc( main_window_ref, 13,2 ) ;
-
- n4activate( main_window_ref ) ;
-
- w4close(main_window_ref) ;
- w4close(on_window_ref) ;
-
- return 0 ;
- }
-
-
- static int row_column_display( int item_ref )
- {
- int w_ref, rc ;
- int r,c ;
-
- c = n4int_get(item_ref) & 7 ;
- r = n4int_get(item_ref) / 8 ;
-
- w_ref = w4define( r*10, c*34, r*10+4, c*34+10 ) ;
- w4popup() ;
- w4border( PANEL, F_BLUE ) ;
-
- w4activate( w_ref ) ;
- w4( 1,2, n4item_text( item_ref ) ) ;
-
- rc = g4char() ;
- w4deactivate( w_ref ) ;
- w4close( w_ref ) ;
-
- return rc ;
- }
-
- static int row_column( int junk_parm )
- {
- int w_ref ;
-
- w_ref = w4define(10,28,14,54) ;
- w4popup() ;
- w4border( DOUBLE, F_WHITE ) ;
- w4title( 0,-1, " Row/Column Menu ", B_WHITE ) ;
-
- n4( "One" ) ; n4action( row_column_display ) ; n4int_save(0) ;
- n4( "Two" ) ; n4action( row_column_display ) ; n4int_save(1) ;
- n4( "Three" ) ; n4action( row_column_display ) ; n4int_save(2) ;
- n4( "Four" ) ; n4action( row_column_display ) ; n4int_save(8) ;
- n4( "Five" ) ; n4action( row_column_display ) ; n4int_save(9) ;
- n4( "Six" ) ; n4action( row_column_display ) ; n4int_save(10) ;
- n4( "Seven" ) ; n4action( row_column_display ) ; n4int_save(16) ;
- n4( "Eight" ) ; n4action( row_column_display ) ; n4int_save(17) ;
- n4( "Nine" ) ; n4action( row_column_display ) ; n4int_save(18) ;
-
- n4item_width( 7 ) ;
- n4horizontal() ;
-
- n4activate( w_ref ) ;
- w4close( w_ref ) ;
-
- return 0 ;
- }
-
-
- static char random_data[9][6] =
- {
- "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
- } ;
-
-
-
- static int random_menu( int junk_parm )
- {
- int w_ref, num_items, i, r,c ;
- time_t t ;
-
- srand( (unsigned int) time(&t) ) ;
-
- #define START_ROW 5
- #define START_COL 30
- #define END_ROW 20
- #define END_COL 60
-
- w_ref = w4define( START_ROW, START_COL, END_ROW, END_COL ) ;
- w4popup() ;
- w4border( DOUBLE, F_GREEN ) ;
- w4title( 0,-1, " Random Menu ", B_WHITE ) ;
-
- num_items = rand() % 7 + 3 ; /* 3 to 9 */
-
- for ( i=0; i< num_items; i++ )
- {
- r = rand() % ( END_ROW-START_ROW-1 ) ;
- c = rand() % ( END_COL-START_COL-1 ) ;
-
- n4item( r,c, random_data[i] ) ;
- n4action( row_column_display ) ;
- n4int_save(9) ;
- }
-
- n4activate( w_ref ) ;
- w4close( w_ref ) ;
-
- return 0 ;
- }
-