home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource4
/
281_01
/
dem_menu.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-10-07
|
38KB
|
1,030 lines
/* dem_menu.c
*
* Demo program for menu functions
* This program will also spawn the window, data entry and general
* library demo programs from a menu.
*
*/
#include <stdio.h>
#include <process.h>
#include "uc_defs.h"
#include "uc_glob.h"
#include "uc_proto.h"
#include "wn_defs.h"
#include "wn_glob.h"
#include "wn_proto.h"
#include "mn_defs.h"
#include "mn_glob.h"
#include "uc_key.h"
MNUPTR make_mnu();
MNU_ITEMPTR make_item();
void main( void )
{
MNU_ITEMPTR mnu_item;
MNUPTR mnu_ptr;
WINDOWPTR wn_mnu;
WINDOWPTR wn_main;
int dummy();
int bye_bye();
int unicorn();
int demos();
int registration();
int future();
int notes();
int uclib51();
int i;
uc_init(); /* This function checks the current video mode and */
/* sets up the window system accordingly. */
/* At present you must define attributes for either a */
/* color or a monochrome system. A future release */
/* add a universal attribute system used in a past */
/* Unicorn release. This system allows the user to */
/* predefine a set of attributes for both systems and */
/* to use the appropriate ones determined on a run */
/* time check of the video mode. This means a single */
/* program may be written that will run correctly on */
/* both color and monochrome systems. */
if ( mouse_exist )
m_flagdec();
cur_save(); /* Save the users current cursor location and shape. */
/* Make a full screen window. This will be popped up*/
/* to save the users screen so that it may be */
/* restored on exiting this demo program. */
wn_main = wn_make( 0, 0, 24, 80 );
wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
wn_bclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_clear( wn_main );
wn_margin( wn_main, 1 );
/* A future release will contain a function to build a*/
/* title so the user will not have to do this messy */
/* stuff. It will be hidden behind a function call. */
wn_main->title = ( TITLEPTR ) malloc( sizeof( TITLE ) );
wn_main->title->title = ( char * ) malloc( 100 );
strcpy( wn_main->title->title,
" Unicorn Software P.O. Box 3214 Kirkland, WA 98034-3214 (206) 823-4656" );
wn_main->title->position = 4;
/* Set the title color */
wn_main->clr->title = mk_att( WHITE, BLUE + BRIGHT );
wn_mkbdr( wn_main, BDR_LNP );
/* position the cursor in the window and write some */
/* text for the user to read. */
wn_csr( wn_main, 4, 21 );
wn_printf( wn_main, "Unicorn Menu System Version 1.0\n" );
wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
wn_printf( wn_main, "\n " );
wn_printf( wn_main, "Welcome to the " );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, "Unicorn Menu System\n" );
wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
wn_printf( wn_main, " " );
wn_printf( wn_main, "Version 1.0. This is included as\n" );
wn_printf( wn_main, " " );
wn_printf( wn_main, "a part of the Unicorn Library. \n" );
wn_printf( wn_main, " " );
wn_printf( wn_main, "We hope you enjoy the menu Demo and\n" );
wn_printf( wn_main, " " );
wn_printf( wn_main, "the other demo programs it will run.\n\n" );
wn_printf( wn_main, " " );
wn_printf( wn_main, "Not all features are demonstrated but\n" );
wn_printf( wn_main, " " );
wn_printf( wn_main, "with the source code for this program\n" );
wn_printf( wn_main, " " );
wn_printf( wn_main, "and the other demos along with the\n" );
wn_printf( wn_main, " " );
wn_printf( wn_main, "reference guide there should be more\n" );
wn_printf( wn_main, " " );
wn_printf( wn_main, "than enough to allow you to write\n" );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, " If you have a mouse driver " );
wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
wn_printf( wn_main, "your own programs. " );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, "Registered users \n" );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, " installed, you may use the " );
wn_printf( wn_main, "will recieve a " );
wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
wn_printf( wn_main, "6 disk set " );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, "including\n" );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, " mouse to point and shoot " );
wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
wn_printf( wn_main, "full source code" );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, " for all of the over\n" );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, " with the menus and may use " );
wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
wn_printf( wn_main, "300 functions " );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, "contained in this version\n" );
wn_printf( wn_main, " the buttons to move through " );
wn_printf( wn_main, "of the Unicorn Library. " );
wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
wn_printf( wn_main, "Thanks for\n" );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, " the display instead of " );
wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
wn_printf( wn_main, "looking at the library and considering\n" );
wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_main, " pressing a key. " );
wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
wn_printf( wn_main, "registration. " );
wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
wn_printf( wn_main, " Dave Miller\n" );
wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
/* Time to make a window for the menu. It will */
/* be attached to a menu structure. */
wn_mnu = wn_make( 4, 2, 11, 32 );
wn_wnclr( wn_mnu, mk_att( CYAN, BLACK + BRIGHT ) );
wn_bclr( wn_mnu, mk_att( CYAN, BROWN + BRIGHT ) );
wn_clear( wn_mnu );
wn_margin( wn_mnu, 2 );
wn_mkbdr( wn_mnu, BDR_DLNP );
/* Make the menu structure now. */
mnu_ptr = make_mnu( wn_mnu );
wn_printf( mnu_ptr->mnu_window, " Main Menu\n" );
/* Now we will make the actual menu items. Each */
/* item call is passed several parameters. You */
/* may easily experiment with changing them to */
/* get a better feel for the system. One very */
/* important one is the pointer to a function to */
/* be called if this item is selected. For the */
/* first item the pointer is 'unicorn'. */
mnu_item = make_item( 3, 4, mk_att( CYAN, BLUE ),
mk_att( BLUE, CYAN + BRIGHT ), " Unicorn Software ", unicorn,
'U', mk_att( CYAN, RED ), mnu_ptr );
mnu_item = make_item( 4, 4, mk_att( CYAN, BLUE ),
mk_att( BLUE, CYAN + BRIGHT ), " Demo Programs ", demos,
'D', mk_att( CYAN, RED ), mnu_ptr );
mnu_item = make_item( 5, 4, mk_att( CYAN, BLUE ),
mk_att( BLUE, CYAN + BRIGHT ), " Registration ", registration,
'R', mk_att( CYAN, RED ), mnu_ptr );
mnu_item = make_item( 6, 4, mk_att( CYAN, BLUE ),
mk_att( BLUE, CYAN + BRIGHT ), " Future Updates ", future,
'F', mk_att( CYAN, RED ), mnu_ptr );
mnu_item = make_item( 7, 4, mk_att( CYAN, BLUE ),
mk_att( BLUE, CYAN + BRIGHT ), " Library Notes ", notes,