Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!bloom-beacon!earth.cray.COM!jlf From: jlf@earth.cray.COM (John Freeman) Newsgroups: comp.windows.x Subject: Re: Help with the list widget Message-ID: <8904131446.AA28412@thelake.cray.com> Date: 13 Apr 89 14:46:48 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 59 > Does anyone have any helpful hints or code using the List widget. Here is a simple program using the list widget - note that it looks suspiciously like a menu. Hope this helps. -------------------------------------------------------------------------------- #include #include #include #include String the_list[] = { "select me!", "no, me!", "but not:", "quit", NULL }; /* ARGSUSED */ void Activate(w, closure, listp) Widget w; caddr_t closure; XtListReturnStruct *listp; { /** A practical use would be to use a switch & case here or a jump table **/ printf( "button \"%s\" was pressed, index = %d\n",listp->string, listp->index ); if (listp->index == 3) { printf("List Widget Demo exiting\n"); exit(0); } } void main(argc, argv) unsigned int argc; char **argv; { Widget toplevel; static XtCallbackRec callbacks[] = { { Activate, NULL }, { NULL, NULL }, }; static Arg argies[] = { { XtNlist, (XtArgVal)the_list }, { XtNdefaultColumns, (XtArgVal)1 }, { XtNforceColumns, (XtArgVal)True }, { XtNverticalList, (XtArgVal)True }, { XtNcallback, (XtArgVal)callbacks }, }; toplevel = XtInitialize( NULL, "List Widget Demo", NULL, 0, &argc, argv ); XtCreateManagedWidget( "list", listWidgetClass, toplevel, argies, XtNumber(argies) ); XtRealizeWidget(toplevel); XtMainLoop(); }