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