[comp.windows.x.motif] Pixmap conversion

oju@canopus.hut.fi (Olli Juhola) (07/30/90)

I need to create an array of pixmaps from files that are
defined in the .Xdefaults file of the user. I'm using
XtGetApplicationResources as I don't want to store the
pixmaps in widgets. For some reason I cannot get the conversion
from file name to Pixmap to work. 

Here is the code I'm using:

struct {
	Pixmap pixmap;
	char   *name;
} Icon, *IconPtr;

create_new_icon(w, icon, name)
Widget w;
Icon   *icon;
char   *name;
{
	XtResource resources[1];
	
	resources->resource_name = name;
	resources->resource_class = "Icon";
	resources->resource_type = XmRPixmap;
	resources->resource_size = sizeof(Pixmap);
	resources->resource_offset = XtOffset(IconPtr, pixmap);
	resources->default_type = XmRString;
	resources->default_addr = "50_foreground";

	XtGetApplicationResources(w, icon, resources, XtNumber(resources),
				  NULL, 0);

	icon->name = name;
}

When calling the above function with:

Widget top_level;
Icon new_icon;

top_level = XtInitialize("my_app", "My_app", NULL, 0, &argc, argv);

create_new_icon(top_level, &new_icon, "icon1");

and using the .Xdefaults entry:
My_app*icon1:    /usr/include/X11/bitmaps/flagup
(or any bitmap file...)
I don't seem to get any valid Pixmap. Even when I try it without a .Xdefaults
entry I don't seem to get the 50_foreground Pixmap.

I've tried to use the new_icon.pixmap with XGetGeometry and as a Pixmap
to XmCreateLabel. The former results in a X Protocol error and the
latter in a blank label.

	Karl

--
           Olli Juhola                Spare disk space -- avoid flaming
       oju@niksula.hut.fi                    Spare me -- go away