home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x.motif
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ncar!laplata.scd.ucar.edu!morreale
- From: morreale@laplata.scd.ucar.edu (Peter Morreale)
- Subject: Width of SelectionBoxDialog....
- Message-ID: <1992Aug15.160502.28082@ncar.ucar.edu>
- Keywords: controlling the list width....
- Sender: news@ncar.ucar.edu (USENET Maintenance)
- Organization: NCAR/UCAR
- Date: Sat, 15 Aug 1992 16:05:02 GMT
- Lines: 97
-
-
- I can't seem to find a way to control the size of the child list in a
- SelectionBoxDialog. The selection box always seems to set the
- width of the list to the length of the longest list item.
-
- If I add the list items *after* managing the SelectionBoxDialog, then I
- wind up with a very narrow list window. (seems to be constrained to the
- the width of the managed buttons)
-
- I've tried setting the width of the box, both before and after managing,
- the width of the list (before and after managing), etc...
-
- Since I'm adding a horizontal scrollbar, I'd ideally like to have the
- list be some reasonable width of the widest list item.
-
- What am I missing?
-
- Here is the code of my latest attempt:
-
-
- /*------------------------------------------------------------------------*/
- void UserSelect(u, num)
- User *u[];
- int num;
- {
- Widget w, child, list;
- char buf[256];
- XmString xms;
- int i, j;
- Arg arg[10];
- void SelectCB();
-
- (void)sprintf(buf, "Matches found: %d", num);
- xms = XmStringCreateSimple(buf);
-
- i = 0;
- XtSetArg(arg[i], XmNlistLabelString, xms); i++;
- XtSetArg(arg[i], XmNlistSizePolicy, XmCONSTANT); i++;
- XtSetArg(arg[i], XmNwidth, 500); i++;
- w = XmCreateSelectionDialog(mainform, "searchSelect", arg, i);
- XmStringFree(xms);
-
- XtAddCallback(w, XmNokCallback, SelectCB, (caddr_t) NULL);
- XtAddCallback(w, XmNapplyCallback, SelectCB, (caddr_t) NULL);
- XtAddCallback(w, XmNcancelCallback, SelectCB, (caddr_t) NULL);
- XtAddCallback(w, XmNnoMatchCallback, SelectCB, (caddr_t) NULL);
-
- list = XmSelectionBoxGetChild(w, XmDIALOG_LIST);
-
- i = 0;
- XtSetArg(arg[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++;
- XtSetArg(arg[i], XmNvisibleItemCount, 10); i++;
- XtSetArg(arg[i], XmNlistSpacing, 2); i++;
- XtSetArg(arg[i], XmNwidth, 500); i++;
- XtSetValues(list, arg, i);
-
- /* Unmanage some children... */
- child = XmSelectionBoxGetChild(w, XmDIALOG_HELP_BUTTON);
- XtUnmanageChild(child);
-
- child = XmSelectionBoxGetChild(w, XmDIALOG_TEXT);
- XtUnmanageChild(child);
-
- child = XmSelectionBoxGetChild(w, XmDIALOG_SELECTION_LABEL);
- XtUnmanageChild(child);
-
- XtManageChild(w);
-
- j = 1;
- for(i = 0; i < num; i++) {
-
- (void)sprintf(buf, "%d %-8.8s %s %s %s %s",
- u[i]->sci,
- u[i]->log,
- u[i]->name,
- u[i]->phn,
- u[i]->div,
- u[i]->mail);
-
- xms = XmStringCreateSimple(LCase(buf));
- XmListAddItem(list, xms, j++);
- XmStringFree(xms);
- }
-
-
- } /* END UserSelect() */
-
-
- Comments appreciated....
- -PWM
-
- ------------------------------------------------------------------
- Peter W. Morreale email: morreale@ncar.ucar.edu
- Nat'l Center for Atmos Research voice: (303) 497-1293
- Scientific Computing Division
- Consulting Office
- ------------------------------------------------------------------
-