Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!gatech!bloom-beacon!corp.sun.COM!aim From: aim@corp.sun.COM (Amy) Newsgroups: comp.windows.x Subject: Re: X window Message-ID: <9011081937.AA17604@slotown.Corp.Sun.COM> Date: 8 Nov 90 19:37:14 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 114 >>From xpert-mailer@expo.lcs.mit.edu Wed Nov 7 19:46:33 1990 >>Organization: New York State Office of General Services, Albany, NY. >>Subject: X window >>Sender: xpert-request@expo.lcs.mit.edu >>To: xpert@expo.lcs.mit.edu >> >> >>Hi, >> I've been working on OPEN LOOK GUI & TOOLKITS in trying to display a tif file >>, bitmap file actually, to be a child widget on the scrolledwindow widget. The >>displaying of image failed for unknown reason in which I suspect if the >>scrolledwindow widget does have the functionality to accommodate image. In >>addition to that, I also used one of the Xlib functions, XPutImage, to be an >>alternative. XPutImage failed to display the image either and caused core dump. >>If anyone does have the experience of dealing image displaying with OPEN LOOK >>GUI & TOOLKITS, I'll appreciate that precious information. Thank you. ` I'm not sure exactly how you are trying to accomplish the above, but, the ScrolledWindow widget in the OpenLook Intrinsics Toolkit is designed to provide scrolling capabilities for a WIDGET created as its child. What you are looking for is scrolling canvas functionality - the way you get that is to create a ScrolledWindow and create a Stub widget as it's child. The Stub which allows you to attach your own expose handler using the resource XtNexpose - and it's in this procedure that you want to do any drawing (hence, this is where you'd load your image). Below is a simple program whichs sets this up for you. Hope this helps. Regards, Amy Moore aim@sun.com #include #include #include #include #include /****************************************************************** * CreateDrawableCanvas: function to create a widget which can * be used for rendering xlib graphics. * This function returns the handle to the created Stub widget. *****************************************************************/ Widget CreateDrawableCanvas(name,parent, width, height) char *name; Widget parent; int width, height; { Widget canvas; Arg arg[4]; int n = 0; XtSetArg(arg[n], XtNwidth, (Dimension) width); n++; XtSetArg(arg[n], XtNheight, (Dimension) height); n++; canvas = XtCreateManagedWidget(name, stubWidgetClass, parent, arg, n); return(canvas); } /************************************************************************* * exposeHandler: routine called on Exposure events on the Canvas(Stub). ************************************************************************/ void exposeHandler(w, xevent, region) Widget w; XEvent *xevent; Region region; { Display *display; GC gc; XGCValues gc_values; Window paint_win; display = XtDisplay(w); paint_win = XtWindow(w); /************************************************* * All xlib drawing routines would go here.... *************************************************/ } /**********************************************************************/ main(argc, argv) int argc; char **argv; { Widget toplevel, scrollwin, canvas; Arg arg[10]; int n = 0; toplevel = OlInitialize(argv[0], "Canvas Test", NULL, 0, &argc, argv); XtSetArg(arg[n], XtNviewHeight, 150); n++; XtSetArg(arg[n], XtNviewWidth, 150); n++; scrollwin = XtCreateManagedWidget("scroller", scrolledWindowWidgetClass, toplevel, arg, n); /* Create canvas (Stub) and set its expose Method */ canvas = CreateDrawableCanvas("canvas", scrollwin, 300, 300); XtSetArg(arg[0], XtNexpose, (void)exposeHandler); XtSetValues(canvas, arg, 1); XtRealizeWidget(toplevel); XtMainLoop(); } /*******************************END EXAMPLE*************************/