-+-+-+-+-+-+-+-+ START OF PART 210 -+-+-+-+-+-+-+-+ X psetlocaltran3(shiftmat, PREPLACE);`20 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 if (ptk_boundingbox(stid, &boundbox, TRUE)) X `7B X itembox = ptk_limit3(0.0, menuptr->boxsize.x,`20 X -menuptr->boxsize.y, 0.0, 0.0, 1.0); X ptk_box3tobox3(&boundbox, &itembox, FALSE, PREPLACE, matrix, &err); X psetlocaltran3(matrix, PPRECONCATENATE); X pexecutestruct(stid); X `7D X`7D /* insertboxstructitem */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void insertuseritem(C(Pint) eltno, C(Pint) stid, C(Pint) itemnum) 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`7Busermenu`7D`7Bmenu item description data`7D`7BIN`7D X** \paramend X** \blurb`7BAdd user menu item to currently open structure.`7D X*/ X`7B X ptk_seteditmode(PEDIT_INSERT); X psetelemptr(eltno); X psetpickid(itemnum); X pexecutestruct(stid); X ptk_unseteditmode(); X`7D /* insertuseritem */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_createstructmenuitem(C(Pint) menuid, C(Pint) structure,`20 X C(Pint) itemno, C(Peditmode) editmode, C(Pint *) error) XPreANSI(Pint menuid) XPreANSI(Pint structure) 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`7BPint`7D`7Bstructure`7D`7Bmenu item structure identifier`7D`7BIN` V7D X** \param`7BPint`7D`7Bitemno`7D`7Bmenu item number`7D`7BIN`7D X** \param`7BPeditmode`7D`7Beditmode`7D`7Binsert or replace menu item`7D`7BIN V`7D X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BIN`7D X** \paramend X** \blurb`7BThis function creates a menu item defined by `7B\tt structure`7D V. X** In the case of box menus the structure is mapped into the item box X** with aspect ratio preserved. No transformation is applied for user X** menu items. The error code = 1 if `7B\tt menuid`7D doesn't exist.`7D X*/ X`7B X Pint elt; X Pint itemalreadythere; X X *error = 0; X setmenu(menuid); X if (menuptr != NULL) X `7B X ptk_openstruct(menuptr->menustid); X ptk_seteditmode(PEDIT_INSERT); X `7B X 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 if ((menuptr->menutype == PTKEUSERMENU) `7C`7C`20 X (menuptr->menutype == PTKEROTATOR)) X insertuseritem(elt - 1, structure, itemno); X else X insertboxstructitem(elt - 1, structure, itemno); X if (itemno > menuptr->maxitem) X menuptr->maxitem = itemno; X `7D X ptk_unseteditmode(); X ptk_closestruct(); X `7D X else X *error = 1; X`7D /* ptk_createstructmenuitem */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_delmenu(C(Pint) menuid) XPreANSI(Pint menuid) X/* X** \parambegin X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \paramend X** \blurb`7BThis function deletes a menu from the PHIGS Toolkit menu store. X** The function returns TRUE if `7B\tt menuid`7D is deleted, otherwise FALSE V.`7D X*/ X`7B X ptksmenu *ptr, *junk; X Pchar stname`5B20`5D; X Pint i; X X setmenu(menuid); X if (menuptr != NULL) X `7B X for (i = 0; i < menuptr->posted.number; i++) X ptk_unpostmenu(menuptr->posted.integers`5Bi`5D, menuid); X pdelstruct(menuptr->menustid); X ptr = firstmenu; X if (ptr->menuid == menuid) X `7B X firstmenu = firstmenu->next; X if (lastmenu->menuid == menuid) X lastmenu = firstmenu; X free(ptr); X `7D X else X `7B X while (ptr->next->menuid != menuid) X `7B X ptr = ptr->next; X if (ptr->next == NULL) X return FALSE; X `7D X junk = ptr->next; X ptr->next = junk->next; X free(junk); X if (ptr->next == NULL) X lastmenu = ptr; X `7D X /* delete strings */ X sprintf(stname, "name$menu%d", menuid); X ptk_delstring("name", stname); X sprintf(stname, "struct$menu%d", menuid); X ptk_delstring("structureid", stname); X menucount--; X return TRUE; X `7D X else X return FALSE; X`7D /* ptk_delmenu */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_delmenuitem(C(Pint) menuid, C(Pint) itemno) XPreANSI(Pint menuid) XPreANSI(Pint itemno) X/* X** \parambegin X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \param`7BPint`7D`7Bitemno`7D`7Bmenu item to delete`7D`7BIN`7D X** \paramend X** \blurb`7BThis function deletes the menu item `7B\tt itemno`7D. X** The function returns TRUE if the menu item is deleted, otherwise FALSE.`7 VD X*/ X`7B X Pint elptr, lstnum, err, numelems; X Pfloat charheight, minheight; X Pchar *buffer; X Peltype eltype; X Psrchstatus stat; X ptkselcontent elcont; X Ppoint centresize; X X setmenu(menuid); X if (menuptr != NULL) X `7B X if (!find_item(menuptr->menustid, itemno, &elptr))`20 X `7B X return FALSE; X `7D X ptk_openstruct(menuptr->menustid); X delete_item(menuptr->menustid, itemno); X shift_items(elptr, -1); X ptk_closestruct(); X /* reset charheight to longest item string. X ** search for all PEL_TEXT elements in menu structure and X ** set charheight to cater for the longest X */ X numelems = ptk_elemcount(menuptr->menustid); X ptk_openstruct(menuptr->menustid); X elptr = 0; X eltype = PEL_TEXT; X minheight = 100.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 do X `7B X psetelemptr(elptr); X ptk_findelemtype(&eltype, 1, PFORWARD, &stat, &elptr, &lstnum); X if (stat == PSUCCESS) X `7B X ptk_inqelemtypesizecontent(menuptr->menustid, elptr, &err, &buffer, X &elcont); X#ifdef SUN X ptk_computecharheight(menuptr->wsid, elcont.eldata.tx.str,`20 X ¢resize, menuptr->font, &charheight); X#endif X#ifdef VMS X ptk_computecharheight(menuptr->wsid, elcont.eldata.text.string,`20 X ¢resize, menuptr->font, &charheight); X#endif X if (charheight < minheight) X `7B X#ifdef SUN X strcpy(menuptr->longstr, elcont.eldata.tx.str); X#endif X#ifdef VMS X strcpy(menuptr->longstr, elcont.eldata.text.string); X#endif X minheight = charheight; X `7D X free(buffer); X `7D X elptr++; X `7D while ((stat == PSUCCESS) && (elptr <= numelems)); X ptk_closestruct(); X if (minheight < 100.0) X `7B X menuptr->charheight = minheight; X resetcharheight(); X `7D X return TRUE; X `7D X else X return FALSE; X`7D /* ptk_delmenuitem */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_frontmenu(C(Pint) wsid, C(Pint) menuid) XPreANSI(Pint wsid) XPreANSI(Pint menuid) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \paramend`20 X** \blurb`7BThis function sets the post priority of the menu structure X** so that it is displayed on top of all the other posted menus and X** windows.`7D X*/ X`7B X Pint ind, err, frontwindow, backwindow, frontwindowstid, fronticonstid; X ptkboolean windows; X ptkewindowstate frontstate, backstate; X X setmenu(menuid); X if (menuptr != NULL) X `7B X checkws(wsid); X findwsid(wsid, &ind); X windows = ptk_inqfrontbackwindowid(wsid, &frontwindow, &frontstate, X &backwindow, &backstate, &err); X if (!wsmenus`5Bind`5D.postedmenus) X `7B X if (windows) X `7B X ptk_inqwindowstructid(frontwindow, &frontwindowstid, &fronticonstid, X &err); X if (frontstate == PTKEWINDOWOPEN) X ptk_postrelative(wsid, menuptr->menustid, PHIGHER, X frontwindowstid, &err); X else X ptk_postrelative(wsid, menuptr->menustid, PHIGHER, X fronticonstid, &err); X `7D X else X ppoststruct(wsid, menuptr->menustid, 0.0); X wsmenus`5Bind`5D.frontptr = wsmenus`5Bind`5D.backptr = menuptr; X wsmenus`5Bind`5D.postedmenus = TRUE; X `7D X else X `7B X ptk_postrelative(wsid, menuptr->menustid, PHIGHER, X wsmenus`5Bind`5D.frontptr->menustid, &err); X wsmenus`5Bind`5D.frontptr = menuptr; X if (menuptr == wsmenus`5Bind`5D.backptr) X findback(wsid, &wsmenus`5Bind`5D); X `7D X addtointlst(wsid, &menuptr->posted); X `7D X`7D /* ptk_frontmenu */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_backmenu(C(Pint) wsid, C(Pint) menuid) XPreANSI(Pint wsid) XPreANSI(Pint menuid) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \paramend`20 X** \blurb`7BThis function sets the post priority of the menu structure so X** that it is displayed below all other posted menus but in front of X** all posted windows.`7D X*/ X`7B X Pint ind, err, frontwindow, backwindow, frontwindowstid, fronticonstid; X ptkboolean windows; X ptkewindowstate frontstate, backstate; X X setmenu(menuid); X if (menuptr != NULL) X `7B X checkws(wsid); X findwsid(wsid, &ind); X windows = ptk_inqfrontbackwindowid(wsid, &frontwindow, &frontstate, X &backwindow, &backstate, &err); X if (windows) X `7B X ptk_inqwindowstructid(frontwindow, &frontwindowstid, &fronticonstid, X &err); X if (frontstate == PTKEWINDOWOPEN) X ptk_postrelative(wsid, menuptr->menustid, PHIGHER, X frontwindowstid, &err); X else X ptk_postrelative(wsid, menuptr->menustid, PHIGHER, X fronticonstid, &err); X `7D X else X if (!wsmenus`5Bind`5D.postedmenus) X ppoststruct(wsid, menuptr->menustid, 0.0); X else X ptk_postrelative(wsid, menuptr->menustid, PLOWER, X wsmenus`5Bind`5D.backptr->menustid, &err); X if (!wsmenus`5Bind`5D.postedmenus) X `7B X wsmenus`5Bind`5D.frontptr = wsmenus`5Bind`5D.backptr = menuptr; X wsmenus`5Bind`5D.postedmenus = TRUE; X `7D X else X `7B X wsmenus`5Bind`5D.backptr = menuptr; X if (menuptr == wsmenus`5Bind`5D.frontptr) X findfront(wsid, &wsmenus`5Bind`5D); X `7D X addtointlst(wsid, &menuptr->posted); X `7D X`7D /* ptk_backmenu */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_postmenu(C(Pint) wsid, C(Pint) menuid) XPreANSI(Pint wsid) XPreANSI(Pint menuid) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \paramend X** \blurb`7BThis function posts the menu structure to the workstation X** `7B\tt wsid`7D. The priority of the menu structure is controlled by the X** PHIGS Toolkit menu system to provide an ordered stacking of displayed X** menus. When `7B\tt menuid`7D is posted it becomes the front menu.`7D`20 X*/ X`7B X ptk_frontmenu(wsid, menuid); X`7D /* ptk_postmenu */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_unpostmenu(C(Pint) wsid, C(Pint) menuid) XPreANSI(Pint wsid) XPreANSI(Pint menuid) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \paramend X** \blurb`7BThis function unposts a menu structure from the workstation X** `7B\tt wsid`7D. The front and back menus are updated if necessary.`7D X*/ X`7B X Pint ind; X X setmenu(menuid); X if (menuptr != NULL) X `7B X findwsid(wsid, &ind); X punpoststruct(wsid, menuptr->menustid); X if (menuptr == wsmenus`5Bind`5D.backptr) X findback(wsid, &wsmenus`5Bind`5D); X if (menuptr == wsmenus`5Bind`5D.frontptr) X findfront(wsid, &wsmenus`5Bind`5D); X removefromintlst(wsid, &menuptr->posted); X `7D X`7D /* ptk_unpostmenu */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_unpostallmenu(C(Pint) wsid) XPreANSI(Pint wsid) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPint`7D`7Bmenuid`7D`7Bmenu identifier`7D`7BIN`7D X** \paramend X** \blurb`7BThis function unposts all menus from the workstation `7B\tt wsid V`7D.`7D X*/ X`7B X ptksmenu *ptrmenu; X X ptrmenu = firstmenu; X while (ptrmenu != NULL) X `7B X if (inintlst(wsid, &ptrmenu->posted) != -1) X ptk_unpostmenu(wsid, ptrmenu->menuid); X ptrmenu = ptrmenu->next; X `7D X`7D /* ptk_unpostallmenu */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ +-+-+-+-+-+-+-+- END OF PART 210 +-+-+-+-+-+-+-+-