[ Usenet FAQs | Web FAQs | Documents | RFC Index ]
    Search the FAQ Archives

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page

Top Document: Motif FAQ (Part 5 of 9)
Previous Document: 152) How can I have a vertical label?
Next Document: 154) Why doesn't the XmLabel widget obey the XmNwith and XmNheight


153) How can I have a Pixmap in a Label?



Answer: Bob Hays (bobhays@spss.com) wrote:

Pixmap px_disarm, px_disarm_insens;

Widget Label1;
Pixel   foreground, background;
Arg     args[4];
Arg     arg[] = {
        { XmNforeground, &foreground },
        { XmNbackground, &background }
};

Label1 = XmCreateLabel ( Shell1, "Label1",
                               (Arg *) NULL, (Cardinal) 0 );
XtGetValues ( Label1, arg, XtNumber ( arg ) );
px_disarm =
XCreatePixmapFromBitmapData(display,
                        DefaultRootWindow(display),
                        mtn_bits, mtn_width, mtn_height,
                        foreground,
                        background,
                        DefaultDepth(display,DefaultScreen(display)));
px_disarm_insens =
XCreatePixmapFromBitmapData(display,
                        DefaultRootWindow(display),
                        mtn_ins_bits, mtn_ins_width, mtn_ins_height,
                        foreground,
                        background,
                        DefaultDepth(display,DefaultScreen(display)));

n = 0;
XtSetArg(args[n], XmNlabelType, XmPIXMAP);  n++;
XtSetArg(args[n], XmNlabelPixmap, px_disarm);  n++;
XtSetArg(args[n], XmNlabelInsensitivePixmap, px_disarm_insens ); n++;
XtSetValues ( Label1, args, n );
XtManageChild(Label1);

That will cause the foreground and background of your pixmap to be inherited
from the one that would be used by OSF/Motif when the label is displayed.  The
advantage is that this will utilize any resource values the user may have
requested without looking explicitly into the resource database.  And, you
will have a pixmap handy if the application insensitizes the label (without an
XmNlabelInsensitivePixmap your label will go empty if made insensitive).

[Bob's original code was for a PushButton. Just change all Label to PushButton
for them.]



Top Document: Motif FAQ (Part 5 of 9)
Previous Document: 152) How can I have a vertical label?
Next Document: 154) Why doesn't the XmLabel widget obey the XmNwith and XmNheight

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page


[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
kenton@rahul.net (Ken Lee)

Last Update October 22 2009 @ 05:27 AM

Some parts © 2009 Advameg, Inc.