                                        /*-------------------------------
                                         |    example1.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 = 0, mask = 0;
   XpmAttributes xpmatts;
   static char *filename = "xterm.xpm";
     
					   	    /* Initialize the toolkit */
   toplevel = XtAppInitialize(&context, "Example1", NULL, 0, &argc, argv,
                              NULL, NULL, 0);
   dpy = XtDisplay(toplevel);

/* Xpm lib sets no default values for red_closeness, green_closeness, 
	blue_closeness or closeness. You should at least set the closeness to
	some value */ 	
   xpmatts.closeness = 40000;
   xpmatts.valuemask = XpmSize | XpmCloseness;
   if( (XpmReadFileToPixmap(dpy, DefaultRootWindow(dpy),
			filename, &pix_returned, &mask, &xpmatts)) == XpmSuccess )
	{	
		printf("Pixmap size: %d x %d\n", xpmatts.width, xpmatts.height);
   		pb = XtVaCreateManagedWidget("pb", xmPushButtonWidgetClass, toplevel,
				XmNwidth, 100,
				XmNheight, 100,
				XmNlabelType, XmPIXMAP,
				XmNlabelPixmap, pix_returned,
				NULL);
	}
	else
	{	/* Error  - don't use Pixmap, use default labelString instead  */
   		pb = XtVaCreateManagedWidget("pb", xmPushButtonWidgetClass, toplevel,
				XmNwidth, 100,
				XmNheight, 100,
				NULL);
	}	

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

   XtAppMainLoop(context);

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