[comp.windows.x] Xaw Viewport Question, Help!

converse@expo.lcs.mit.EDU (Donna Converse) (06/14/91)

> I have a program which brings up a viewport widget.  The viewport's
> child is a list widget with a bunch of entries, forced vertically with
> a vertical scrollbar.  This all works nicely, with all the list elements
> coming up and selectable. 
> 
> What I would like to do is make the viewport display only a fixed number
> of the list elements (say three, even if I supply 10 list elements) and
> have the scrollbar scroll me through the list (say, three at a time).
> 
> I am assuming that the Xaw set will do all this for me "automatically"
> assuming I set up the resources properly.  Everything works so far except
> for giving me the small item "window" into the list.  I can't seem to 
> set resources properly to make this happen.
> 
> Documentation on the viewport says that it consists of a frame window,
> an inner window (in which the child is displayed) and 1 or 2 scrollbars.
> Supposedly the child will be clipped automatically if larger than the
> inner window.  Given this, the most logical approach would be to set
> a height resource for the viewport widget, which should then clip and
> scroll the child appropriately.

Yes, I believe this is the correct way to get the effect that you want.
You could set the height at the time that the Viewport is created, in the
application's call to XtCreateManagedWidget, or you could set it in an
application defaults file which accompanies your source code.  The latter
method makes it possible for end-users to adjust the default height, the
former does not.

> My attempts to do this have failed.  I have tried using XtSetArg/XtSetValues
> on the viewport widget (XtNheight). 

Perhaps the parent of the Viewport does not allow the Viewport child to
change size after it has been created.  Look at the constraint resources
of the parent of the Viewport, if it is a constraint widget.

> I have also tried modifying the
> resources file I am using to develop the application.  No luck.

I don't know why this failed, unless the resource was not correctly specified.


> [..aside:  it appears that one can use the resources "textfile" and xrdb
> only if the /usr/lib/X11/*.h files set up a correspondence between a text 
> string and a symbolic constant - e.g. the viewport's include file has
> ' #define XtNforceBars "forceBars" '..  otherwise you have to set the 
> resource using C calls.  Is that correct?]..

I'm not sure I understand you; you might not be conceptualizing the resource
specification correctly.  Use XtNforcebars with arg lists in the application
source code.  Use *Viewport.forcebars: True in your resource file.