home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
MENUDROW.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
2KB
|
85 lines
/*
menudrow.c 4/10/88
% menu_DeleteRows
C-scape 3.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
6/07/88 jmd added call to tb_DeleteRow
6/24/88 jmd converted to new xarray/iarray calls
4/16/89 jmd adjusted for jarray
4/22/89 jmd moved DelTBrow to the end
3/28/90 jmd ansi-fied
*/
#include "menu.h"
void menu_DeleteRows(menu_type menu, int row, int count)
/*
Deletes count rows in the menu starting with row.
*/
{
register int i;
int fno, rfld;
/* test menu and row number */
cs_Assert(menu_Ok(menu), CS_M_DR_MENU, 0); /* passed bad menu */
cs_Assert(row >= 0 && row < menu_GetRowCount(menu), CS_M_DR_ARG, 0); /* passed bad args */
/* check count */
if (count <= 0) {
return;
}
else {
count = (count > menu_GetRowCount(menu) - row) ? menu_GetRowCount(menu) - row : count;
}
/* delete all the fields in the rows */
for (i = row + count - 1; i >= row; i--) {
if ((fno = ia_Get((menu)->fgrid, i)) > 0) {
for (fno = fno - 1; fno >= 0; fno = rfld) {
/* get fno BEFORE deleting field */
rfld = menu_GetFieldRight(menu, fno);
menu_DeleteField(menu, fno);
/* compensate for deleted field */
if (rfld > fno) {
rfld--;
}
}
}
}
/* adjust the row position for all the fields below */
/* slide the row array */
for (i = row; i <= menu_GetRowCount(menu) - count; i++) {
fno = ia_Get((menu)->fgrid, i + count);
ia_Put((menu)->fgrid, i, fno);
if (fno > 0) {
for (fno = fno - 1; fno >= 0; fno = menu_GetFieldRight(menu, fno)) {
field_SetRow(menu_GetField(menu, fno), i);
}
}
}
/* clear the now unused area of the row array */
fno = 0;
for (i = menu_GetRowCount(menu) - count; i < menu->frowcount; i++) {
ia_Put((menu)->fgrid, i, fno);
}
menu->frowcount -= count;
/* delete the text in the rows */
for (i = 0; i < count; i++) {
menu_DelRowTB(menu, row, 0);
}
/* menu size is now incorrect */
menu_SetDirty(menu, TRUE);
}