[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Text widget: colors
- From: "Michael J. Hammel" <mjhammel graphics-muse org>
- To: gtk-app-devel-list redhat com
- Subject: Re: Text widget: colors
- Date: Fri, 25 Jun 1999 08:30:01 -0600 (MDT)
Thus spoke Gernot Kerschbaumer
> i wonder how to set the background color of a text widget. when i launch
You need to copy the style, then change the base[] color, something like this:
style1 = gtk_widget_get_style( pn->pn_textwidget );
style2 = gtk_style_copy( style1 );
colormap = gdk_window_get_colormap (toplevel->window);
gdk_color.red = (guint16)(item->color[0]*65535.0);
gdk_color.green = (guint16)(item->color[1]*65535.0);
gdk_color.blue = (guint16)(item->color[2]*65535.0);
gdk_color_alloc (colormap, &gdk_color);
/* Set the background of the text widget */
style2->base[GTK_STATE_NORMAL].red = gdk_color.red;
style2->base[GTK_STATE_NORMAL].green = gdk_color.green;
style2->base[GTK_STATE_NORMAL].blue = gdk_color.blue;
/* Set th background of the text to the same color as the widget */
style2->bg[GTK_STATE_NORMAL].red = gdk_color.red;
style2->bg[GTK_STATE_NORMAL].green = gdk_color.green;
style2->bg[GTK_STATE_NORMAL].blue = gdk_color.blue;
gtk_widget_set_style(pn->pn_textwidget, style2);
gdk_window_set_background(pn->pn_scrollwidget->window, &gdk_color);
This code is taken from XNotesPlus, where I set the background of different
notes based on which project the notes belong to. Note that you have to
set both the text widget background (with base[]) and the text background
(bg[]) or you might not get what you were expecting.
This doesn't work well in Gtk 1.0 because the base[] color setting is not
used, but it works just fine in 1.2.
--
Michael J. Hammel |
The Graphics Muse | Someday we'll look back on this and plow into a
mjhammel@graphics-muse.org | parked car. -- Dilbert
http://www.graphics-muse.org
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]