GdkGC question

I don't succed to draw lines of different colors (and
I need some help but it seems that nobody uses GDK drawing
features, and that there is no tutorial about this. It's
very sad because I want to use GDK for this, but if I can't
I will have to use another lib or another programming
langage with more documentation.

Maybe the problem is that I didn't really understand what a
GC is, and how it must be used.

Here is what I do :

--- global variables ---
static GdkGC *lines1_GC = NULL;
static GdkColor *color1 = NULL;

static GdkGC *lines2_GC = NULL;
static GdkColor *color2 = NULL;

--- main() ---
 GTK_SIGNAL_FUNC(drawing_init), NULL);

--- drawing_init ---
drawing_init(GtkWidget *widget, gpointer data)
 lines1_GC = gdk_gc_new(widget->window);
 lines2_GC = gdk_gc_new(widget->window);

 color1 = g_new(GdkColor, 1);
 color1->red = (gushort)(65535 * 1.00);
 color1->green = (gushort)(65535 * 0.50);
 color1->blue = (gushort)(65535 * 0.50);

 gdk_gc_set_foreground(lines1_GC, color1);
/* same with color2 and lines2 */

when an event (click) occurs, I use this function to draw
the line :
--- gdk_draw_line ---
 gdk_draw_line(pixmap, lines1_GC,
 x1, y1,
 x2, y2);
/* or lines2 */

The problem is : no matter what color I choose in
drawing_init, I get only the black
color. All of the code is in the same file.

How to draw lines of different colors ?
How to draw lines of different styles ?

Thanks for any help

Boîte aux lettres - Caramail -

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