refresh pushbutton with a pixmap on it

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

Submitted by orank on Mon, 01/14/2002 - 15:21. Developers
Hi ,
One way I know is this
You can create 2 pixmaps one that looks like the button is not pressed and one that looks like the button is pressed. When needed change the current pixmap to be one of the 2 pixmap?s.
Good luck

Hi I have a pushbutton with a XmNlableType == XmPIXMAP.
I change the pixmap on the button using the following function.
The problem is that the pixmaps are not changed (refreshed) until I push the pushbutton then for some reason it gets the needed event and gets repainted with the new pixmap.

How can I make the button refresh after I changed the pixmap for it.

I already tried to use XmUpdateDisplay(Widg); after the set_color_icon_pixmap is finished. It did not help.

I hope some one knows how to over come this . .

Thank you

Here is the PixMap function I use

static int set_color_icon_pixmap(button, filename)
Widget button;
char *filename;
Pixmap pix, old_pix, arm_pix, old_arm_pix, inactive_pix, old_inactive_pix;
Arg wargs[10];
int n;
int pix_width, pix_height, err_code=0;
Boolean recompute_size;
Dimension button_width, button_height;
unsigned char label_type;

/* retrieve the old pixpams to destroy */
n = 0;
XtSetArg(wargs[n], XmNlabelType, &label_type); n++;
XtSetArg(wargs[n], XmNlabelPixmap, &old_pix); n++;
XtGetValues(button, wargs, n);

pix = ii_motif_util_create_color_icon(XtParent(button), filename,
&pix_width, &pix_height, &err_code);

n = 0;
XtSetArg(wargs[n], XmNrecomputeSize, &recompute_size); n++;
XtSetArg(wargs[n], XmNwidth, &button_width); n++;
XtSetArg(wargs[n], XmNheight, &button_height); n++;
XtGetValues(button, wargs, n);

if ((recompute_size == FALSE) &&
pix != NULL &&
(button_height < pix_height ||
button_width < pix_width)) {
XFreePixmap(XtDisplay(XtParent(button)), pix);
pix = NULL;
err_code = PIXMAP_TOO_BIG;
return FALSE;
* Set pixmap resources.

n = 0;

if (pix == NULL) {

pix = XCreatePixmap(ii_motif_display(),
ii_motif_get_default_root_window(ii_motif_display()), 1, 1,

#if 0
XFillRectangle(ii_motif_display(), pix,
i_x11_backgroundGC, 0, 0, 1, 1);

XtSetArg(wargs[n], XmNlabelType, XmPIXMAP); n++;
XtSetArg(wargs[n], XmNlabelPixmap, pix); n++;
XtSetValues(button, wargs, n);

if (label_type == XmPIXMAP && old_pix &&
XFreePixmap(XtDisplay(XtParent(button)), old_pix);

return (err_code == 0);

Tue, 07/03/2012 - 15:14
2 posts / 0 new
Last post
Tue, 07/03/2012 - 15:15