Changing background color of check / radio buttons
- From: Peter Krueger <pkrueger appss de>
- To: gtk-list gnome org
- Subject: Changing background color of check / radio buttons
- Date: Wed, 20 Aug 2003 17:24:16 +0200 (MEST)
Hello,
I want to change the background color of some check and radio buttons.
My example program works fine for GTK_STATE_PRELIGHT and draws a green
background rectangle. But in GTK_STATE_NORMAL most of the widget is still
drawn with the default background color. I would like to get a red
rectangle like the green one in PRELIGHT.
I'm wondering why the background for these states behaves so different. I
can get this filled background color in state NORMAL too (like
the toggle button has) when I put my check and radio buttons inside event
boxes and set those background color.
But since it works in PRELIGHT, I guess that this should be somehow
possible without the help of additional widgets. Does anybody know how?
Regards...Peter
#include <gtk/gtk.h>
int main(int argc, char **argv)
{
GtkWidget *pWindow, *pVBox, *pToggle, *pCheck, *pRadio;
GtkRcStyle *pRcStyle;
gtk_init(&argc, &argv);
/* create main window and a vbox inside it */
pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(pWindow), 5);
pVBox = gtk_vbox_new(0, 5);
gtk_container_add(GTK_CONTAINER(pWindow), pVBox);
/* create some buttons */
pToggle = gtk_toggle_button_new_with_label("Togglebutton");
pCheck = gtk_check_button_new_with_label ("Checkbutton");
pRadio = gtk_radio_button_new_with_label(0, "Radiobutton");
gtk_container_add(GTK_CONTAINER(pVBox), pToggle);
gtk_container_add(GTK_CONTAINER(pVBox), pCheck);
gtk_container_add(GTK_CONTAINER(pVBox), pRadio);
/* modify style of buttons */
pRcStyle = gtk_rc_style_new();
gdk_color_parse("red", &pRcStyle->bg[GTK_STATE_NORMAL]);
pRcStyle->color_flags[GTK_STATE_NORMAL] = GTK_RC_BG;
gdk_color_parse("green", &pRcStyle->bg[GTK_STATE_PRELIGHT]);
pRcStyle->color_flags[GTK_STATE_PRELIGHT] = GTK_RC_BG;
gtk_widget_modify_style(pToggle, pRcStyle);
gtk_widget_modify_style(pCheck, pRcStyle);
gtk_widget_modify_style(pRadio, pRcStyle);
gtk_widget_show_all(pWindow);
gtk_main();
return 0;
}
--
====================================================================
Peter Krüger
applied software solutions (appss) GmbH
Sandtorstr. 23
D-39106 Magdeburg
Germany
Phone: +49-(0)391-54486-19388
Fax: +49-(0)391-54486-19222
email: krueger appss de
URL: http://www.appss.de
Managing Director: Uwe Hess, Dietmar Schäfer
Register: HRB12386, AG Mageburg
"Virtual business becomes reality!"
This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
====================================================================
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]