Re: GtkStyle in CList...
- From: Angelo Cano <acano systec com>
- To: "James K. Wiggs" <wiggs novum-millennium org>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GtkStyle in CList...
- Date: Thu, 12 Oct 2000 02:44:29 -0500
On Tue, Oct 10, 2000 at 11:35:48AM -0700, James K. Wiggs wrote:
Folks,
I'm trying to change the background colors in a CList widget, and
I don't seem to be having a lot of luck with it. I want to color the
text white by default, and alternating rows in the CList either black
or 25% grey. Certain cells may have the text colored bright green,
bright red, gold, or a light purple. I have the following code that
is called during the application's initialization phase to create a
global array of styles for this purpose:
gint Create_CList_Styles()
{
gint n;
GtkStyle *style;
GdkColormap *cmap;
GdkColor black,darkgrey,lightgrey,white;
GdkColor brightred,brightgreen;
GdkColor darkred,darkgreen;
GdkColor purple,gold;
cmap = gdk_colormap_get_system();
gdk_color_parse( "ffffff", &white);
try:
gdk_color_parse( "white", &white );
gdk_colormap_alloc_color( cmap, &white, FALSE, TRUE );
gdk_color_parse( "000000", &black );
gdk_color_parse( "black", &black );
gdk_colormap_alloc_color( cmap, &black, FALSE, TRUE );
gdk_color_parse( "404040", &darkgrey );
gdk_color_parse( "darkgrey", &darkgrey );
gdk_colormap_alloc_color( cmap, &darkgrey, FALSE, TRUE );
...
/* The default (black) display style. */
MMStyle[BLACK_WHITE_DISPLAY_STYLE] =
gtk_style_copy( gtk_widget_get_default_style() );
(MMStyle[BLACK_WHITE_DISPLAY_STYLE])->bg[GTK_STATE_NORMAL] = black;
(MMStyle[BLACK_WHITE_DISPLAY_STYLE])->base[GTK_STATE_NORMAL] = black;
Sometimes when you want to change a widget's "background" color you need
to use "base" instead.
(MMStyle[BLACK_WHITE_DISPLAY_STYLE])->fg[GTK_STATE_NORMAL] = white;
(MMStyle[BLACK_WHITE_DISPLAY_STYLE])->text[GTK_STATE_NORMAL] = white;
/* The default (grey) display style. */
MMStyle[GREY_WHITE_DISPLAY_STYLE] =
gtk_style_copy( gtk_widget_get_default_style() );
(MMStyle[GREY_WHITE_DISPLAY_STYLE])->bg[GTK_STATE_NORMAL] = darkgrey;
(MMStyle[GREY_WHITE_DISPLAY_STYLE])->fg[GTK_STATE_NORMAL] = white;
(MMStyle[GREY_WHITE_DISPLAY_STYLE])->text[GTK_STATE_NORMAL] = white;
...
return(0);
}
So that's how I'm creating the styles. Then the styles get used
in this fashion (at this point in the code, the CList has already
been created and filled in):
for(i=0; i<MM->nsymbols; i++) {
if( i%2 ) {
gtk_clist_set_row_style( clist, i,
MMStyle[GREY_WHITE_DISPLAY_STYLE] );
}
else {
gtk_clist_set_row_style( clist, i,
MMStyle[BLACK_WHITE_DISPLAY_STYLE] );
}
for(j=0; j<MM->nfields; j++) {
/* Here is where we do the text coloring stuff. */
if( MM->field[j] == CHANGE_FIELD ) {
if( i%2 ) {
gtk_clist_set_cell_style( clist, i, j,
MMStyle[BLACK_GREEN_DISPLAY_STYLE] );
}
else {
gtk_clist_set_cell_style( clist, i, j,
MMStyle[GREY_GREEN_DISPLAY_STYLE] );
}
}
else if( MM->field[j] == SYMBOL_FIELD ) {
if( i%2 ) {
gtk_clist_set_cell_style( clist, i, j,
MMStyle[BLACK_PURPLE_DISPLAY_STYLE] );
}
else {
gtk_clist_set_cell_style( clist, i, j,
MMStyle[GREY_PURPLE_DISPLAY_STYLE] );
}
}
}
}
The code *does* have some effect. It appears to change the text
color, but not to the color it *should* be changed to. Instead of
black, it is a dark blue. The background remains white. So, any
suggestions as to what's wrong here?
thanks,
Jim Wiggs
wiggs wiggs net
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]