Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!bloom-beacon!NMSU.EDU!pannaiya From: pannaiya@NMSU.EDU Newsgroups: comp.windows.x Subject: Re: Scrolling in Viewport widget. Message-ID: <8907280016.AA19316@NMSU.Edu> Date: 28 Jul 89 00:16:38 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 51 Here are the context diffs that defines a function implementing the software scrolling capability in the R3 Athena Viewport widget. The name I used was XtViewportMoveChild(W, xoff, yoff). I guess it really ought to be XawView... Anyway the functionality is as follows: xoff and yoff are floating point numbers in the range 0.0 and 1.0. The child's new position has to be expressed as the position from the top/left. If the ?off is > 1.0 the child will be moved to the extreme right/bottom. if the ?off is < 0.0 the position on the axis remains unchanged. This has worked for me(so far). If the Xaw gods see any flaw in it please post. PK -----------------------------8<----------------->8--------------------- *** vtemp.c Thu Jul 27 17:54:51 1989 --- Viewport.c Thu Jul 27 17:57:59 1989 *************** *** 383,388 **** --- 383,411 ---- RedrawThumbs(w); } + void XtViewportMoveChild(w,xoff,yoff) + ViewportWidget w; + float xoff,yoff; + { + register Widget child = w->viewport.child; + Position x,y; + + if(xoff > 1.0) /* If the offset is > 1.0 scroll to */ + x = child->core.width; /* extreme right */ + else if (xoff < 0.0) /* if the offset is < 0.0 no movement */ + x = child->core.x; /* in the x direction */ + else + x = child->core.width * xoff; + if(yoff > 1.0) + y = child->core.height; + else if (yoff < 0.0) + y = child->core.y; + else + y = child->core.height * yoff; + + MoveChild(w,-x,-y); + } + static void Resize(widget) Widget widget; {