home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
MENUDFLD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-23
|
3KB
|
135 lines
/*
menudfld.c 4/10/88
% menu_DeleteField
C-scape 3.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
6/24/88 jmd converted to new xarray/iarray calls
8/24/88 jmd added bob list support
2/01/89 jdc fixed bob list support, menu->bobcount--;
2/02/89 jdc fixed bob list support fix, if (menu->bobcount > 0)
4/22/89 jmd really fixed bob list support, menu->bobcount--;
4/24/89 jdc fixed namelist and funcnamea
5/29/89 jdc added varname array
7/02/89 jdc added functype array
10/02/89 jmd fixed NULL reference in delete field
11/12/89 jdc fixed name reference
11/20/89 pmcm really fixed name reference
1/20/90 jdc speeded data retrieval (oslists)
3/28/90 jmd ansi-fied
8/23/90 jdc tweeked for CHILDCLOSE msg, added menu_RemoveFieldName
*/
#include "sed.h"
#include "fldpriv.h"
#include "sfile.h" /* for os_list stuff */
void menu_DeleteField(menu_type menu, int fieldno)
/*
Delete a field.
Close up the gap in the field array.
*/
{
int i;
field_type field, field1;
int fld, moveflag, temp;
iarray funcnamea, functypea, varnamea;
/* test menu and field number */
cs_Assert(menu_Ok(menu), CS_M_DF_MENU, 0); /* passed bad menu */
cs_Assert(fieldno >= 0 && fieldno < menu->fieldcount, CS_M_DF_MENU, 0); /* passed bad fieldno */
/* remove field from grid */
menu_TakeFieldFromGrid(menu, fieldno);
/* adjust field references in fields */
for (i = 0; i < menu->fieldcount; i++) {
field = menu_GetField(menu, i);
if ((fld = field_GetRight(field)) > fieldno) {
field_SetRight(field, fld - 1);
}
if ((fld = field_GetLeft(field)) > fieldno) {
field_SetLeft(field, fld - 1);
}
}
/* adjust row array */
for (i = 0; i < menu->frowcount; i++) {
if ((fld = ia_Get(menu->fgrid, i)) > fieldno) {
temp = fld - 1;
ia_Put(menu->fgrid, i, temp);
}
}
if (menu->bobcount > 0) {
/* adjust bob list */
for (i = 0, moveflag = FALSE; i < menu->bobcount; i++) {
if ((fld = ia_Get(menu->boba, i)) > fieldno) {
fld = fld - 1;
ia_Put(menu->boba, i, fld);
}
else if (fld == fieldno) {
moveflag = TRUE;
continue;
}
if (moveflag) {
ia_Put(menu->boba, i - 1, fld);
}
}
if (moveflag) {
menu->bobcount--;
}
}
field = menu_GetField(menu, fieldno);
if (field->nameno != OSLIST_BADNAME) {
menu_RemoveFieldName(menu, fieldno);
}
funcnamea = menu->funcnamea;
functypea = menu->functypea;
varnamea = menu->varnamea;
for (i = fieldno; i < menu->fieldcount - 1; i++) {
/* slide fields in field array */
field1 = (field_type) xa_Get(menu->fa, i + 1);
xa_Put((menu)->fa, i, (VOID *) field1);
/* take care of names */
if (field1->nameno != -1) {
oslist_SetData(menu->namelist, field1->nameno, (VOID *)(&i));
}
if (funcnamea != NULL) {
/* take care of funcname array */
temp = ia_Get(funcnamea, SED_FSYM_COUNT + i + 1);
ia_Put(funcnamea, SED_FSYM_COUNT + i, temp);
/* take care of functype array */
temp = ia_Get(functypea, i + 1);
ia_Put(functypea, i, temp);
/* take care of varname array */
temp = ia_Get(varnamea, i + 1);
ia_Put(varnamea, i, temp);
}
}
/* decrement fieldcount */
menu->fieldcount--;
/* menu size is now incorrect */
menu_SetDirty(menu, TRUE);
/* destroy field */
field_Close(field);
}