[ba.windows.x] help with XmCreateScrolledList

thanh@athertn.Atherton.COM (Thanh Diec) (06/25/91)

  Does anyone out there have a working example of XmCreateScrolledList()?
I have a procedure here to display a list in a scrolling window, but 
the window displayed is empty, without scrollbars or list.  Can anyone tell me
what is wrong with this procedure?  Whereas if I use the 'list' widget, the 
list is displayed.

Thanks in advance,

Thanh
thanh@atherton.com
(408)734-9822

==================== program ====================

#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <Xm/Xm.h>
#include <Xm/RowColumn.h>
#include <Xm/PushB.h>
#include <Xm/PanedW.h>
#include <Xm/BulletinB.h>
#include <Xm/List.h>


static Widget
  showList();

main(argc, argv)
     int   argc;
     char *argv[];
{
  XtAppContext         app_context;
  Widget               topLevel, root, cmd, add, quit, mlist;
  int                  addDesc, quitDesc;

  topLevel = XtVaAppInitialize(
    &app_context,
    "XAtdbux",
    NULL, 0,
    &argc, argv,
    NULL,
    NULL);

  showList(topLevel);

  XtRealizeWidget (topLevel);

  XtAppMainLoop(app_context);
}

static char *names[] = { "one", "two", "three" };

static
Widget
showList(parent)
  Widget          parent;
{
  XmString       *xmstr;
  Widget          bb, mlist;
  Arg             wargs[10];
  int             idx, n, namesCnt;

						/* base window */  	

  bb = XtCreateManagedWidget("bb", xmBulletinBoardWidgetClass, parent, NULL, 0);

							/* str -> xmstr */

  namesCnt = XtNumber(names);

  xmstr = (XmString *) XtMalloc(sizeof(XmString) * namesCnt);
  for (idx = 0; idx < namesCnt; idx++)
    xmstr[idx] = XmStringCreate(names[idx], XmSTRING_DEFAULT_CHARSET);

  n = 0;
  XtSetArg(wargs[n], XmNitems, xmstr); n++;  
  XtSetArg(wargs[n], XmNitemCount, namesCnt); n++;
  XtSetArg(wargs[n], XmNvisibleItemCount, namesCnt); n++;
  XtSetArg(wargs[n], XmNscrollingPolicy, XmAUTOMATIC); n++;

#if SCROLLED_LIST
							/* scrolled list, does NOT work, blank window */
  mlist = XmCreateScrolledList(bb, "mlist", wargs, n);
#else
							/* list, works */
  mlist = XtCreateManagedWidget("mlist", 
                               xmListWidgetClass, 
                               bb, wargs, n);
#endif
  return(mlist);
}