[comp.windows.x] How do you pass floats to XSetArg? XtNshown doesn't work

simpson@saturn.ind.trw.com (Scott Simpson) (03/22/90)

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

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (03/23/90)

>  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.)

Take a look at section: 3.5.5 in the "Athena Widget Set - C Language Interface"
document on your X11R4 tape, or look in `examples/Xaw/xscroll.c'.


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213