-+-+-+-+-+-+-+-+ START OF PART 211 -+-+-+-+-+-+-+-+ Xextern ptkboolean ptk_stringscanmenus(C(Pint) wsid, C(Pchar *) str,`20 X C(Pint *) menuid, C(Pint *) itemnum) XPreANSI(Pint wsid) XPreANSI(Pchar *str) XPreANSI(Pint *menuid) XPreANSI(Pint *itemnum) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPchar *`7D`7Bstr`7D`7Bstring`7D`7BIN`7D X** \param`7BPint *`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BOUT`7D X** \param`7BPint *`7D`7Bitemno`7D`7Bitem number`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function compares the character string `7B\tt str`7D with X** the items of all posted menus. The comparison begins with the X** highest priority menu and works through to the back menu. X** User menu items are also searched for text primitives with which to X** compare the string. The comparison is case sensitive so that X** "item 1" is not the same as "IteM 1". X** The function returns TRUE if the string matches a menu item,`20 X** otherwise FALSE.`7D X*/ X`7B X ptkboolean menufound; X Pintlst *menus; X ptksmenu *ptrmenu; X Pint numstructs, i, err; X Pstructpostlst structlist; X Pintlst incl, excl; X Pint incllen, excllen; X X menufound = FALSE; X structlist.postings = NULL; X pinqpostedstruct(wsid, 0, 0, &err, &structlist, &numstructs); X structlist.postings = (Pstructpost *)calloc(numstructs,`20 X sizeof(Pstructpost)); X pinqpostedstruct(wsid, numstructs, 0, &err, &structlist, &numstructs); X X /* inquire invisibility filter */ X pinqinvisfilter(wsid, 0, 0, 0, 0, &err, &incl, &incllen, &excl, &excllen); X incl.integers = (Pint *)calloc(incllen, sizeof(Pint)); X excl.integers = (Pint *)calloc(excllen, sizeof(Pint)); X incl.number = incllen; X excl.number = excllen; X pinqinvisfilter(wsid, incllen, 0, excllen, 0, &err, &incl, &incllen,`20 X &excl, &excllen); X X /* This bit is a bit dodgy because it relies on structlist being ordered X ** by PHIGS into highest priority last. This is not standard PHIGS, X ** so if version is not sorted do a sort. X */ X i = numstructs - 1; X while ((i >= 0) && (!menufound))`20 X `7B X if (ismenu(structlist.postings`5Bi`5D.id, &ptrmenu)) X `7B X /* check invisibility filter */ X if (!((inintlst(ptrmenu->menuname, &incl) != -1) &&`20 X (inintlst(ptrmenu->menuname, &excl) == -1))) X `7B X if (find_string(ptrmenu->menustid, itemnum, str)) X `7B X menufound = TRUE; X *menuid = ptrmenu->menuid; X `7D X `7D X `7D X i--; X `7D X free(structlist.postings); X return menufound; X`7D /* ptk_stringscanmenus */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_pickscanmenus(C(Ppickpath *) pickpath,`20 X C(Ppathorder) pathorder, C(Pint *) menuid, C(Pint *) itemnum) XPreANSI(Ppickpath *pickpath) XPreANSI(Ppathorder pathorder) XPreANSI(Pint *menuid) XPreANSI(Pint *itemnum) X/* X** \parambegin X** \param`7BPpickpath *`7D`7Bpickpath`7D`7Bpath through structure network.`7 VD`7BIN`7D X** \param`7BPpathorder`7D`7Bpathorder`7D`7Border of data in pickpath`7D`7BIN V`7D X** \param`7BPint *`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BOUT`7D X** \param`7BPint *`7D`7Bitemnum`7D`7Bitem number`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function tests the pick path to inquire if a menu item X** was picked.`20 X** The function returns TRUE if a menu item was picked, otherwise FALSE.`7D X*/ X`7B X Pint menustid; X X if (pathorder == PTOP_FIRST) X `7B X *itemnum = pickpath->pick_path`5Bpickpath->depth - 1`5D.pick_id; X menustid = pickpath->pick_path`5B0`5D.struct_id; X return (getmenuid(menustid, menuid)); X `7D X else X `7B X *itemnum = pickpath->pick_path`5B0`5D.pick_id; X menustid = pickpath->pick_path`5Bpickpath->depth - 1`5D.struct_id; X return (getmenuid(menustid, menuid)); X `7D X`7D /* ptk_pickscanmenus */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_locscanmenus(C(Pint) wsid, C(Ppoint *) point,`20 X C(Pint *) menuid, C(Pint *) itemnum, C(Ppoint *) value) XPreANSI(Pint wsid) XPreANSI(Ppoint *point) XPreANSI(Pint *menuid) XPreANSI(Pint *itemnum) XPreANSI(Ppoint *value) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPpoint *`7D`7Bpoint`7D`7Binput point`7D`7BIN`7D X** \param`7BPint *`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BOUT`7D X** \param`7BPint *`7D`7Bitemnum`7D`7Bitem number`7D`7BOUT`7D X** \param`7BPpoint *`7D`7Bvalue`7D`7Bposition of point within item`7D`7BOUT` V7D X** \paramend X** \blurb`7BThis function uses the INCREMENTAL SPATIAL SEARCH function`20 X** of PHIGS to test if `7B\tt point`7D lies within a posted menu. X** The menus are tested begining the highest priority menu and working`20 X** through to the back menu. The position of `7B\tt point`7D relative X** to bottom-left corner of the menu item bounding box is returned X** in `7B\tt value`7D. X** The function returns TRUE if `7B\tt point`7D lies within a menu,`20 X** otherwise FALSE.`7D X*/ X`7B X ptkboolean menufound, itemfound; X ptksmenu *ptrmenu; X Pint foundstruct; X Pint elemno, pickid, firstpick, nextpick, nextpickid; X Pfloat div; X Plimit3 menubox; X Peltype extype; X Psrchstatus status; X Pint ptrlist`5B2`5D; X Pintlst elemlist; X Pint numstructs, i, err; X Pstructpostlst structlist; X Pintlst incl, excl; X Pint incllen, excllen; X Ppoint3 minbox, maxbox; X Pmatrix3 mat; X#ifdef SUN X Pexecreflst reflist, startlist; X Pexecref startpath; X Pint ceiling; X Pfilterlst normal, invert; X Pfilter filter; X Pfloat distance; X Pint totlen, len; X `20 X startlist.number = 1; X startlist.ers = &startpath; X startpath.elem_num = 0; X ceiling = 1; /* all of structure network */ X normal.num_filters = 1; X normal.filters = &filter; X filter.incl_set.number = 1; X filter.excl_set.number = 0; X filter.excl_set.integers = NULL; X invert.num_filters = 0; X invert.filters = NULL; X distance = 0.001; /* nearness to point */ X reflist.number = 0; X reflist.ers = NULL; X#endif X X ptk_stacktsl(); X ptk_stackbbox(); X menufound = FALSE; X structlist.postings = NULL; X /* inquire posted structures */ X pinqpostedstruct(wsid, 0, 0, &err, &structlist, &numstructs); X structlist.postings = (Pstructpost *)calloc(numstructs,`20 X sizeof(Pstructpost)); X pinqpostedstruct(wsid, numstructs, 0, &err, &structlist, &numstructs); X X /* inquire invisibility filter */ X pinqinvisfilter(wsid, 0, 0, 0, 0, &err, &incl, &incllen, &excl, &excllen); X incl.integers = (Pint *)calloc(incllen, sizeof(Pint)); X excl.integers = (Pint *)calloc(excllen, sizeof(Pint)); X incl.number = incllen; X excl.number = excllen; X pinqinvisfilter(wsid, incllen, 0, excllen, 0, &err, &incl, &incllen,`20 X &excl, &excllen); X`20 X /* This bit is a bit dodgy because it relies on structlist being ordered X ** by PHIGS into highest priority last. This is not standard PHIGS, X ** so if version is not sorted do a sort. X */ X i = numstructs - 1; X while ((i >= 0) && (!menufound))`20 X `7B X if (ismenu(structlist.postings`5Bi`5D.id, &ptrmenu)) X `7B X /* check invisibility filter */ X if (!((inintlst(ptrmenu->menuname, &incl) != -1) &&`20 X (inintlst(ptrmenu->menuname, &excl) == -1))) X `7B X#ifdef SUN X startpath.struct_id = ptrmenu->menustid; X filter.incl_set.integers = &ptrmenu->menuname; `20 X pincrspasrch(point, distance, &startlist, ceiling, &normal, X &invert, 0, 0, &err, &reflist, &totlen); X reflist.ers = (Pexecref *)calloc(totlen, sizeof(Pexecref)); X pincrspasrch(point, distance, &startlist, ceiling, &normal, X &invert, totlen, 0, &err, &reflist, &totlen); X if (reflist.number > 0) X `7B X menufound = TRUE; X *menuid = ptrmenu->menuid; X *value = ptk_point(0.0, 0.0); X foundstruct = reflist.ers`5B0`5D.struct_id; X elemno = reflist.ers`5B0`5D.elem_num; `20 X if (ptk_findnextpickid(foundstruct, PBACKWARD, &elemno, &pickid)) X *itemnum = pickid; X firstpick = 1; X ptk_findnextpickid(foundstruct, PFORWARD, &firstpick, &pickid); X X /* inquire TSL from element 1 to firstpick in foundstruct */ X ptk_inittsl(); X ptk_tsltraverserange(foundstruct, 1, foundstruct, firstpick, FALSE V); X nextpick = elemno + 1; X if (!ptk_findnextpickid(foundstruct, PFORWARD, &nextpick, &pickid) V) X nextpick = ptk_elemcount(foundstruct); X ptk_initbbox(); X ptk_tsltraverserange(foundstruct, elemno, foundstruct, nextpick,`2 V0 X TRUE); X`09 ptk_inqboundingbox(&menubox); X /* calculate value */ X div = menubox.xmax - menubox.xmin; X if (div != 0.0) X value->x = (point->x - menubox.xmin)/div; X div = menubox.ymax - menubox.ymin; X if (div != 0.0) X value->y = (point->y - menubox.ymin)/div; X free(reflist.ers); X `7D X#endif X#ifdef VMS X foundstruct = ptrmenu->menustid; X elemno = firstpick = 1; X ptk_findnextpickid(foundstruct, PFORWARD, &firstpick, &pickid); X ptk_inittsl(); X ptk_tsltraverserange(foundstruct, 1, foundstruct, firstpick, FALSE); X ptk_boundingbox(foundstruct, &menubox, TRUE); X if (ptinlimit3(point, &menubox)) X `7B X menufound = TRUE; X *menuid = ptrmenu->menuid; X itemfound = FALSE; X while (!itemfound) X`09 `7B X`09 ptk_stacktsl(); X ptk_stackbbox(); X if (ptk_findnextpickid(foundstruct, PFORWARD, &elemno, &pickid)) X`09 `7B X elemlist.number = 2; X elemlist.integers = ptrlist; X ptrlist`5B0`5D = elemno; X nextpick = elemno + 1; X if (!ptk_findnextpickid(foundstruct, PFORWARD, &nextpick,`20 X &nextpickid)) X nextpick = ptk_elemcount(foundstruct); X ptk_initbbox(); X ptk_tsltraverserange(foundstruct, elemno, foundstruct,`20 X nextpick, TRUE); X ptk_inqboundingbox(&menubox); X if (ptinlimit3(point, &menubox)) X`09 `7B X itemfound = TRUE; X *itemnum = pickid; `20 X /* calculate value */ X *value = ptk_point(0.0, 0.0); X div = menubox.xmax - menubox.xmin; X if (div != 0.0) X value->x = (point->x - menubox.xmin)/div; X div = menubox.ymax - menubox.ymin; X if (div != 0.0) X value->y = (point->y - menubox.ymin)/div; X `7D X else X elemno++; X `7D X else X`09 `7B X itemfound = TRUE; X *itemnum = 0; X `7D `20 X ptk_unstackbbox(); X ptk_unstacktsl(); X `7D X `7D X#endif X `7D X `7D X i--; X `7D X free(structlist.postings); X free(incl.integers); X free(excl.integers); X ptk_unstackbbox(); X ptk_unstacktsl(); X return menufound;`20 X`7D /* ptk_locscanmenus */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_scanmenus(C(Pint) wsid, C(ptksgeneralinput *) input,`2 V0 X C(ptksmenuoutput *) output) XPreANSI(Pint wsid) XPreANSI(ptksgeneralinput *input) XPreANSI(ptksmenuoutput *output) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7Bptksgeneralinput *`7D`7Binput`7D`7Binput data`7D`7BIN`7D X** \param`7Bptksmenuoutput *`7D`7Boutput`7D`7Boutput data`7D`7BIN`7D X** \paramend X** \blurb`7BThis function performs a scan on all posted menus using X** either string, pick or locator data. X** The function returns TRUE if a menu item has been selected,`20 X** otherwise FALSE.`7D X*/ X`7B X ptkboolean result; X X switch (input->inputclass)`20 X `7B X X case PI_LOCATOR: X result = ptk_locscanmenus(wsid, &input->ptkugeninput.locpoint,`20 X &output->menuid, &output->itemnum, &output->value V); X output->measure = TRUE; X break; X X case PI_STROKE: X result = FALSE; X break; X X case PI_VALUATOR: X result = FALSE; X break; X X case PI_CHOICE: X result = FALSE; X break; X X case PI_PICK: X result = ptk_pickscanmenus(&input->ptkugeninput.ptkspickinput.pickdata,` V20 X input->ptkugeninput.ptkspickinput.pathorder, X &output->menuid, &output->itemnum); X output->measure = FALSE; X break; X X case PI_STRING: X result = ptk_stringscanmenus(wsid, input->ptkugeninput.str,`20 X &output->menuid, &output->itemnum); X output->measure = FALSE; X break; X `7D X return result; X`7D /* ptk_scanmenus */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_setmenuposition(C(Pint) menuid, C(Ppoint *) menupos) XPreANSI(Pint menuid) XPreANSI(Ppoint *menupos) X/* X** \parambegin X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \param`7BPpoint *`7D`7Bmenupos`7D`7Bmenu position`7D`7BIN`7D X** \paramend X** \blurb`7BThis function sets the position of the top-left corner of the X** first menu item. The position is given in the range `5B0, 1`5D. If the X** position results in part of the menu being clipped then the actual X** position is adjusted so that as much as possible of the menu is`20 X** visible.`7D X*/ X`7B X Ppoint pos; X Ppoint3 mpos; X Pmatrix3 mat; X Plimit lim; X X pos = *menupos; X setmenu(menuid); X if (menuptr != NULL) X `7B X if (menuptr->menutype == PTKEBOXMENU) X `7B X getboxmenulimits(menupos, &lim); X if ((lim.xmin < 0.0) && (lim.xmax > 1.0)) +-+-+-+-+-+-+-+- END OF PART 211 +-+-+-+-+-+-+-+-