On 6 May 2002 06:10:57 -0700, Thejaswi wrote
> please help me in changing the colors of lines,arc,,rectangles etc in
> GTK (drawingarea)
> I could get only black_gc(black) and white_gc(white) colors for my
> objects

I assume you know how to draw stuff at all (ExposeEvent). You need
your own GC for this. I'm using a pixmap here, @pixmap, which
is of course of type Gdk::Pixmap, but any Gdk::Drawable should do.
@widget is a Gtk::Widget on which the pixmap will be drawn in the
ExposeEvent handler.


gc=Gdk::GC.new(@pixmap)
color=Gdk::Color.new(r,g,b) # (1)
@widget.get_colormap.alloc_color(color,false,true) # (2)
gc.set_foreground(color)
@pixmap.draw_rectangle(gc,true,0,0,100,100)


Remarks:
(1): Possible values for r,g,b are 0..0xffff
(2): The allocated color will not be writeable (cannot be changed
later) and the best match for the color attempted when too few colors
are available

-- 
Timon Christl <me / christltimon.de>