1efbcb2bfSmrg#include <stdlib.h> 2efbcb2bfSmrg#include <stdio.h> 3efbcb2bfSmrg#include <X11/StringDefs.h> 4efbcb2bfSmrg#include <Xaw/Box.h> 5efbcb2bfSmrg#include <Xaw/Command.h> 6efbcb2bfSmrg#include <Xaw/SimpleMenu.h> 7efbcb2bfSmrg#include <Xaw/MenuButton.h> 8efbcb2bfSmrg#include <Xaw/Sme.h> 9efbcb2bfSmrg#include <Xaw/SmeLine.h> 10efbcb2bfSmrg#include <Xaw/SmeBSB.h> 11efbcb2bfSmrg 12efbcb2bfSmrgstatic void 13efbcb2bfSmrgquit_cb(Widget w, XtPointer client_data, XtPointer call_data) 14efbcb2bfSmrg{ 15efbcb2bfSmrg XtAppSetExitFlag(XtWidgetToApplicationContext(w)); 16efbcb2bfSmrg} 17efbcb2bfSmrg 18efbcb2bfSmrgvoid setupmenu(Widget top) 19efbcb2bfSmrg{ 20efbcb2bfSmrg Widget button, menu; 21efbcb2bfSmrg char buf[256]; 22efbcb2bfSmrg int i; 23efbcb2bfSmrg 24efbcb2bfSmrg button = XtVaCreateManagedWidget("menuButton", menuButtonWidgetClass, top, 25efbcb2bfSmrg NULL); 26efbcb2bfSmrg 27efbcb2bfSmrg menu = XtVaCreatePopupShell("menu", simpleMenuWidgetClass, 28efbcb2bfSmrg button, NULL); 29efbcb2bfSmrg 30efbcb2bfSmrg for (i = 1; i < 6; i++) { 31efbcb2bfSmrg sprintf(buf, "menuEntry%d", i ); 32efbcb2bfSmrg (void) XtVaCreateManagedWidget(buf, smeBSBObjectClass, menu, NULL); 33efbcb2bfSmrg if (i == 2) 34efbcb2bfSmrg (void) XtVaCreateManagedWidget("menuButton", smeLineObjectClass, 35efbcb2bfSmrg menu, NULL); 36efbcb2bfSmrg } 37efbcb2bfSmrg 38efbcb2bfSmrg} 39efbcb2bfSmrg 40efbcb2bfSmrgint main(int argc, char **argv) 41efbcb2bfSmrg{ 42efbcb2bfSmrg Widget toplevel,box,command; 43efbcb2bfSmrg XtAppContext app_con; 44efbcb2bfSmrg toplevel = XtAppInitialize(&app_con, "demo", NULL, 0, 45efbcb2bfSmrg &argc, argv, NULL, 46efbcb2bfSmrg NULL, 0); 47efbcb2bfSmrg 48efbcb2bfSmrg box = XtCreateManagedWidget("box", boxWidgetClass, toplevel, NULL, 0); 49efbcb2bfSmrg 50efbcb2bfSmrg command = XtVaCreateManagedWidget("cmd", 51efbcb2bfSmrg commandWidgetClass, box, 52efbcb2bfSmrg XtNlabel, "EXIT", 53efbcb2bfSmrg NULL); 54efbcb2bfSmrg 55efbcb2bfSmrg XtAddCallback(command, XtNcallback, quit_cb, NULL); 56efbcb2bfSmrg 57efbcb2bfSmrg setupmenu(box); 58efbcb2bfSmrg 59efbcb2bfSmrg XtRealizeWidget(toplevel); 60efbcb2bfSmrg XtAppMainLoop(app_con); 61efbcb2bfSmrg exit(0); 62efbcb2bfSmrg} 63