Re: how to set a button's background?



how to set a button's background?Hello,

I'm using this method to paint the background of a CList cell in a different
color, maybe you can apply that to your case :

 GdkColor   xColor;
 GdkColormap     *pxColorMap;

 /* Get the colormap from the GtkCList object */
 pxColorMap = gtk_widget_get_colormap(GTK_WIDGET(lstGtkCList_E));

 /* Create a new color : Red-Orange-ish */
 xColor.red  = 61696;
 xColor.green = 52736;
 xColor.blue  = 45312;

 /* Alloc the new color to the colormap */
 gdk_colormap_alloc_color(pxColorMap, &xColor, FALSE, TRUE);

 /* Set back the colormap to my GtkCList object */
 gtk_widget_set_colormap(GTK_WIDGET(lstGtkCList_E), pxColorMap);

 /* Get a copy of a default style and customize it */
 pxUndetStyle = gtk_style_copy(gtk_widget_get_default_style());
 pxUndetStyle->base[GTK_STATE_NORMAL] = xColor;
 pxUndetStyle->base[GTK_STATE_ACTIVE] = xColor;
 pxUndetStyle->base[GTK_STATE_PRELIGHT] = xColor;
 pxUndetStyle->base[GTK_STATE_SELECTED] = xColor;
 pxUndetStyle->base[GTK_STATE_INSENSITIVE] = xColor;

 gtk_style_ref(pxUndetStyle);

 /* Apply this style to the cell */
 gtk_clist_set_cell_style(lstGtkCList_E, i, j, pxUndetStyle);

 /* But you can use for your case :
gtk_widget_set_style(GTK_WIDGET(Your_GtkButton_Object), pxCustom_Style); */



Best regards,
---
Jean-Christophe Berthon

Cap Gemini -- Ernst & Young
France
Skill IS -- Image Quality
Email: Jean-Christophe Berthon cgey com
Tel: (+33) 561 31 6671


----- Original Message -----
From: ¶À¼y Kason Huang
To: gtk-list gnome org
Sent: Monday, January 21, 2002 6:44 AM
Subject: how to set a button's background?


hello,hi:
        could anyone tell me how to set a button's background?
when the button get focus(with updown key in the keyboard),how to let the
button's background being red or other color?
_______________________________________________ gtk-list mailing list
gtk-list gnome org http://mail.gnome.org/mailman/listinfo/gtk-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]