home *** CD-ROM | disk | FTP | other *** search
- /*
- menusize.c
-
- % menu_RecalcSize
-
- C-scape 3.2
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/23/88 jdc created
- 12/13/88 jdc handles bobs too
- 7/02/89 jdc added frowcount change
- 8/10/89 jmd convert bobs to wins
-
- 3/28/90 jmd ansi-fied
- */
-
- #include "menu.h"
- #include "bordobj.h" /* for bord_ calls */
-
- void menu_RecalcSize(menu_type menu)
- /*
- Recalculates the size of the menu.
- */
- {
- int row, count, text_done, fldno, hgt, wid;
- tb_type tb;
- bob_type bob;
- field_type field;
-
-
- if (!menu_IsDirty(menu)) {
- return;
- }
-
- tb = menu_GetTextbuf(menu);
-
- /* reset menu height and width */
- menu->rowcount = menu->frowcount = menu->colcount = 0;
-
- /* loop through all the rows until everything has been checked! */
- for (row = 0, count = menu->fieldcount, text_done = FALSE;
- count > 0 || !text_done;
- row++) {
-
- if (count > 0 && (fldno = menu_GetGRow(menu, row)) > 0) {
- fldno--;
-
- /* check all the fields across the row, include bobs. */
- do {
- field = menu_GetField(menu, fldno);
-
- if ((bob = field_GetBob(field)) != NULL && bob_IsDepend(bob)) {
- hgt = bord_GetHeight(bob);
- wid = bord_GetWidth(bob);
- }
- else {
- hgt = 1;
- wid = field_GetWidth(field);
- }
-
- if ((wid += field_GetCol(field)) > menu->colcount) {
- menu->colcount = wid;
- }
- if ((hgt += row) > menu->frowcount) {
- menu->frowcount = hgt;
- }
- count--;
- }
- while ((fldno = field_GetRight(field)) >= 0);
- }
- /* check the text too */
- if (tb_FindLine(tb, row) <= 0) {
- text_done = TRUE;
- }
- else {
- if (row >= menu->rowcount) {
- menu->rowcount = row + 1;
- }
- if (tb->exp_len > menu->colcount) {
- menu->colcount = tb->exp_len;
- }
- }
- }
- menu_SetDirty(menu, FALSE);
- }
-
-