[comp.windows.x] Forced Scrolling in a ViewPort?

bagchi@eecs.umich.edu (Ranjan Bagchi) (04/21/91)

	An application I'm working on has a List widget within a
Viewport widget (both from the Athena set).  What I'm being given
headaches over is making the Viewport scroll so that a certain part of
the List is shown.  I'm having no trouble doing with this manually
with the scrollbar, but I haven't been able to do it automagically.

	What Viewport.c seems to do when the Scrollbar tells it that
it's supposed to scroll is move the ListWidget.  I haven't had any
luck doing this with XtGeometryRequest.
 
	thanks in advance...rj
--
--------------------------------------------------------------------------------
Ranjan Bagchi - asleep......  |    v,i,j,k,l,s,a[99];
bagchi@eecs.umich.edu         |    main()   {
-------------------------------       for(scanf("%d",&s);*a-s;v=a[j*=v]-a[i],k=i<s,j+=(v=j<s&&(!k&&!!printf(2+"\n\n%c"-(!l<<!j)," #Q"[l^v?(l^j)&1:2])&&++l||a[i]<s&&v&&v-i+j&&v+i-j))&&!(l%=s),v||(i==j?a[i+=k]=0:++a[i])>=s*k&&++a[--i]) ;
					}  /* Osovlanski and Nissenbaum */
--------------------------------------------------------------------------------

vojta@powdermilk.berkeley.edu (Paul Vojta) (04/23/91)

In article <BAGCHI.91Apr21011828@snarf.eecs.umich.edu> bagchi@eecs.umich.edu (Ranjan Bagchi) writes:
>
>	An application I'm working on has a List widget within a
>Viewport widget (both from the Athena set).  What I'm being given
>headaches over is making the Viewport scroll so that a certain part of
>the List is shown.  I'm having no trouble doing with this manually
>with the scrollbar, but I haven't been able to do it automagically.
>
>	What Viewport.c seems to do when the Scrollbar tells it that
>it's supposed to scroll is move the ListWidget.  I haven't had any
>luck doing this with XtGeometryRequest.

I have submitted an extensive bug report to the X people concerning
the Xaw Viewport widget.  This includes a patch.  So hopefully sometime
soon (R5?) this will work the way you want it to.  Right now the Viewport
widget doesn't even contain code for moving the child via XtGeometryRequest.

In the meantime, what you can do is:

	1.  Use XtNameToWidget to get the name of the subwidget "clip"

	2.  Use XtGetValues to get the height of the clip widget (and the
	    child widget, in case your program forgets).

	3.  If clip.height < child.height, then you have a vertical
	    scrollbar, which you can find via XtNameToWidget using the
	    name "vertical".

If you know for sure that you have a scrollbar, then steps 1-2 are unnecessary.
Note that XtNameToWidget can return a nonzero value even if there is no
bar--it still might be in the process of being destroyed.

	4.  Use XtCallCallbacks with XtNScrollProc and the relative distance
	    to move.  You can also use XtNThumbProc, and a floating argument
	    in the range from 0 to 1.

Hope this helps.

--Paul Vojta, vojta@math.berkeley.edu