XIrc/src/dialogues.c

104 lines
2.2 KiB
C

#include "headers.h"
Widget XawVaMakeSimpleMenuEntry(Widget parent, const char *name, void *func, XtPointer data)
{
Widget w;
w = XtVaCreateManagedWidget(name, smeBSBObjectClass, parent, NULL);
XtAddCallback(w, XtNcallback, func, data);
return(w);
}
/* XawVaMakeSimpleMenu -- 0.1 */
/* Accepts a parent that contains the menu, a name for the menu, and the quantity of argument pairs supplied */
/* an "argument pair" consists of a name, used as the menu entry's label, and a callback, which is assigned to it. */
/* Returns NULL on failure, or a pointer to the menu on success. */
Widget XawVaMakeSimpleMenu(Widget parent, const char *name, int argtrips, ...)
{
va_list ap;
va_start(ap, argtrips);
void *labelp, *funcp, *datap;
int i;
Widget menu;
i = 0;
menu = 0;
if( (menu = XtVaCreatePopupShell(name, simpleMenuWidgetClass, parent, NULL)) == NULL)
{
return(NULL);
}
else
{
for(i = 0; i < argtrips; i++)
{
labelp = va_arg(ap, void*);
funcp = va_arg(ap, void*);
datap = va_arg(ap, void*);
XawVaMakeSimpleMenuEntry(menu, labelp, funcp, datap);
}
}
va_end(ap);
return(menu);
}
Widget XawVaCreateSimpleMenuBar(Widget parent, const char *name, int menutrip, ...)
{
va_list ap;
va_start(ap, menutrip);
char *bname, *mname;
int i;
Widget frame, gridbox, button;
i = 0;
frame = XtVaCreateManagedWidget(name, frameWidgetClass, parent,
XtNgridx, 0,
XtNgridy, 0,
XtNweightx, 1,
XtNshadowType, Raised,
XtNborderWidth, 1,
XtNshadowWidth, 1,
NULL);
gridbox = XtVaCreateManagedWidget("Menu Gridbox", gridboxWidgetClass, frame,
XtNgridx, 0,
XtNgridy, 0,
XtNweightx, 1,
NULL);
for(i = 0; i < menutrip; i++)
{
bname = va_arg(ap, void*);
mname = va_arg(ap, void*);
button = va_arg(ap, void*);
if(i+1 == menutrip)
{
XtVaCreateManagedWidget(NULL, labelWidgetClass, gridbox,
XtNgridy, 0,
XtNgridx, i++,
XtNweightx, 1,
XtNfill, FillNone,
XtNborderWidth, 0,
NULL);
}
*((Widget *) button) = XtVaCreateManagedWidget(bname, menuButtonWidgetClass, gridbox,
XtNgridy, 0,
XtNgridx, i,
XtNmenuName, mname,
NULL
);
}
va_end(ap);
return(frame);
}