Re: Setting Drawing Area Background Color

Fiorillo.Paul wrote:

Hello all,

How do I set the background color of a DrawingArea?

You can use gtk_widget_modify_base() function:
GdkColor bg; = 50000; = 40000; = 30000;
   gtk_widget_modify_base(GTK_WIDGET(drawing_area), GTK_STATE_NORMAL, &bg);
--- gdk-colormaps-and-colors.html gtkwidget.html

The DrawingArea is a
GtkWidget and I'm able to use the default DrawingArea->style->black_gc to
color it black when calling gdk_draw_rectangle() , but I want to change the
color to something else other than the default colors of white_gc or
black_gc.  Any hints on how to do this?

Create new gc, allocate the colour you need, set colour into gc and use this gc in
gdk_draw_rectangle call.
GdkGC gc;
GdkColor *color;

                                                  FALSE, TRUE
   gc = gdk_gc_new(GTK_WIDGET(drawing_area)->window);
   gdk_gc_set_foreground(gc, &color);
/* now you can use gc in drawing */
--- gdk-colormaps-and-colors.html gdk-graphics-contexts.html gtkwidget.html


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