vix@ubvax.UB.Com (Paul Vixie) (03/24/88)
I've encountered a burning need for a scrollable graphics window widget as a child of a VPaned widget. The Viewport widget looks perfect, but I am having trouble understanding one little thing about it: How do I get the windowID of the child window? There are four parts of the Viewport widget -- two (optional) scroll bars, a clip window, and the child window. This child window is where I will presumeably draw my graphics, but I can't see how I can get a hold of the windowID other than by explicitly referencing XtWindow(portwidg.???.child), which seems like an ugly way to pass this information from the widget to the application. Looking into lib/Xaw/Widget.c, I can't even see where it ever associates a window with the "child" structure member. Perhaps I am supposed to create a window and tell the Viewport widget about it when I create it (the widget), but if so I can't see from the source or the docs how to do it. Help? -- Paul Vixie Consultant Work: 408-562-7798 vix@ub.com vix%ubvax@uunet.uu.net Ungermann-Bass Home: 415-647-7023 {amdahl,ptsfa,pyramid,uunet}!ubvax!vix Santa Clara, CA <<I do not speak for Ungermann-Bass>>
kit@athena.mit.edu (Chris D. Peterson) (03/25/88)
>How do I get the windowID of the child window? I have seen this question more than once so I am posting the answer. The viewport was designed to take allow scrolling of a child widget, this child widget can be anything, a label, buttonbox, anything. But it does not exist until you create it, the viewport widget only creates itself and the scrollbars, it does not create the widget that is to be scrolled. If you want to put graphics into a window that is scrolled then you probabally want to instanciate a core widget that is the managed child of the viewport widget, the the window that you will draw into will be the XtWindow(corewidget). Source code to follow. No guarentee on this folks, I have not tried to compile this, but it is the general idea, hope this helps. Chris Peterson Project Athena Systems Development Net: kit@athena.mit.edu Phone: (617) 253 - 1326 USMail: MIT - Room E40-342C 77 Massachusetts Ave. Cambridge, MA 02139 DISCLAIMER: I work for Athena, but I don't talk for them, they can do that for themselves. This is my opinion, so only I have to like it. ------------------------------------------------------------ #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <X11/Shell.h> #include <X11/Viewport.h> #include <X11/Core.h> main(argc,argv) int argc; char ** argv; { Widget top_shell, viewport, graph_widget; Window graph_window; top_shell = XtInitialize("topshell", "XTools", NULL, 0, &argc, argv ); viewport = XtCreateManagedWidget("viewport", viewportWidgetClass, top_shell, NULL, 0); graph_widget = XtCreateManagedWidget("label", widgetClass, viewport, NULL, 0); graph_window = XtWindow(graph_widget); /* Wonderful Graphics stuff. */ }
kochhar@harvard.harvard.EDU (Sandeep Kochhar) (05/07/90)
Is there some way for the program to "scroll" the child of a viewport widget to a particular location (i.e. "fake" the viewport into believing that the user moved the scrollbars to that location) after the widgets are realized. E.g., given coordinates (x, y), I would like the point (x,y) of the child become the left top corner that is visible in the viewport. I tried setting the child's resources XtNx to -x, and XtNy to -y but to no avail.... Help.... Thanks. Sandeep Kochhar (617) 495-3988 mail: kochhar@harvard.harvard.edu Harvard University kochhar@harvard.csnet 33 Oxford st, kochhar@harvard.uucp Cambridge, MA 02138 kochhar@harvard.bitnet Fax: (617) 495-9837