[comp.windows.x.motif] XmScrolledWindow, XmDrawingArea, and XClearWindow

roger@zuken.co.jp (Roger Meunier) (08/24/90)

I am trying to use XmDrawingArea in a XmScrolledWindow to save screen
space.  Most Xlib functions work fine under these circumstances, but
XClearWindow() refuses to clear the entire window.

The program below can be used to verify the problem.  If you repeatedly
"Display" and then scroll the DrawingArea, you would expect the entire
window to be cleared with the same background color, but on my machine
the window is only partially cleared.  It would appear that there is some
clipping being done, but this clipping is erratic.

Any suggestions as to what is going on here and/or how to get around it?

(I am using Motif 1.0 with X11R3 on HP9000 300-series under HP-UX 7.0.)

-------------------------  Cut Here  ------------------------------------

#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/RowColumn.h>
#include <Xm/ScrolledW.h>
#include <Xm/DrawingA.h>
#include <Xm/CascadeB.h>

Display*	display;
Window		window;

main(argc, argv)
char    *argv[];
int     argc;
{
	void	DoQuit();
	void	DoDisplay();
	Widget	toplevel;
	Widget	main_w,menu_bar,quit_b,display_b;
	Widget	scroll_w,draw_w;
	Arg	args[10];
	short	cnt;

	XSetWindowAttributes	attr;

	toplevel = XtInitialize(argv[0], "Swbug", NULL, 0, &argc, argv);
	main_w = XmCreateMainWindow(toplevel,"mainw",NULL,0);
	XtManageChild(main_w);
	menu_bar = XmCreateMenuBar(main_w,"Menu",NULL,0);
	XtManageChild(menu_bar);
	quit_b = XtCreateManagedWidget("Quit",xmCascadeButtonWidgetClass,
			menu_bar,NULL,0);
	XtAddCallback(quit_b,XmNactivateCallback,DoQuit,NULL);
	display_b = XtCreateManagedWidget("Display",xmCascadeButtonWidgetClass,
			menu_bar,NULL,0);
	XtAddCallback(display_b,XmNactivateCallback,DoDisplay,NULL);

	cnt = 0;
	XtSetArg(args[cnt],XmNscrollBarDisplayPolicy,XmAS_NEEDED); cnt++;
	XtSetArg(args[cnt],XmNscrollingPolicy,XmAUTOMATIC); cnt++;
	scroll_w = XtCreateManagedWidget("Scroller",xmScrolledWindowWidgetClass,
			main_w,args,cnt);
	cnt = 0;
	XtSetArg(args[cnt],XmNwidth,300); cnt++;
	XtSetArg(args[cnt],XmNheight,300); cnt++;
	draw_w = XmCreateDrawingArea(scroll_w,"Draw",args,cnt);
	XtManageChild(draw_w);

	XtRealizeWidget(toplevel);
	display = XtDisplay(draw_w);
	window = XtWindow(draw_w);
	attr.background_pixel = 0;
	attr.backing_store = Always;
	XChangeWindowAttributes(display,window,
			CWBackPixel|CWBackingStore, &attr);

	XtMainLoop();
}

void	DoDisplay(w, flag, call_data)
Widget	w;
int	*flag;
XmAnyCallbackStruct	*call_data;
{
	static int	color=0;
	XSetWindowAttributes	attr;

	attr.background_pixel = color;
	XChangeWindowAttributes(display,window,CWBackPixel,&attr);
	XClearWindow(display,window);
	color = (color+1) % 7;
}

void	DoQuit(w, flag, call_data)
Widget	w;
int	*flag;
XmAnyCallbackStruct	*call_data;
{
	exit(0);
}

-------------------------  Cut Here  ------------------------------------
--
Roger Meunier @ Zuken, Inc.  Yokohama, Japan	(roger@zuken.co.jp)

jordan@Morgan.COM (Jordan Hayes) (08/24/90)

Hmmm.  This works for me (Sun4/SunOS/4.0.3/X11R4/Motif 1.0.3),
so you aren't doing anything "wrong" ...

/jordan