                                        /*-------------------------------
                                         |    example4.c                 |
                                         -------------------------------*/
#include <Xm/PushB.h>
#include <X11/xpm.h>
                                        /*-------------------------------------
                                         |              MAIN                  |
                                         ------------------------------------*/
int main(argc, argv)
  unsigned int argc;
  char **argv;
{
   Widget toplevel, pb;
   XtAppContext context;
   Display *dpy;
   Pixmap pix_returned, mask, button_pixmap;
   XpmAttributes xpmatts;
   XpmColorSymbol transparentColor[1] = {{NULL, "none", 0}};
   static char *filename = "xterm.xpm";
   Pixel fg, bg;
   XGCValues gcvals;
   long gcmask = 0L , dynamic_mask = 0L , dont_care_mask = 0L;
   GC gc;
     
					   	    /* Initialize the toolkit */
   toplevel = XtAppInitialize(&context, "Example4", NULL, 0, &argc, argv,
                              NULL, NULL, 0);
   dpy = XtDisplay(toplevel);

						     /* Create the pushbutton */
   pb = XtVaCreateManagedWidget("pb", xmPushButtonWidgetClass, toplevel,
				NULL);

   XtVaGetValues(pb, XmNbackground, &bg,
						NULL);

   transparentColor[0].pixel = bg;
   xpmatts.closeness = 40000;
   xpmatts.valuemask = XpmColorSymbols | XpmCloseness;
   xpmatts.colorsymbols = transparentColor;
   xpmatts.numsymbols = 1;
   if( XpmReadFileToPixmap(dpy, DefaultRootWindow(dpy), filename,
							&pix_returned, &mask, &xpmatts) == XpmSuccess )
	{
   		XtVaSetValues(pb, XmNlabelPixmap, pix_returned,
				XmNwidth, 100,
				XmNheight, 100,
				XmNlabelType, XmPIXMAP,
				NULL);
   		if(mask)
			XFreePixmap(dpy, mask);
	}
	else/* No pixmaps created */
	{
   		XtVaSetValues(pb, XmNwidth, 100,
						XmNheight, 100,
						NULL);
	}

					      /* Realize the top level widget */
   XtRealizeWidget(toplevel);

   XtAppMainLoop(context);

}/*------------------------------------------------------------ End of MAIN --*/
