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