-+-+-+-+-+-+-+-+ START OF PART 208 -+-+-+-+-+-+-+-+ X/*-------------------------------------------------------------------------- V*/ X Xstatic ptkboolean getmenuid(C(Pint) menustid, C(Pint *) menuid) XPreANSI(Pint menustid) XPreANSI(Pint *menuid) X`7B X ptksmenu *ptr; X X ptr = firstmenu; X while (ptr->menustid != menustid) X `7B X ptr = ptr->next; X if (ptr == NULL) X return FALSE; X `7D X *menuid = ptr->menuid; X return TRUE; X`7D /* getmenuid */ X X/*-------------------------------------------------------------------------* V/ X Xstatic ptkboolean ismenu(C(Pint) menustid, C(ptksmenu **) mptr) XPreANSI(Pint menustid) XPreANSI(ptksmenu **mptr) X`7B X ptksmenu *ptr; X ptkboolean found; X X ptr = firstmenu; X found = FALSE; X while ((ptr != NULL) && (!found)) X `7B X if (ptr->menustid == menustid) X `7B X *mptr = ptr; X found = TRUE; X `7D X else X ptr = ptr->next; X `7D X return found; X`7D /* ismenu */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void findfront(C(Pint) wsid, C(ptkswsmenu *) wsfront) XPreANSI(Pint wsid) XPreANSI(ptkswsmenu *wsfront) X`7B X Pstructpostlst structlist; X Pint numstructs, error, i; X Pfloat priority; X ptkboolean found; X ptksmenu *mptr; X X priority = 0.0; X found = FALSE; X i = 0; X pinqpostedstruct(wsid, 0, 0, &error, &structlist, &numstructs); X structlist.postings = (Pstructpost *)calloc(numstructs,`20 X sizeof(Pstructpost)); X pinqpostedstruct(wsid, numstructs, 0, &error, &structlist, &numstructs); X for (i = 0; i < numstructs; i++) X `7B X /* find highest priority menu structure */ X if (ismenu(structlist.postings`5Bi`5D.id, &mptr)) X if (structlist.postings`5Bi`5D.priority > priority) X `7B X priority = structlist.postings`5Bi`5D.priority; X wsfront->frontptr = mptr; X found = TRUE; X `7D X `7D X if (!found) X wsfront->postedmenus = FALSE; X`7D /* findfront */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void findback(C(Pint) wsid, C(ptkswsmenu *) wsback) XPreANSI(Pint wsid) XPreANSI(ptkswsmenu *wsback) X`7B X Pstructpostlst structlist; X Pint numstructs, error, i; X Pfloat priority; X ptkboolean found; X ptksmenu *mptr; X X priority = 1.0; X found = FALSE; X i = 0; X pinqpostedstruct(wsid, 0, 0, &error, &structlist, &numstructs); X structlist.postings = (Pstructpost *)calloc(numstructs,`20 X sizeof(Pstructpost)); X pinqpostedstruct(wsid, numstructs, 0, &error, &structlist, &numstructs); X for (i = 0; i < numstructs; i++) X `7B X /* find lowest priority menu structure */ X if (ismenu(structlist.postings`5Bi`5D.id, &mptr)) X if (structlist.postings`5Bi`5D.priority < priority) X `7B X priority = structlist.postings`5Bi`5D.priority; X wsback->backptr = mptr; X found = TRUE; X `7D X `7D X if (!found) X wsback->postedmenus = FALSE; X`7D /* findback */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void find_insertion_pt(C(Pint) menustid, C(Pint) itemno,`20 X C(Pint *) eltptr, C(Pint *) itemfound) XPreANSI(Pint menustid) XPreANSI(Pint itemno) XPreANSI(Pint *eltptr) XPreANSI(Pint *itemfound) X/* X** \parambegin X** \param`7B`7D`7Bmenustid`7D`7Bmenu structure id`7D`7BIN`7D X** \param`7B`7D`7Bitemno`7D`7Bnumber of menu item`7D`7BIN`7D X** \param`7B`7D`7Beltptr`7D`7Belement pointer of pick id`7D`7BIN`7D X** \param`7B`7D`7Bitemfound`7D`7Bpick id value`7D`7BIN`7D X** \paramend X** \blurb`7BSearch struct for `60set pick id' structure elements until`20 X** either get to end of structure or a pick id >= `60itemno' is found,`20 X** in which case the element number of the corresponding structure element`2 V0 X** is returned (this is the point at which "itemno" will be inserted).`20 X** `60itemfound' indicates whether or not the pick id found was `60itemno'. X** Returns TRUE if pick id found, otherwise FALSE.`7D X*/ X`7B X Pint pickid; X ptkboolean finished; X X finished = FALSE; X *itemfound = -1; X *eltptr = 2; X do X `7B X if (ptk_findnextpickid(menustid, PFORWARD, eltptr, &pickid)) X `7B X if (pickid >= itemno) X `7B X *itemfound = pickid; X finished = TRUE; X `7D X else X (*eltptr)++; X `7D X else X `7B X *eltptr = ptk_elemcount(menustid); X finished = TRUE; X `7D X `7D while (!finished); X`7D /* find_insertion_pt */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void finditemrange(C(Pint) menustid, C(Pint) itemno,`20 X C(Pint *) elem1, C(Pint *) elem2) XPreANSI(Pint menustid) XPreANSI(Pint itemno) XPreANSI(Pint *elem1) XPreANSI(Pint *elem2) X/* X** \parambegin X** \param`7B`7D`7Bmenustid`7D`7Bmenu structure id`7D`7BIN`7D X** \param`7B`7D`7Bitemno`7D`7Bnumber of menu item`7D`7BIN`7D X** \param`7B`7D`7Beltptr`7D`7Belement pointer of pick id`7D`7BIN`7D X** \param`7B`7D`7Bitemfound`7D`7Bpick id value`7D`7BIN`7D X** \paramend X** \blurb`7BSearch struct for `60set pick id' structure elements until`20 X** either get to end of structure or a pick id >= `60itemno' is found,`20 X** in which case the element number of the corresponding structure element`2 V0 X** is returned (this is the point at which "itemno" will be inserted).`20 X** `60itemfound' indicates whether or not the pick id found was `60itemno'. X** Returns TRUE if pick id found, otherwise FALSE.`7D X*/ X`7B X Pint pickid; X ptkboolean finished; X X finished = FALSE; X *elem1 = 1; X do X `7B X if (ptk_findnextpickid(menustid, PFORWARD, elem1, &pickid)) X `7B X if (pickid == itemno) X `7B X *elem2 = *elem1 + 1; X if (ptk_findnextpickid(menustid, PFORWARD, elem2, &pickid)) X`09`7B X (*elem2)--; X finished = TRUE; X `7D X else X`09`7B X *elem2 = ptk_elemcount(menustid) - 1; X finished = TRUE; X `7D X `7D X else`20 X (*elem1)++; X `7D X else X `7B X *elem1 = *elem2 = -1; X finished = TRUE; X `7D X `7D while (!finished); X`7D /* finditemrange */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic ptkboolean find_item(C(Pint) menustid, C(Pint) itemno, C(Pint *) eltp Vtr) XPreANSI(Pint menustid) XPreANSI(Pint itemno) XPreANSI(Pint *eltptr) X/* X** \parambegin X** \param`7B`7D`7Bmenustid`7D`7Bmenu structure id`7D`7BIN`7D X** \param`7B`7D`7Bitemno`7D`7Bmenu item number`7D`7BIN`7D X** \param`7B`7D`7Beltptr`7D`7Belement pointer of pick id`7D`7BIN`7D X** \paramend X** \blurb`7BLook for item in menu. X** Returns TRUE if item found, otherwise FALSE.`7D X*/ X`7B X Pint pickid; X ptkboolean found; X X *eltptr = 2; X found = FALSE; X do`20 X `7B X if (ptk_findnextpickid(menustid, PFORWARD, eltptr, &pickid)) X `7B X if (pickid == itemno) X`09found = TRUE; X else`20 X`09(*eltptr)++; X `7D`20 X else X *eltptr = -1; X `7D while ((!found) && (*eltptr != -1)); X return found; X`7D /* find_item */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic Ppoint3 get_tlboxcorner(C(Pint) itemno) XPreANSI(Pint itemno) X/* X** \parambegin X** \param`7B`7D`7Bitemno`7D`7Bmenu item number`7D`7BIN`7D X** \paramend X** \blurb`7BGet top left corner of box menu item. X** Returns top left corner of menu item.`7D X*/ X`7B X Ppoint3 temp; X X temp = ptk_point3(0.0, 0.0, 0.0); X switch (menuptr->menupath)`20 X `7B X X case PTP_RIGHT: X temp.x = (Pfloat)(itemno - 1) * menuptr->boxsize.x; X break; X X case PTP_LEFT: X temp.x = (Pfloat)(1 - itemno) * menuptr->boxsize.x; X break; X X case PTP_UP: X temp.y = (Pfloat)(itemno - 1) * menuptr->boxsize.y; X break; X X case PTP_DOWN: X temp.y = (Pfloat)(1 - itemno) * menuptr->boxsize.y; X break; X `7D X return temp; X`7D /* get_tlboxcorner */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void shift_items(C(Pint) eltno, C(Pint) shiftby) XPreANSI(Pint eltno) XPreANSI(Pint shiftby) X/* X** \parambegin X** \param`7B`7D`7Bmenustid`7D`7Bmenu structure id`7D`7BIN`7D X** \param`7B`7D`7Beltno`7D`7Belement pointer of first pickid in menu`7D`7BIN V`7D X** \param`7B`7D`7Bmenuinfo`7D`7Bmenu description data`7D`7BIN`7D X** \param`7B`7D`7Bshiftby`7D`7Bamount to shift boxes`7D`7BIN`7D X** \paramend X** \blurb`7BIf menu is a `60box' menu, shift subsequent items by size of`20 X** box and increment item number.`7D X*/ X`7B X Pmatrix3 shiftmat; X Pint pickid; X ptkboolean end_of_struct; X Ppoint3 shift; X X /* replace subsequent "set pick id" elts with pick id = pick id + shiftby V */ X end_of_struct = FALSE; X if (!ptk_findnextpickid(menuptr->menustid, PFORWARD, &eltno, &pickid)) X return; X ptk_seteditmode(PEDIT_REPLACE); X do`20 X `7B X psetelemptr(eltno); X psetpickid(pickid + shiftby); X if (menuptr->menutype == PTKEBOXMENU) X `7B X shift = get_tlboxcorner(pickid + shiftby); X ptk_shift3(&shift, PREPLACE, shiftmat); X poffsetelemptr(1); X psetlocaltran3(shiftmat, PREPLACE); X `7D X eltno++; X if (!ptk_findnextpickid(menuptr->menustid, PFORWARD, &eltno, &pickid))`2 V0 X end_of_struct = TRUE; X `7D while (!end_of_struct); X ptk_unseteditmode(); X`7D /* shift_items */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void delete_item(C(Pint) menustid, C(Pint) itemnum) XPreANSI(Pint menustid) XPreANSI(Pint itemnum) X/* X** \parambegin X** \param`7B`7D`7Bmenustid`7D`7Bmenu structure id`7D`7BIN`7D X** \param`7B`7D`7Beltno`7D`7Belement pointer of item`7D`7BIN`7D X** \paramend X** \blurb`7BDelete item from menu. `7D X*/ X`7B X Pint elem1, elem2; X X finditemrange(menustid, itemnum, &elem1, &elem2); X if (elem1 != -1) X `7B X ptk_openstruct(menustid); X pdelelemrange(elem1, elem2); X ptk_closestruct(); X `7D X`7D /* delete_item */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic ptkboolean find_string(C(Pint) structure, C(Pint *) pickid,`20 X C(Pchar *) str) XPreANSI(Pint structure) XPreANSI(Pint *pickid) XPreANSI(Pchar *str) X/* X** \parambegin X** \param`7B`7D`7Bstructure`7D`7Bmenu structure id`7D`7BIN`7D X** \param`7B`7D`7Bpickid`7D`7Bitem containing string`7D`7BIN`7D X** \param`7B`7D`7Bstrmenu`7D`7Bstring and menu data`7D`7BIN`7D X** \paramend X** \blurb`7BSearch for string in menu items. X** Returns TRUE if string found, otherwise FALSE.`7D X*/ X`7B X Pint error; X Psrchstatus stat; X ptkselcontent elcont; X Pchar *databuf; X Pint eltptr; X ptkboolean stop_search, string_found; X Pint numelems; X#ifdef SUN X Psrcheltypelst include, exclude; X Psrcheltype includeelems`5B10`5D, excludeelems`5B10`5D; X#endif X#ifdef VMS X Peltype srchelems`5B5`5D; X Pint numsrchelems, lstnum; X#endif X X eltptr = 0; X stop_search = FALSE; X string_found = FALSE; X numelems = ptk_elemcount(structure); X do`20 X `7B X#ifdef SUN X includeelems`5B0`5D = PSEL_TEXT3; X includeelems`5B1`5D = PSEL_TEXT; X includeelems`5B2`5D = PSEL_EXECUTE_STRUCTURE; X includeelems`5B3`5D = PSEL_PICK_ID; X include.number = 4; X include.elems = includeelems; X exclude.number = 0; X exclude.elems = excludeelems; X X pelemsrch(structure, eltptr, PFORWARD, &include, &exclude, X &error, &stat, &eltptr); X#endif X#ifdef VMS X numsrchelems = 4; X srchelems`5B0`5D = PEL_TEXT3; X srchelems`5B1`5D = PEL_TEXT; X srchelems`5B2`5D = PEL_EXECUTE_STRUCTURE; X srchelems`5B3`5D = PEL_PICK_ID; X X ptk_openstruct(structure); X psetelemptr(eltptr); X ptk_findelemtype(srchelems, numsrchelems, PFORWARD, &stat, &eltptr,`20 X &lstnum); X ptk_closestruct(); X error = 0; X#endif X X if (error != 0) X stop_search = TRUE; X else`20 X if (stat != PSUCCESS)`20 X stop_search = TRUE; X else`20 X `7B X ptk_inqelemtypesizecontent(structure, eltptr, &error, &databuf,`20 X &elcont); X if (error == 0)`20 X `7B X switch (elcont.eltype)`20 X `7B X `20 X case PEL_TEXT: X#ifdef SUN X if (strcmp(elcont.eldata.tx.str, str) == 0) X string_found = TRUE; X#endif X#ifdef VMS X if (strcmp(elcont.eldata.text.string, str) == 0) X string_found = TRUE; X#endif X break; X X case PEL_TEXT3: X#ifdef SUN X if (strcmp(elcont.eldata.text3.str, str) == 0) X string_found = TRUE; X#endif X#ifdef VMS X if (strcmp(elcont.eldata.text3.string, str) == 0) X string_found = TRUE; X#endif X break; X X case PEL_EXECUTE_STRUCTURE: X string_found = find_string(elcont.eldata.idata, pickid, str); X break; X X case PEL_PICK_ID: X *pickid = elcont.eldata.idata; X break; X `7D X `7D X `7D X eltptr++; X free(databuf); X `7D while (!string_found && !stop_search && (eltptr <= numelems)); X return string_found; X`7D /* find_string */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void redrawboxmenuitem(C(Pint) textcolour, C(Pint) intcolour,`20 X C(Pint) edgecolour, C(Pint) tlcolour,`20 X C(Pint) brcolour) XPreANSI(Pint textcolour) XPreANSI(Pint intcolour) XPreANSI(Pint edgecolour) XPreANSI(Pint tlcolour) XPreANSI(Pint brcolour) X`7B X Ppoint3 box_centre; X Pint err, elptr, lstnum; X Ppoint centresize; X Peltype eltype`5B2`5D; X Psrchstatus stat; X X /* find elem = setintstyle */ X eltype`5B0`5D = PEL_INTERIOR_STYLE; X ptk_findelemtype(eltype, 1, PFORWARD, &stat, &elptr, &lstnum); X /* delete next 9 elems */ X ptk_delelem(9); X box_centre = ptk_point3(0.5 * menuptr->boxsize.x, +-+-+-+-+-+-+-+- END OF PART 208 +-+-+-+-+-+-+-+-