1efbcb2bfSmrg#include <stdlib.h>
2efbcb2bfSmrg#include <stdio.h>
3efbcb2bfSmrg#include <X11/StringDefs.h>
4efbcb2bfSmrg#include <Xaw/Box.h>
5efbcb2bfSmrg#include <Xaw/List.h>
6efbcb2bfSmrg#include <Xaw/Viewport.h>
7efbcb2bfSmrg#include <Xaw/Command.h>
8efbcb2bfSmrg
9efbcb2bfSmrgvoid quit_CB(Widget w, XtPointer closure, XtPointer call_data)
10efbcb2bfSmrg{
11efbcb2bfSmrg   Widget lst=closure;
12efbcb2bfSmrg   XawListReturnStruct *ret;
13efbcb2bfSmrg
14efbcb2bfSmrg   ret=XawListShowCurrent(lst);
15efbcb2bfSmrg
16efbcb2bfSmrg   if (ret->string[0] != 0)
17efbcb2bfSmrg   	printf("selected:%s\n",ret->string);
18efbcb2bfSmrg
19efbcb2bfSmrg   XtAppSetExitFlag(XtWidgetToApplicationContext(w));
20efbcb2bfSmrg}
21efbcb2bfSmrg
22efbcb2bfSmrgint main(int argc, char **argv)
23efbcb2bfSmrg{
24efbcb2bfSmrg    Widget toplevel,box,list,cmd,view;
25efbcb2bfSmrg    XtAppContext app_con;
26efbcb2bfSmrg    toplevel = XtAppInitialize(&app_con, "Hello", NULL, 0,
27efbcb2bfSmrg                               &argc, argv, NULL,
28efbcb2bfSmrg                               NULL, 0);
29efbcb2bfSmrg    char *items[]={ "the  ","quick","brown", "fox  ",
30efbcb2bfSmrg		    "jumps","Over","the","lazy","dog",
31efbcb2bfSmrg		    NULL};
32efbcb2bfSmrg
33efbcb2bfSmrg    box = XtCreateManagedWidget("box", boxWidgetClass, toplevel, NULL, 0);
34efbcb2bfSmrg    cmd=XtCreateManagedWidget("exit", commandWidgetClass, box, NULL, 0);
35efbcb2bfSmrg
36efbcb2bfSmrg   view=XtVaCreateManagedWidget("viewport", viewportWidgetClass, box,
37efbcb2bfSmrg				XtNallowVert, 1,
38efbcb2bfSmrg                                XtNforceBars,1,
39efbcb2bfSmrg				NULL);
40efbcb2bfSmrg
41efbcb2bfSmrg   list= XtVaCreateManagedWidget("listbox", listWidgetClass,view,
42efbcb2bfSmrg				  XtNlist,items,
43efbcb2bfSmrg				  XtNdefaultColumns,1,
44efbcb2bfSmrg				  XtNnumberStrings,4,
45efbcb2bfSmrg				  XtNforceColumns,1,
46efbcb2bfSmrg				  NULL);
47efbcb2bfSmrg    XawListChange(list,items,0,0,0);
48efbcb2bfSmrg    XtAddCallback(cmd, XtNcallback, quit_CB , list);
49efbcb2bfSmrg    XtRealizeWidget(toplevel);
50efbcb2bfSmrg    XtAppMainLoop(app_con);
51efbcb2bfSmrg    exit(0);
52efbcb2bfSmrg}
53