1c9e2be55Smrg/* 2c9e2be55Smrg * $XConsortium: menu.c,v 1.7 94/04/17 20:24:02 kaleb Exp $ 3c9e2be55Smrg * 4c9e2be55SmrgCopyright (c) 1989 X Consortium 5c9e2be55Smrg 6c9e2be55SmrgPermission is hereby granted, free of charge, to any person obtaining a copy 7c9e2be55Smrgof this software and associated documentation files (the "Software"), to deal 8c9e2be55Smrgin the Software without restriction, including without limitation the rights 9c9e2be55Smrgto use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10c9e2be55Smrgcopies of the Software, and to permit persons to whom the Software is 11c9e2be55Smrgfurnished to do so, subject to the following conditions: 12c9e2be55Smrg 13c9e2be55SmrgThe above copyright notice and this permission notice shall be included in 14c9e2be55Smrgall copies or substantial portions of the Software. 15c9e2be55Smrg 16c9e2be55SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17c9e2be55SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18c9e2be55SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19c9e2be55SmrgX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 20c9e2be55SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21c9e2be55SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22c9e2be55Smrg 23c9e2be55SmrgExcept as contained in this notice, the name of the X Consortium shall not be 24c9e2be55Smrgused in advertising or otherwise to promote the sale, use or other dealings 25c9e2be55Smrgin this Software without prior written authorization from the X Consortium. 26c9e2be55Smrg * 27c9e2be55Smrg */ 28c9e2be55Smrg/* $XFree86: xc/programs/xmh/menu.c,v 1.2 2001/08/01 00:45:06 tsi Exp $ */ 29c9e2be55Smrg 30c9e2be55Smrg#include "xmh.h" 31c9e2be55Smrg#include "bboxint.h" 32c9e2be55Smrg 33c9e2be55Smrg 34e2264b6dSmrgvoid AttachMenuToButton( 35e2264b6dSmrg Button button, 36e2264b6dSmrg Widget menu, 3766d665a3Smrg const char *menu_name) 38c9e2be55Smrg{ 39c9e2be55Smrg Arg args[3]; 40c9e2be55Smrg 41c9e2be55Smrg if (button == NULL) return; 42c9e2be55Smrg button->menu = menu; 43c9e2be55Smrg /* Yup, this is a memory leak. :-) */ 44c9e2be55Smrg XtSetArg(args[0], XtNmenuName, XtNewString(menu_name)); 45c9e2be55Smrg XtSetValues(button->widget, args, (Cardinal) 1); 46c9e2be55Smrg} 47c9e2be55Smrg 48c9e2be55Smrg 49c9e2be55Smrg/*ARGSUSED*/ 50e2264b6dSmrgvoid DoRememberMenuSelection( 51e2264b6dSmrg Widget widget, /* menu entry object */ 52e2264b6dSmrg XtPointer client_data, 53e2264b6dSmrg XtPointer call_data) 54c9e2be55Smrg{ 55c9e2be55Smrg static Arg args[] = { 56c9e2be55Smrg { XtNpopupOnEntry, (XtArgVal) NULL }, 57c9e2be55Smrg }; 58c9e2be55Smrg args[0].value = (XtArgVal) widget; 59c9e2be55Smrg XtSetValues(XtParent(widget), args, XtNumber(args)); 60c9e2be55Smrg} 61c9e2be55Smrg 62c9e2be55Smrg 63e2264b6dSmrgvoid SendMenuEntryEnableMsg( 64e2264b6dSmrg Button button, 6566d665a3Smrg const char *entry_name, 66e2264b6dSmrg int value) 67c9e2be55Smrg{ 68c9e2be55Smrg Widget entry; 69c9e2be55Smrg static Arg args[] = {{XtNsensitive, (XtArgVal) NULL}}; 70c9e2be55Smrg 71c9e2be55Smrg if ((entry = XtNameToWidget(button->menu, entry_name)) != NULL) { 72c9e2be55Smrg args[0].value = (XtArgVal) ((value == 0) ? False : True); 73c9e2be55Smrg XtSetValues(entry, args, (Cardinal) 1); 74c9e2be55Smrg } 75c9e2be55Smrg} 76c9e2be55Smrg 77c9e2be55Smrg 78c9e2be55Smrgvoid ToggleMenuItem(Widget entry, Boolean state) 79c9e2be55Smrg{ 80c9e2be55Smrg Arg args[1]; 81c9e2be55Smrg 82c9e2be55Smrg XtSetArg(args[0], XtNleftBitmap, (state ? MenuItemBitmap : None)); 83c9e2be55Smrg XtSetValues(entry, args, (Cardinal) 1); 84c9e2be55Smrg} 85