you can follow this basic algorithm, (there are many ways to effect this, this is just one that works and is, hopefully, descriptive): // set up colors and some GCs GdkColor red, black; GdkGC *gc, *inverse_gc; gc = gdk_gc_new(window); // regular GC for the window inverse_gc = gdk_gc_new(window); // inverse GC // init the various aspects/qualities of the GCs red.red = 65535; red.green = 0; red.blue = 0; // red black.red = 0; black.green = 0; black.blue = 0; // black gdk_gc_set_rgb_fg_color(gc, &red); gdk_gc_set_rgb_bg_color(gc, &black); gdk_gc_set_rgb_fg_color(inverse_gc, &black); gdk_gc_set_rgb_bg_color(inverse_gc, &red); // plus any other qualities of the line you would like to set, like dashes, thickness, etc. // see gdk_gc_set_function(gc, FUNCTION) in the documentation // then in your configure routine for your drawing area: // make the pixmap you will be drawing on GdkPixmap *pixmap = gdk_pixmap_new(da->window, da->allocation.width, da->allocation.height, -1); // paint the background using the background color (foreground color of our inverse GC) gdk_draw_rectangle(pixmap, inverse_gc, TRUE, 0, 0, da->allocation.width, da->allocation.height); // draw a line from corner to corner, twice gdk_draw_line(pixmap, gc, 0, 0, da->allocation.width, da->allocation.height); gdk_draw_line(pixmap, gc, 0, da->allocation.height, da->allocation.width, 0); // force the expose event for the drawing area to be called gtk_widget_queue_draw_area(da, 0, 0, da->allocation.width, da->allocation.height); // render the pixmap to the screen in your expose routine for the drawing area: gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], pixmap, event->area.x, event->area.y event->area.x, event->area.y event->area.width, event->area.height); richard On Mar 11, 2006, at 5:29 PM, Leo - wrote: I think I can grasp the GC idea; it's just a way to reduce the number of parameters sent to certain functions, but where do I "get" the colors from? |
_______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list