Re: GdkGC question




G'Day !

Harlow has some really exellent examples of how to do this in his book.  You can download example code from the attached web site.  Look for the example system monitor.

http://www.newriders.com/books/title.cfm?isbn=0735700214

cheers,
Jim Parker

Sailboat racing is not a matter of life and death ....  It is far more important than that !!!



Tom Aziz <tomazi caramail com>
Sent by: gtk-app-devel-list-admin gnome org

04/21/01 10:18 AM

       
        To:        gtk-app-devel-list gnome org
        cc:        
        Subject:        GdkGC question


I don't succed to draw lines of different colors (and
style).
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_connect(GTK_OBJECT(MainDrawingArea),
"configure_event",
GTK_SIGNAL_FUNC(drawing_init), NULL);
--------------

--- drawing_init ---
void
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
Tomazi

______________________________________________________
Boîte aux lettres - Caramail - http://www.caramail.com





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