home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
dbase
/
vviews.zip
/
SPACE.C
< prev
next >
Wrap
Text File
|
1990-09-28
|
16KB
|
408 lines
/*
************* Copyright 1988 by Vermont Creative Software **************
space.c
A demo program designed and written using Vermont Views and the Vermont Views
Designer.
Description
This program demonstrates how to use data-entry and menu forms created with
the Vermont Views Designer.
*/
#include <string.h>
#include <vv_help.h> /* Enables to use help system */
#include <vv_clist.h>
#include <vv_extch.h>
#include <vv_str.h> /* Enables use of string fields */
#include <vv_sr.h>
#include <vv_memo.h>
#include <vv_menu.h> /* Enables use of menus */
#include <vv_des.h> /* Enables use of Designer forms */
#include <space.h> /* Data structures of space form */
#include <spacepro.h> /* Prototypes of space functions */
#include <spacefun.h> /* Function list */
#include <vv_main.h>
#define MAXTRANSP 6 /* Number of fields in the transport */
/* menu */
#define MAXDEST 9 /* Number of fields in the destination*/
/* menu */
TRANSPORT_FORM transport; /* Data storage for transport_form */
OTHER_DEST_FORM destination; /* Data storage for other_dest_form */
CREW_FORM crew; /* Data storage for crew_form */
SUPPLY_FORM supplies; /* Data storage for supply_form */
SUMMARY_FORM summary; /* Data storage for summary_form */
DFORMPTR fmptransport; /* Pointer to transport_form */
DFORMPTR fmpdest; /* Pointer to other_dest_form */
#ifdef LINT_ARGS
int CDECL main(void);
#endif
/*----------------------------------------------------------------------------*/
/* Main program */
/*----------------------------------------------------------------------------*/
int CDECL main()
{
DFORMPTR fmpopening; /* Pointer to opening form */
DFORMPTR fmpmessage; /* Pointer to message form */
MFORMPTR main_menu; /* Pointer to top menu form */
DLIBPTR libp; /* Pointer to library */
MFILEPTR mfp; /* Pointer to memory file */
WINDOWPTR wnp; /* Pointer to a window structure */
int i;
/*-------------------------------------------------------------------------*/
/* Defines data form information array */
/*-------------------------------------------------------------------------*/
static DFMINFO fmlistp[] =
{
{"crew_form", &crew, space, NULLP},
{"supply_form", &supplies, space, NULLP},
{"summary_form", &summary, space, NULLP},
{NULLP, NULLP, NULLP, NULLP}
};
init_vv(); /* Initializes Vermont Views */
vs_clr(); /* Clears the video screen */
/* Changes the colors used for shadows*/
latt_rpl(LSHADOW, NORMAL, BLACK, BLUE, LATT_SYS);
latt_rpl(LSYS, NORMAL | HIGH_INT, WHITE | HIGH_INT, BLACK, LATT_SYS);
/*-------------------------------------------------------------------------*/
/* Sets us up to use shadows and exploding windows on all forms and */
/* menus and choice lists */
/*-------------------------------------------------------------------------*/
sw_shad(CH_MEDSHADE, LSHADOW, BOTTOMLEFT, MN_WNP);
sw_updnfp(wn_expset, wn_expunset, MN_WNP);
sw_exporg(EXPTOPLFT, MN_WNP);
sw_updnfp(wn_expset, wn_expunset, FM_WNP);
sw_exporg(EXPTOPLFT, FM_WNP);
sw_shad(TRANSPARENT, LSYS, BOTTOMLEFT, CLIST_WNP);
sw_updnfp(wn_rollset, wn_rollunset, CLIST_WNP);
sw_exporg(EXPTOP, CLIST_WNP);
/*-------------------------------------------------------------------------*/
/* Defines memory file, reads in a choice list text to memory file, reads */
/* in a help text file to memory file. */
/*-------------------------------------------------------------------------*/
mfp = mf_def(200, 80);
mf_rd("space.chc", mfp);
for (i = 0; i < 3; i++)
fmlistp[i].clist_mfp = mfp;
help_mf("help.txt", 200);
/*-------------------------------------------------------------------------*/
/* Get forms from library. */
/*-------------------------------------------------------------------------*/
libp = dl_open("space.vvd"); /* Opens library */
fmpopening = dl_fmget("opening", NULLP, NULLP, NULLP, libp);
fmpmessage = dl_fmget("message", NULLP, NULLP, NULLP, libp);
main_menu = dl_mnget("main_menu", SUBMENUS, space, fmlistp, libp);
fmptransport = dl_fmget("transport_form", &transport, NULLP, NULLP, libp);
fmpdest = dl_fmget("other_dest_form", &destination, NULLP, mfp, libp);
sw_shad(CH_MEDSHADE, LSHADOW, BOTTOMLEFT, fmpdest->wnp);
dl_close(libp); /* Closes library */
/*-------------------------------------------------------------------------*/
/* Assigns the underlying data variables for fields on the summary_form */
/*-------------------------------------------------------------------------*/
sf_datap("scofficer", crew.scofficer, fm_namptr("summary_form"));
sf_datap("comofficer", crew.comofficer, fm_namptr("summary_form"));
sf_datap("navigator", crew.navigator, fm_namptr("summary_form"));
sf_datap("pilot", crew.pilot, fm_namptr("summary_form"));
sf_datap("warlord", crew.warlord, fm_namptr("summary_form"));
ssr_datap("general_staff", crew.general_staff, fm_namptr("summary_form"));
ssr_datap("supplies", supplies.supplies, fm_namptr("summary_form"));
/*-------------------------------------------------------------------------*/
/* Process menu system. */
/*-------------------------------------------------------------------------*/
fm_up(fmpopening); /* Displays opening form on screen */
ki(); /* Waits for a key */
fm_dn(fmpopening); /* Removes opening form from screen */
fm_up(fmpmessage); /* Displays message form on screen */
ki(); /* Waits for a key */
fm_dn(fmpmessage); /* Removes message form from screen */
vs_clratt(LFLDACT); /* Changes the color used to clear */
/* the video screen */
vs_clr(); /* Clears the video screen */
mn_proc(0, main_menu); /* Process menu system */
mn_free(main_menu); /* Frees menu forms */
/* Allocate and initialize window */
wnp = wn_def(5, 9, 14, 65, LHIGHLITE, BDR_DLNP);
/*Special effects - shadows, exploding*/
/*window, title */
sw_shad(CH_MEDSHADE, LSHADOW, BOTTOMRIGHT, wnp);
sw_updnfp(wn_expset, wn_expunset, wnp);
sw_title("Press any key to continue.", LNORMAL, BOTTOMCENTER, wnp);
wn_up(wnp); /* Sets the window on screen */
/* Writes to the window */
v_stpl(2, 2, "Captain ", wnp);
if (! st_isblank(summary.missioncom))
v_st(summary.missioncom, wnp);
else
wnp->c--;
v_st(",", wnp);
v_stpl(4, 2, "News of your completed mission to ", wnp);
v_st(destination.destination, wnp);
v_stpl(5, 2, "has reached Star Fleet Command. Your field promotion", wnp);
v_stpl(6, 2, "awaits your return. Congratulations!", wnp);
v_stpl(9, 28, "Fleet Admiral James T. Kirk", wnp);
ki(); /* Waits for a key */
wn_dn(wnp); /* Removes the window from screen */
wn_mod(6, 5, 13, 69, wnp); /*Modifies window size and location */
for (i = 0; i < 3; i++) /*Makes window seem to "pulse" onto */
{ /*the screen. */
wn_up(wnp);
wn_dn(wnp);
}
wn_up(wnp); /*Puts window up for the last time */
/*Writes to window buffer */
v_stpl(2, CENTER_TEXT, "Congratulations on a successful mission!", wnp);
v_stpl(5, CENTER_TEXT, "You may now plot a new course to", wnp);
v_stpl(6, CENTER_TEXT, "faster user interface development with", wnp);
v_stpl(8, CENTER_TEXT, "Vermont Views(TM)!", wnp);
ki(); /*Waits for keystroke */
wn_dn(wnp); /*Takes window down */
wn_free(wnp); /* Frees memory allocated for window */
/* Set the clear attribute to normal */
latt_rpl(LSYS, NORMAL, WHITE, BLACK, LATT_SYS);
vs_clratt(LSYS); /* Changes the color used to clear */
/* the video screen */
vs_clr(); /* Clears the video screen */
csr_mv(vs_rowq() - 1, 0); /* Moves the cursor to the last row */
exit_vv(); /* Exit Vermont Views */
return(0);
}
/*----------------------------------------------------------------------------*/
/* This function will exit the main menu. */
/*----------------------------------------------------------------------------*/
int exit_function(mfmp)
MFORMPTR mfmp;
{
return(EXITMENU);
}
/*----------------------------------------------------------------------------*/
/* End destination menu form function. */
/* This function writes the destination (which may be indicated by a */
/* checkmark on the destination menu) out to the global destination variable.*/
/*----------------------------------------------------------------------------*/
int efmdestination(mfmp)
MFORMPTR mfmp;
{
int i; /* Loop counter */
int lastfldnum = 0; /* Number of last field on form */
MFIELDPTR mfldp; /* Pointer to menu field on form */
/* Fills in destination if user didn't*/
/* enter it */
if (st_isblank(destination.destination))
strcpy(destination.destination, "(unspecified destination)");
lastfldnum = i_maxnum(mfmp); /* Gets number of last field */
/* Loops through fields, looking for */
/* the checkmarked field */
for (i = 0; i < lastfldnum - 1; i++)
{
mfldp = i_numptr(i, mfmp); /* Gets a pointer to the field */
if (mnf_ischecked(mfldp)) /* Checks whether user checked field */
{ /* Copies item into destination string*/
strcpy(destination.destination, mfldp->datap);
/* Only one field can be checked, so */
break; /*break after finding it */
}
}
return(1);
}
/*----------------------------------------------------------------------------*/
/* End transport menu form function. */
/* This function will remove transport_form from the video screen */
/*----------------------------------------------------------------------------*/
int efmtransport(mfmp)
MFORMPTR mfmp;
{
fm_dn(fmptransport);
return(1);
}
/*----------------------------------------------------------------------------*/
/* Begin transport menu form function. */
/* This function will display transport_form on the screen. */
/*----------------------------------------------------------------------------*/
int bfmtransport(mfmp)
MFORMPTR mfmp;
{
fm_up(fmptransport);
return(1);
}
/*----------------------------------------------------------------------------*/
/* Action function for each field of the destination menu form. */
/* */
/* This function will update checkmark in the destination checkmark menu, */
/* so only one item can be selected at a time, for the last item (Other */
/* Destination) will read the dest_other_form, and will update the */
/* destination field in the summary_form. */
/*----------------------------------------------------------------------------*/
int dest_check_mark(mfmp)
MFORMPTR mfmp;
{
int i;
/*-------------------------------------------------------------------------*/
/* If checkmark for the current item is ON, updates it to OFF and clears */
/* destination fields on the dest_other_form and summary_form. */
/*-------------------------------------------------------------------------*/
if (mnf_ischecked(curmfldp(mfmp)))
{
smnf_checkstatus(OFF, curmfldp(mfmp));
*summary.destination = '\0';
*destination.destination = '\0';
}
/*-------------------------------------------------------------------------*/
/* If the checkmark for the current item is OFF, clears checkmark for all */
/* items of the destination menu, sets checkmark for the current item to */
/* ON. If current item is the last item (Other Destination) it displays */
/* and processes the other_dest_form and then updates the summary_form, */
/* otherwise updates the summary_form and clears the destination field */
/* on the other_dest_form. */
/*-------------------------------------------------------------------------*/
else
{
for (i = 0; i <= MAXDEST; i++)
smnf_checkstatus(OFF, (MFIELDPTR) i_numptr(i, mfmp));
smnf_checkstatus(ON, curmfldp(mfmp));
if (curitemnum(mfmp) == MAXDEST)
{
fm_up(fmpdest);
fm_rd(0, fmpdest);
strcpy(summary.destination, destination.destination);
}
else
{
strcpy(summary.destination, i_numnam(curitemnum(mfmp), mfmp));
*destination.destination = '\0';
}
}
if (fm_isup(fmpdest)) /* if destination form is up, */
fm_dn(fmpdest); /* removes it from the screen */
smn_altered(mfmp); /* sets the altered flag for the menu */
return(SAMELEVEL);
}
/*----------------------------------------------------------------------------*/
/* Action function for each field of the transport menu form. */
/* */
/* This function will update checkmark in the transport checkmark menu, */
/* so only one item can be selected at a time, for the last item (Other) */
/* will read the transport_form, and will update the transport field in the */
/* summary_form. */
/*----------------------------------------------------------------------------*/
int tran_check_mark(mfmp)
MFORMPTR mfmp;
{
int i;
/*-------------------------------------------------------------------------*/
/* If checkmark for the current item is ON, updates it to OFF and clears */
/* transport field on the transport_form and summary_form. */
/*-------------------------------------------------------------------------*/
if (mnf_ischecked(curmfldp(mfmp)))
{
smnf_checkstatus(OFF, curmfldp(mfmp));
*summary.transport = '\0';
*transport.transport = '\0';
}
/*-------------------------------------------------------------------------*/
/* If the checkmark for the current item is OFF, clears checkmark for all */
/* items of the transport menu, sets checkmark for the current item to ON. */
/* If the current item is the last item (Other) it processes the transport_*/
/* form and then updates the summary_form, otherwise updates the summary_ */
/* form and clears the transport field on the transport_form. */
/*-------------------------------------------------------------------------*/
else
{
for (i = 0; i <= MAXTRANSP; i++)
smnf_checkstatus(OFF, (MFIELDPTR) i_numptr(i, mfmp));
smnf_checkstatus(ON, curmfldp(mfmp));
if (curitemnum(mfmp) == MAXTRANSP)
{
fm_rd(0, fmptransport);
strcpy(summary.transport, transport.transport);
}
else
{
strcpy(summary.transport, i_numnam(curitemnum(mfmp), mfmp));
*transport.transport = '\0';
}
}
fm_upd(fmptransport); /* updates the transport_form */
smn_altered(mfmp); /* sets the altered flag for the menu */
return(SAMELEVEL);
}