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

   xpmatts.closeness = 40000;
   xpmatts.valuemask = XpmSize | XpmCloseness;
   if( XpmReadFileToImage(dpy, filename, &image_returned, &mask,
							&xpmatts) == XpmSuccess)
	{
		printf("Installing Image\n");
   		XmInstallImage(image_returned, "xterm");
	}
	
   pb = XtVaCreateManagedWidget("pb", xmPushButtonWidgetClass, toplevel,
				XmNwidth, 100,
				XmNheight, 100,
				/* set the pixmap in the resource file */
				NULL);

/*	Could have used XmGetPixmap() for example 

	buttonPixmap = XmGetPixmap(XtScreen(toplevel), "xterm", NULL, NULL);
	if( buttonPixmap != XmUNSPECIFIED_PIXMAP)
	{
   		pb = XtVaCreateManagedWidget("pb", xmPushButtonWidgetClass, toplevel,
				XmNwidth, 100,
				XmNheight, 100,
				XmNlabelType, XmPIXMAP,
				XmNlabelPixmap, buttonPixmap,
				NULL);
	}
	else 
	{
   		pb = XtVaCreateManagedWidget("pb", xmPushButtonWidgetClass, toplevel,
				XmNwidth, 100,
				XmNheight, 100,
				NULL);
	}
*/
					      /* Realize the top level widget */
   XtRealizeWidget(toplevel);

   XtAppMainLoop(context);

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