[comp.windows.x] Drawing to Viewport Widgets

bmcprog@MYCROFT.MAYO.EDU (03/07/90)

Could anyone spare some insight into viewport widgets (the name of some
example source
code would do I have the release and contrib tapes)? I am trying to use a viewport
widget to display some 8 bit grayscale images.

I create a viewport widget by:

	m_draw  = XtCreateManagedWidget ("Product", viewportWidgetClass, m_main,
					 NULL, ZERO);

with the following resources:

	"*Viewport*borderWidth:		2",
	"*Viewport*allowHoriz:		True",
	"*Viewport*allowVert:		True",
	"*Viewport*forceBars:		True",
	"*Viewport*width:		512",
	"*Viewport*height:		512",
	"*Viewport*useBottom:		True",
	"*Viewport*useRight:		True",

What I wish to do is to have a 1024 x 1024 drawing region, a grayscale colormap and
use XPutImage to do the drawing. So I tried:

	num_args = 0;
	XtSetArg (args[num_args], XtNwidth, 1024);
	num_args++;
	XtSetArg (args[num_args], XtNheight, 1024);
	num_args++;
	m_draw_surface = XtCreateManagedWidget ("output", labelWidgetClass, m_draw,
						 args, num_args);

to set my drawing region and:

	XSetStandardColormap (XtDisplay(m_draw_surface), 
			      DefaultRootWindow (XtDisplay(parent)),
			      cmap, XA_RGB_GRAY_MAP);

to set the colormap.

When I test the code thus far, I do not get the results I expected (ie two
sliders on the right and bottom and a blank screen). Rather I get the
viewport widget
no sliders and a label widget with the label "output" in the upper left (the
text is what I expected, the rest is not). So:

1) What is the best way to do what I want?
2) What's the best way to draw images into a viewport?

Many Thanks,

--Bruce
----------------------------------------------------
Bruce M. Cameron                    bmc@bru.mayo.edu
Medical Sciences 1-14               (507) 284-3288
Mayo Foundation                     WD9CKW
Rochester, MN 55905
----------------------------------------------------