Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!trwind!saturn.ind.trw.com!simpson From: simpson@saturn.ind.trw.com (Scott Simpson) Newsgroups: comp.windows.x Subject: How do you pass floats to XSetArg? XtNshown doesn't work Keywords: O'Reilly X Toolkit Manuals, Xtk, Scrollbars, XtNshown Message-ID: <3903@trwind.UUCP> Date: 22 Mar 90 01:16:39 GMT Sender: news@trwind.UUCP Reply-To: simpson@saturn.ind.trw.com (Scott Simpson) Organization: TRW Information Networks Division, Torrance, CA Lines: 33 SunOS 4.0.3c, X11 R4, SPARCstation 1 I am monkeying around with the O'Reilly X Toolkit programming manual trying to learn Xtk. On page 111 of the programming manual, there is some code to add scrollbars to a bitmap widget. The code looks like i = 0; XtSetArg(args[i], XtNorientation, XtorientVertical); i++; XtSetArg(args[i], XtNwidth, window_width); i++; XtSetArg(args[i], XtNheight, 15); i++; XtSetArg(args[i], XtNshown, window_height/pixmap_height_in_pixels); i++; scrollVert = XtCreateManagedWidget("scrollVert", scrollbarWidgetClass, drawingForm, args, i); (The code with X11 R4 actually uses XtNlength.) The type of value for the XtNshown parameter is listed in the reference manual as a float. The above code won't work because dividing two integers gives you an integer. Next I tried XtSetArg(args[i], XtNshown, (float)window_height/pixmap_height_in_pixels); This won't work either because reals get converted to doubles in expressions and doubles are always passed as real parameters in C. Next I tried using the address of a float: float f = (double)window_height/pixmap_height_in_pixels; XtSetArg(args[i], XtNshown, &f); This didn't work either. I also tried the address of a double and this didn't work. How do I set float values to XtSetArg and how do I get XtNshown to work? (BTW, XtNshown sets up the scrollbars so the gray area is initially the right size.) Scott Simpson TRW Information Networks Division simpson@trwind.trw.com