Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!dogie.macc.wisc.edu!uwvax!umn-d-ub!umn-cs!kulkarni From: kulkarni@umn-cs.CS.UMN.EDU (Srinivas R. Kulkarni) Newsgroups: comp.windows.x Subject: Automatic Scrolling inside a Athena Viewport Widget(X11R3) Keywords: Xaw,Viewport,X11R3 Message-ID: <17276@umn-cs.CS.UMN.EDU> Date: 25 Nov 89 19:53:41 GMT Distribution: usa Organization: University of Minnesota, Minneapolis Lines: 75 hello, i know this subject was discussed on the net a few months ago but i missed the details then. Sorry about that. I am trying to implement 'automatic scrolling' inside a Athena viewport widget. In particular, whenever the user holds Button1 down and drags the cursor out of the viewport boundaries, i want the canvas underneath to start scrolling and track the cursor. If anybody can mail me code that does this or can point out how i can calculate WHICH_X and WHICH_Y, i will be very thankful. Thankx in advance. Srinivas R. Kulkarni kulkarni@umn-cs.cs.umn.edu Relevant portions of the code follows: ----------------------code------------------------------ #define VIEWPORT_WIDTH 100 #define VIEWPORT_HEIGHT 80 #define CANVAS_WIDTH 1000 #define CANVAS_HEIGHT 800 Dimension viewport_width, viewport_height; Widget horizontal, vertical; Position child_x, child_y; /* this proc is called whenever cursor moves with Button2 down */ Button2Motion_proc(curr_x,curr_y) int curr_x, curr_y; /* { /* get horizontal and vertical scroll bar widget IDs */ horizontal= XtNameToWidget(viewport, "horizontal"); vertical = XtNameToWidget(viewport, "vertical"); /* get viewport width and height */ i=0; XtSetArg(args[i],XtNwidth, &viewport_width); i++; XtSetArg(args[i],XtNheight, &viewport_height); i++; XtGetValues(viewport, args, i); /* get current position of canvas within viewport */ i=0; XtSetArg(args[i],XtNx, &child_x); i++; XtSetArg(args[i],XtNy, &child_y); i++; XtGetValues(canvas, args, i); /* given child_x, child_y and the current position(curr_x, curr_y) of the * cursor, how can i calculate WHICH_X and WHICH_Y ? */ XtCallCallbacks(horizontal,XtNscrollProc, WHICH_X); XtCallCallbacks(vertical, XtNscrollProc, WHICH_Y); }