1 /* $Header: /home/cvs/wavplay/menu.c,v 1.1.1.1 1999/11/21 19:50:56 wwg Exp $
2  * Warren W. Gay VE3WWG		Thu Feb 13 21:10:04 1997
3  *
4  * Menu related functions:
5  *
6  * 	X LessTif WAV Play :
7  *
8  * 	Copyright (C) 1997  Warren W. Gay VE3WWG
9  *
10  * This  program is free software; you can redistribute it and/or modify it
11  * under the  terms  of  the GNU General Public License as published by the
12  * Free Software Foundation version 2 of the License.
13  *
14  * This  program  is  distributed  in  the hope that it will be useful, but
15  * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17  * Public License for more details (see enclosed file COPYING).
18  *
19  * You  should have received a copy of the GNU General Public License along
20  * with this  program; if not, write to the Free Software Foundation, Inc.,
21  * 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * Send correspondance to:
24  *
25  * 	Warren W. Gay VE3WWG
26  *
27  * Email:
28  *	ve3wwg@yahoo.com
29  *	wgay@mackenziefinancial.com
30  *
31  * $Log: menu.c,v $
32  * Revision 1.1.1.1  1999/11/21 19:50:56  wwg
33  * Import wavplay-1.3 into CVS
34  *
35  * Revision 1.1  1997/04/14 00:04:22  wwg
36  * Initial revision
37  *
38  */
39 static const char rcsid[] = "@(#)menu.c $Revision: 1.1.1.1 $";
40 
41 #include <stdio.h>
42 #include <stdarg.h>
43 #include <Xm/Xm.h>
44 #include <Xm/RowColumn.h>
45 #include <Xm/PushB.h>
46 #include <Xm/CascadeB.h>
47 #include <Xm/ToggleB.h>
48 #include "xltwavplay.h"
49 
50 void
CreateMenu(Widget wMenuBar,Widget * wPulldown,char * namePulldown,Widget * wCascade,char * nameCascade,...)51 CreateMenu(
52   Widget wMenuBar,
53   Widget *wPulldown,
54   char *namePulldown,
55   Widget *wCascade,
56   char *nameCascade,
57   ...) {		/* char *classname,char menu_type,XtCallbackProc callback,Widget *pWidget,... */
58 	Arg al[32];
59 	Cardinal ac;
60 	va_list ap;
61 	Widget wChoice;
62 	/* Varargs repeating group: */
63 	char *nameChoice;			/* Class name of the item to select */
64 	char menu_type;				/* 'M' for normal menu, 'T'/'t' for toggle item */
65 	XtCallbackProc callback;		/* Callback procedure */
66 	Widget *wPointer;			/* Pointer to widget to return */
67 	Boolean tf;				/* Boolean value for 'T' and 't' types: */
68 
69 	va_start(ap,nameCascade);
70 
71 	ac = 0;
72 	*wPulldown = XmCreatePulldownMenu(wMenuBar,namePulldown,al,ac);
73 
74 	ac = 0;
75 	XtSetArg(al[ac],XmNsubMenuId,*wPulldown); ++ac;
76 	*wCascade = XmCreateCascadeButton(wMenuBar,nameCascade,al,ac);
77 
78 	nameChoice = va_arg(ap,char *);
79 
80 	while ( nameChoice != NULL ) {
81 		menu_type = va_arg(ap,char);		/* Get 'M' or 'T' */
82 		callback = va_arg(ap,XtCallbackProc);	/* Get callback address or NULL ptr */
83 		wPointer = va_arg(ap,Widget *);		/* Get address so we can return widget */
84 
85 		switch ( menu_type ) {
86 		case 'M' :
87 			ac = 0;
88 			*wPointer = wChoice = XmCreatePushButton(*wPulldown,nameChoice,al,ac);
89 			if ( callback != NULL )
90 				XtAddCallback(wChoice,XmNactivateCallback,callback,NULL);
91 			break;
92 		case 'T' :				/* Default is TRUE */
93 		case 't' :				/* Default is FALSE */
94 			tf = menu_type == 'T' ? TRUE : FALSE;
95 		        ac = 0;
96 	                XtSetArg(al[ac],XmNindicatorOn,TRUE); ++ac;
97 	                XtSetArg(al[ac],XmNset,tf); ++ac;
98                         XtSetArg(al[ac],XmNindicatorType,XmN_OF_MANY); ++ac;
99 			*wPointer = wChoice = XmCreateToggleButton(*wPulldown,nameChoice,al,ac);
100 			if ( callback != NULL )
101 				XtAddCallback(wChoice,XmNvalueChangedCallback,callback,NULL);
102 			break;
103 		default :
104 			abort();			/* This should never happen */
105 		}
106 		XtManageChild(wChoice);
107 
108 		nameChoice = va_arg(ap,char *);
109 	}
110 	XtManageChild(*wCascade);
111 	va_end(ap);
112 }
113 
114 /* $Source: /home/cvs/wavplay/menu.c,v $ */
115