1#include <stdlib.h> 2#include <stdio.h> 3#include <X11/StringDefs.h> 4#include <Xaw/Viewport.h> 5#include <Xaw/Command.h> 6#include <Xaw/Box.h> 7static void 8quit_cb(Widget w, XtPointer client_data, XtPointer call_data) 9{ 10 XtAppSetExitFlag(XtWidgetToApplicationContext(w)); 11} 12 13int main(int argc, char **argv) 14{ 15 Widget toplevel,viewport,box,cmd; 16 XtAppContext app_con; 17 int i; 18 char buf[80]; 19 toplevel = XtAppInitialize(&app_con, "demo", NULL, 0, 20 &argc, argv, NULL, 21 NULL, 0); 22 23 viewport = XtVaCreateManagedWidget("view", viewportWidgetClass, toplevel, 24 XtNforceBars,True, 25 XtNallowVert,True, 26 NULL); 27 28 box = XtVaCreateManagedWidget("box", boxWidgetClass, viewport, 29 XtNvSpace,10, 30 NULL); 31 32 for (i=0;i<10;i++){ 33 sprintf(buf,"label%02d",i); 34 cmd=XtVaCreateManagedWidget("cmd", 35 commandWidgetClass, 36 box, XtNlabel, buf, NULL); 37 XtAddCallback(cmd, XtNcallback, quit_cb, NULL); 38 } 39 40 XtRealizeWidget(toplevel); 41 42 43 XtAppMainLoop(app_con); 44 exit(0); 45} 46