home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / windows / x / motif / 5634 < prev    next >
Encoding:
Text File  |  1992-08-15  |  3.1 KB  |  109 lines

  1. Newsgroups: comp.windows.x.motif
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ncar!laplata.scd.ucar.edu!morreale
  3. From: morreale@laplata.scd.ucar.edu (Peter Morreale)
  4. Subject: Width of SelectionBoxDialog....
  5. Message-ID: <1992Aug15.160502.28082@ncar.ucar.edu>
  6. Keywords: controlling the list width....
  7. Sender: news@ncar.ucar.edu (USENET Maintenance)
  8. Organization: NCAR/UCAR
  9. Date: Sat, 15 Aug 1992 16:05:02 GMT
  10. Lines: 97
  11.  
  12.  
  13. I can't seem to find a way to control the size of the child list in a
  14. SelectionBoxDialog.  The selection box always seems to set the 
  15. width of the list to the length of the longest list item.  
  16.  
  17. If I add the list items *after* managing the SelectionBoxDialog, then I
  18. wind up with a very narrow list window.  (seems to be constrained to the
  19. the width of the managed buttons)
  20.  
  21. I've tried setting the width of the box, both before and after managing,
  22. the width of the list (before and after managing), etc...  
  23.  
  24. Since I'm adding a horizontal scrollbar, I'd ideally like to have the
  25. list be some reasonable width of the widest list item.  
  26.  
  27. What am I missing?
  28.  
  29. Here is the code of my latest attempt:
  30.  
  31.  
  32. /*------------------------------------------------------------------------*/
  33. void UserSelect(u, num)
  34. User    *u[];
  35. int    num;
  36. {
  37.     Widget        w, child, list;
  38.     char        buf[256];
  39.     XmString    xms;
  40.     int        i, j;
  41.     Arg        arg[10];
  42.     void        SelectCB();
  43.  
  44.     (void)sprintf(buf, "Matches found: %d", num);
  45.     xms = XmStringCreateSimple(buf);
  46.  
  47.     i = 0;
  48.     XtSetArg(arg[i], XmNlistLabelString, xms); i++;
  49.     XtSetArg(arg[i], XmNlistSizePolicy, XmCONSTANT); i++;
  50.     XtSetArg(arg[i], XmNwidth, 500); i++;
  51.     w = XmCreateSelectionDialog(mainform, "searchSelect", arg, i);
  52.     XmStringFree(xms);
  53.  
  54.     XtAddCallback(w, XmNokCallback,      SelectCB, (caddr_t) NULL);
  55.     XtAddCallback(w, XmNapplyCallback,   SelectCB, (caddr_t) NULL);
  56.     XtAddCallback(w, XmNcancelCallback,  SelectCB, (caddr_t) NULL);
  57.     XtAddCallback(w, XmNnoMatchCallback, SelectCB, (caddr_t) NULL);
  58.  
  59.     list = XmSelectionBoxGetChild(w, XmDIALOG_LIST);
  60.  
  61.     i = 0;
  62.     XtSetArg(arg[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++;
  63.     XtSetArg(arg[i], XmNvisibleItemCount, 10); i++;
  64.     XtSetArg(arg[i], XmNlistSpacing, 2); i++;
  65.     XtSetArg(arg[i], XmNwidth, 500); i++;
  66.     XtSetValues(list, arg, i);
  67.  
  68.     /* Unmanage some children... */
  69.     child = XmSelectionBoxGetChild(w, XmDIALOG_HELP_BUTTON);
  70.     XtUnmanageChild(child);
  71.  
  72.     child = XmSelectionBoxGetChild(w, XmDIALOG_TEXT);
  73.     XtUnmanageChild(child);
  74.  
  75.     child = XmSelectionBoxGetChild(w, XmDIALOG_SELECTION_LABEL);
  76.     XtUnmanageChild(child);
  77.  
  78.     XtManageChild(w);
  79.  
  80.     j = 1;
  81.     for(i = 0; i < num; i++) {
  82.  
  83.        (void)sprintf(buf, "%d %-8.8s %s %s %s %s", 
  84.              u[i]->sci,
  85.              u[i]->log,
  86.              u[i]->name,
  87.              u[i]->phn,
  88.              u[i]->div,
  89.              u[i]->mail);
  90.  
  91.        xms = XmStringCreateSimple(LCase(buf));
  92.        XmListAddItem(list, xms, j++);
  93.        XmStringFree(xms);
  94.     }
  95.  
  96.  
  97. } /* END UserSelect() */
  98.  
  99.  
  100. Comments appreciated....
  101. -PWM
  102.  
  103. ------------------------------------------------------------------
  104. Peter W. Morreale                  email:  morreale@ncar.ucar.edu
  105. Nat'l Center for Atmos Research    voice:  (303) 497-1293
  106. Scientific Computing Division     
  107. Consulting Office
  108. ------------------------------------------------------------------
  109.