Hello,
I am writing an application that creates an image characterized by several
different colors. For this reason, I need to change the drawing (i.e.,
the foreground) color of a GtkDrawingArea many times during the life of
the application. I have found a way to do it but don't think it's
particularly clean. I have not had much luck finding documentation that
specifies a better way (that has not been deprecated). Do any of the
experts have any suggestions?
The structure of my current code follows:
GdkColor mycolor = { 0, 0xaa, 0xaa, 0xaa };
GdkColormap *mycolormap;
GdkGCValues mygcvalues;
GdkColor originalcolor;
/* Get the widget's graphic context properties and store the original
* foreground color.
*/
gdk_gc_get_values( widget->style->fg_gc[GTK_WIDGET_STATE( widget )],
&mygcvalues
);
originalcolor = mygcvalues.foreground;
/* Get the widget's graphic context properties. */
mycolormap = gtk_widget_get_colormap( widget );
/* Allocate the color we wish to use. */
gdk_colormap_alloc_color( mycolormap, &mycolor, TRUE, TRUE );
/* Set the foreground color to the new color. */
/* Why doesn't this work?
gtk_widget_modify_fg( widget, GTK_STATE_NORMAL, &mycolor );
*/
gdk_gc_set_foreground( widget->style->fg_gc[GTK_WIDGET_STATE( widget )],
&mycolor
);
/* Draw shapes in new foreground color */
. . .
/* Reset the foreground color to the new color. */
gdk_gc_set_foreground( widget->style->fg_gc[GTK_WIDGET_STATE( widget )],
&originalcolor
);
. . .
Also, I tried to use gtk_widget_modify_fg (above), but it didn't work. Has
anyone else had any luck? If so, would you attach a small piece of code?
Thanks!
Brad
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list