[comp.windows.x.motif] "pixmaps" as labels

argv@Eng.Sun.COM (Dan Heller) (06/29/90)

In an attempt to feed the pushbutton widget a pixmap, I find that
the pixmap you feed it must be the same depth as the screen you're
using.  Therefore, you cannot feed a "bitmap" to a label or pushbutton
widget on a color screen.

Upon investigation of the source, I see that the label widget does
get the dimensions (w, h, depth) of the pixmap used, but does not
consider the depth before calling XCopyArea.  It should use XCopyPlane
if the depth == 1.  As a result, I have done the following:

	Pixmap pixmap, pixmap2;
	int d, foo, w, h;

	if (XReadBitmapFile(dpy, DefaultRootWindow(dpy),
	    filename, &w, &h, &pixmap, &foo, &foo) != BitmapSuccess)
	    error("can't load %s\n", filename), exit(1);
	if ((d = DefaultDepth(dpy, DefaultScreen(dpy))) != 1) {
	    pixmap2 = XCreatePixmap(dpy, DefaultRootWindow(dpy), w, h, d);
	    XCopyPlane(dpy, pixmap, pixmap2, gc, 0,0, w,h, 0,0, 1L);
	    XFreePixmap(dpy, pixmap);
	    pixmap = pixmap2;
	}
	button = WidgetCreate("button", xmPushButtonGadgetClass, bboard,
	    XmNlabelType,   XmPIXMAP,
	    XmNlabelPixmap, pixmap,
	    NULL);

[ Note: I use my old R3 WidgetCreate routines until Motif 1.1 comes out
  that complies with R4. ]


The question is, has the OSF folks fixed this for 1.1?

-- 
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.