-+-+-+-+-+-+-+-+ START OF PART 209 -+-+-+-+-+-+-+-+ X`09`09 -0.5 * menuptr->boxsize.y, 0.0); X centresize = ptk_point(menuptr->boxsize.x -`20 X (2.0 * menuptr->framesize.x), X menuptr->boxsize.y -`20 X (2.0 * menuptr->framesize.y)); X ptk_framebox(&box_centre, ¢resize, &menuptr->framesize, X intcolour, edgecolour, tlcolour, brcolour); X /* replace text colour if required */ X eltype`5B0`5D = PEL_TEXT_COLOUR_INDEX; X eltype`5B1`5D = PEL_PICK_ID; X ptk_findelemtype(eltype, 2, PFORWARD, &stat, &elptr, &lstnum); X if ((stat == PSUCCESS) && (lstnum == 0)) X `7B X pdelelem(); X psettextcolourind(textcolour); X `7D X`7D /* redrawboxmenuitem */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void resetcharheight() X`7B X ptk_openstruct(menuptr->menustid); X psetelemptr(0); X psetelemptrlabel(ptk_stringtoint("label", "charheight")); X poffsetelemptr(1); X pdelelem(); X psetcharheight(menuptr->charheight); X ptk_closestruct(); X`7D /* resetcharheight */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void getboxmenulimits(C(Ppoint *) pos, C(Plimit *) lims) XPreANSI(Ppoint *pos) XPreANSI(Plimit *lims) X`7B X Pfloat xdimen, ydimen; X X xdimen = menuptr->boxsize.x; /* + (2.0 * menuptr->framesize.x); */ X ydimen = menuptr->boxsize.y; /* + (2.0 * menuptr->framesize.y); */ X *lims = ptk_limit(pos->x, pos->x, pos->y, pos->y); X switch (menuptr->menupath) X `7B X case PTP_RIGHT: X lims->xmax += ((Pfloat)menuptr->maxitem * xdimen); X lims->ymin -= ydimen; X break; X X case PTP_LEFT: X lims->xmin -= (menuptr->maxitem - 1) * xdimen; X lims->xmax += xdimen; X lims->ymin -= ydimen; X break; X X case PTP_UP: X lims->xmax += xdimen; X lims->ymin -= ydimen; X lims->ymax += ((Pfloat)(menuptr->maxitem - 1) * ydimen); X break; X X case PTP_DOWN: X lims->xmax += xdimen; X lims->ymin -= ((Pfloat)menuptr->maxitem * ydimen); X break; X `7D X`7D /* getboxmenulimits */ X X/*-------------------------------------------------------------------------- V*/ X/*------------------- exported menu routines ------------------------------- V*/ X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_createusermenu(C(Pint) menuid, C(Pint) menustid) XPreANSI(Pint menuid) XPreANSI(Pint menustid) X/* X** \parambegin X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \param`7BPint`7D`7Bmenustid`7D`7Bmenu structure identifier`7D`7BIN`7D X** \paramend X** \blurb`7BThis function creates a user menu using the structure X** `7B\tt menustid`7D. Each menu item must be an individual PHIGS X** structure or network and the menu initially contains no menu items. X** This function requires hashtables "label", "name".`7D`20 X*/ X`7B X ptksmenu *newmenu; X Pintlst incl; X Pint inclname; X Pchar stname`5B30`5D; X Pmatrix3 unitmat; X X setmenu(menuid); X if (menuptr == NULL) X `7B X if (lastmenu == NULL) X `7B X firstmenu = lastmenu = newmenu = X (ptksmenu *)malloc(sizeof(ptksmenu)); X newmenu->next = NULL; X `7D X else X `7B X lastmenu->next = newmenu = (ptksmenu *)malloc(sizeof(ptksmenu)); X newmenu->next = NULL; X lastmenu = lastmenu->next; X `7D X X menucount++; `20 X newmenu->menuid = menuid; X newmenu->menustid = menustid; X newmenu->maxitem = 0; X newmenu->highlight = 0; X newmenu->posted.number = 0; X newmenu->posted.integers = (Pint *)calloc(10, sizeof(Pint)); X sprintf(stname, "name$menu%d", menuid); X newmenu->menuname = ptk_stringtoint("name", stname); X ptk_openstruct(newmenu->menustid); X ptk_seteditmode(PEDIT_INSERT); X psetelemptr(0); X `20 X newmenu->menutype = PTKEUSERMENU; X `20 X incl.number = 1; X incl.integers = &inclname;`20 X incl.integers`5B0`5D = newmenu->menuname; X `20 X plabel(ptk_stringtoint("label", "menuviewind")); X `20 X plabel(ptk_stringtoint("label", "globaltran")); X ptk_unitmatrix3(unitmat); X psetglobaltran3(unitmat); X X paddnameset(&incl); X plabel(ptk_stringtoint("label", "begin-menu")); X X plabel(ptk_stringtoint("label", "end-menu")); X premovenameset(&incl); X ptk_unseteditmode(); X ptk_closestruct(); X `7D X`7D /* ptk_createusermenu */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void createboxmenu(C(Pint) menuid, X C(Ppoint *) tlcorner, C(Ppoint *) boxsize, X C(Ptxpath) menupath, C(Pint) textcolour, C(Pint) intcolour,`20 X C(Pint) edgecolour, C(Pint) boxtlcolour, C(Pint) boxbrcolour) XPreANSI(Pint menuid) XPreANSI(Ppoint *tlcorner) XPreANSI(Ppoint *boxsize) XPreANSI(Ptxpath menupath) XPreANSI(Pint textcolour) XPreANSI(Pint intcolour) XPreANSI(Pint edgecolour) XPreANSI(Pint boxtlcolour) XPreANSI(Pint boxbrcolour) X/* X** \parambegin X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \param`7BPpoint *`7D`7Btlcorner`7D`7Btop left corner of menu`7D`7BIN`7D X** \param`7BPpoint *`7D`7Bboxsize`7D`7Bwidth and height of menu box item`7D` V7BIN`7D X** \param`7BPtxpath`7D`7Bmenupath`7D`7Bpath of box menu (left, right, up, do Vwn)`7D`7BIN`7D X** \param`7BPint`7D`7Btextcolour`7D`7Bcolour index for text`7D`7BIN`7D X** \param`7BPint`7D`7Bintcolour`7D`7Bcolour index for interior`7D`7BIN`7D X** \param`7BPint`7D`7Bedgecolour`7D`7Bcolour index for edges`7D`7BIN`7D X** \param`7BPint`7D`7Bboxtlcolour`7D`7Bcolour index for top-left of box`7D`7 VBIN`7D X** \param`7BPint`7D`7Bboxcolour`7D`7Bcolour index for bottom-right of box`7D V`7BIN`7D X** \paramend X** \blurb`7BCreate a box menu using given specification.`7D X*/ X`7B X Ptxalign align; X Pmatrix3 mat; X ptksmenu *newmenu; X Pintlst wsids; X Pint err, totlen, wsid; X Pchar stname`5B20`5D, *str; X Pintlst incl; X Pint inclname, i, maxchars; X Pfloat charheight, framedim; X Ppoint3 pos; X X setmenu(menuid); X if (menuptr == NULL) X `7B X if (lastmenu == NULL) X `7B X firstmenu = lastmenu = newmenu = X (ptksmenu *)malloc(sizeof(ptksmenu)); X newmenu->next = NULL; X `7D X else X `7B X lastmenu->next = newmenu = (ptksmenu *)malloc(sizeof(ptksmenu)); X newmenu->next = NULL; X lastmenu = lastmenu->next; X `7D X `20 X menucount++; X newmenu->menuid = menuid; X wsids.integers = &wsid; X pinqsetopenws(1, 0, &err, &wsids, &totlen); X newmenu->wsid = wsids.integers`5B0`5D; X newmenu->font = 1; X newmenu->highlight = 0; X newmenu->posted.number = 0; X newmenu->posted.integers = (Pint *)calloc(10, sizeof(Pint)); X sprintf(stname, "struct$menu%d", menuid); X newmenu->menustid = ptk_stringtoint("structureid", stname); X sprintf(stname, "name$menu%d", menuid); X newmenu->menuname = ptk_stringtoint("name", stname); `20 X newmenu->menutype = PTKEBOXMENU; X newmenu->boxsize = *boxsize; X newmenu->menupath = menupath; X newmenu->menuposition = *tlcorner; X newmenu->maxitem = 0; X newmenu->charheight = 100.0; X newmenu->longstr`5B0`5D = '\0'; X newmenu->intcolour = intcolour; X newmenu->edgecolour = edgecolour; X newmenu->tlcolour = boxtlcolour; X newmenu->brcolour = boxbrcolour; X newmenu->textcolour = textcolour; X newmenu->htintcolour = textcolour; X newmenu->htedgecolour = edgecolour; X newmenu->httextcolour = intcolour; X newmenu->httlcolour = boxbrcolour; X newmenu->htbrcolour = boxtlcolour; X X framedim = 0.05 * MIN(boxsize->x, boxsize->y); X newmenu->framesize = ptk_point(framedim, framedim); X X incl.number = 1; X incl.integers = &inclname; X incl.integers`5B0`5D = newmenu->menuname; X X ptk_openstruct(newmenu->menustid); X ptk_seteditmode(PEDIT_INSERT); X paddnameset(&incl); X `20 X plabel(ptk_stringtoint("label", "menuviewind")); X X plabel(ptk_stringtoint("label", "globaltran")); X pos = ptk_point3(tlcorner->x, tlcorner->y, 0.0); X ptk_shift3(&pos, PREPLACE, mat); X psetglobaltran3(mat); `20 X /* calculate text expan */ X psettextprec(PPSTROKE); X plabel(ptk_stringtoint("label", "charheight")); X charheight = 0.01; X psetcharheight(charheight); X psettextfont(1); X align.hor = PAH_CENTRE; X align.ver = PAV_HALF; X psettextalign(&align); X plabel(ptk_stringtoint("label", "begin-menu")); X X plabel(ptk_stringtoint("label", "end-menu")); X premovenameset(&incl); X ptk_unseteditmode(); X ptk_closestruct(); X `7D X`7D /* createboxmenu */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_createboxmenu(C(Pint) menuid, X C(Ppoint *) tlcorner, C(Ppoint *) boxsize) XPreANSI(Pint menuid) XPreANSI(Ppoint *tlcorner) XPreANSI(Ppoint *boxsize) X/* X** \parambegin X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \param`7BPpoint *`7D`7Btlcorner`7D`7Btop left corner of menu`7D`7BIN`7D X** \param`7BPpoint *`7D`7Bboxsize`7D`7Bwidth and height of menu box item`7D` V7BIN`7D X** \paramend X** \blurb`7BThis function creates a box menu with no initial items. X** The position of the menu is specified by `7B\tt tlcorner`7D which X** defines the top-left corner of the first menu item. The position X** and size of box menu items are given in the range `5B0, 1`5D. The default X** menu path is DOWN. X** This function requires hashtables "structureid", "label", "name".`7D`20 X*/ X`7B X createboxmenu(menuid, tlcorner, boxsize, PTP_DOWN, 1, 0, 1, 0, 0); X`7D /* ptk_createboxmenu */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void insertboxtextitem(C(Pint) eltno, C(Pchar *) str, C(Pint) itemnum V) XPreANSI(Pint eltno) XPreANSI(Pchar *str) XPreANSI(Pint itemnum) X/* X** \parambegin X** \param`7BPint`7D`7Beltno`7D`7Belement pointer`7D`7BIN`7D X** \param`7B`7D`7Bmenubox`7D`7Bmenu item description data`7D`7BIN`7D X** \paramend X** \blurb`7BAdd item to box menu.`7D X*/ X`7B X Pmatrix3 matrix, shiftmat; X Pfloat scl, charheight; X Ppoint3 box_centre; X Ppoint3 tlpt; X Pint err; X Plimit3 boundbox, itembox; X Ppoint centresize, txpt; X X psetelemptr(eltno); X psetpickid(itemnum); X tlpt = get_tlboxcorner(itemnum); X ptk_shift3(&tlpt, PREPLACE, shiftmat); X psetlocaltran3(shiftmat, PREPLACE);`20 X X box_centre = ptk_point3(0.5 * menuptr->boxsize.x, X`09`09 -0.5 * menuptr->boxsize.y, 0.0); X centresize = ptk_point(menuptr->boxsize.x -`20 X (2.0 * menuptr->framesize.x), X menuptr->boxsize.y -`20 X (2.0 * menuptr->framesize.y)); X ptk_framebox(&box_centre, ¢resize, &menuptr->framesize, X menuptr->intcolour, menuptr->edgecolour, X menuptr->tlcolour, menuptr->brcolour); X X /* recalculate character height if necessary */ X ptk_computecharheight(menuptr->wsid, str, ¢resize, menuptr->font,`20 X &charheight); X if (charheight < menuptr->charheight) X `7B X strcpy(menuptr->longstr, str); X menuptr->charheight = charheight; X resetcharheight(); X `7D`20 X psettextcolourind(menuptr->textcolour); X txpt = ptk_point(box_centre.x, box_centre.y); X ptext(&txpt, str); X`7D /* insertboxtextitem */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_createtextmenuitem(C(Pint) menuid, C(Pchar *) str,`20 X C(Pint) itemno, C(Peditmode) editmode, C(Pint *) error) XPreANSI(Pint menuid) XPreANSI(Pchar *str) XPreANSI(Pint itemno) XPreANSI(Peditmode editmode) XPreANSI(Pint *error) X/* X** \parambegin X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \param`7BPchar *`7D`7Bstr`7D`7Btext string`7D`7BIN`7D X** \param`7BPint`7D`7Bitemno`7D`7Bmenu item number`7D`7BIN`7D X** \param`7BPeditmode`7D`7Beditmode`7D`7Binsert or replace menu item.`7D`7BI VN`7D X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BIN`7D X** \paramend X** \blurb`7BThis function creates a box menu item containing the character X** string `7B\tt str`7D. The string is automatically scaled to fit inside X** the menu item box. This function may only be used with box menus. X** The error code = 1 if `7B\tt menuid`7D doesn't exist and = 2 if the X** menu is not a box menu.`7D X*/ X`7B X Pint elt; X Pint itemalreadythere; X X /* check menu name supplied, if it has no prefix add current structure`20 X ** prefix. X */ X`20 X *error = 0; X setmenu(menuid); X if (menuptr != NULL) X `7B X ptk_seteditmode(PEDIT_INSERT); X ptk_openstruct(menuptr->menustid); X if (menuptr->menutype != PTKEBOXMENU) X *error = 2; X else`20 X `7B X find_insertion_pt(menuptr->menustid, itemno, &elt, &itemalreadythere); X if (itemalreadythere == itemno)`20 X `7B X if (editmode == PEDIT_INSERT) /* shift following items up by one */ X shift_items(elt, 1); X else /* mode is replace, therefore delete old item */ X delete_item(menuptr->menustid, itemno); X `7D X /* add new item before elt */ X insertboxtextitem(elt - 1, str, itemno); X if (itemno > menuptr->maxitem) X menuptr->maxitem = itemno; X `7D X ptk_closestruct(); X ptk_unseteditmode(); X `7D X else X *error = 1; X`7D /* ptk_createtextmenuitem */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void insertboxstructitem(C(Pint) eltno, C(Pint) stid, C(Pint) itemnum V) XPreANSI(Pint eltno) XPreANSI(Pint stid) XPreANSI(Pint itemnum) X/* X** \parambegin X** \param`7BPint`7D`7Beltno`7D`7Belement pointer`7D`7BIN`7D X** \param`7B`7D`7Bmenubox`7D`7Bmenu item description data`7D`7BIN`7D X** \paramend X** \blurb`7BAdd item to box menu.`7D X*/ X`7B X Pmatrix3 matrix, shiftmat; X Pfloat scl, charheight; X Ppoint3 box_centre; X Ppoint3 tlpt; X Pint err; X Plimit3 boundbox, itembox; X Ppoint centresize, txpt; X X psetelemptr(eltno); X psetpickid(itemnum); X tlpt = get_tlboxcorner(itemnum); X ptk_shift3(&tlpt, PREPLACE, shiftmat); +-+-+-+-+-+-+-+- END OF PART 209 +-+-+-+-+-+-+-+-