Hi,
I'm trying to work out how to do coloured drawing stuff. I've read the FAQ,
the tute, the reference, archives, other sources, and this colour
kerfuffle's giving me the shiz.
As a "trivial" exercise, I'm simply trying to open up a GtkWindow and smack
a dirty big blue rectangle in it. It won't work:
#include <gtk/gtk.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
GtkWidget *darea1, *mainWindow;
GdkGC *gc;
GdkColor *blue;
// init
gtk_init(&argc, &argv);
// main window
mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(mainWindow);
// drawing area
darea1 = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(mainWindow), darea1);
gtk_widget_realize(darea1);
// make color
blue = malloc(sizeof(GdkColor));
blue->pixel = 255;
blue->red = 0;
blue->green = 0;
blue->blue = 65535;
gdk_colormap_alloc_color(gdk_colormap_get_system(), blue, TRUE, TRUE);
// make gc and set fgcolor
gc = gdk_gc_new(darea1->window);
gdk_gc_set_foreground(gc, blue);
// make it happen
gdk_draw_rectangle (darea1->window,
gc,
TRUE,
0, 0,
darea1->allocation.width,
darea1->allocation.height);
gtk_widget_show(darea1);
gtk_main();
return 0;
}
Can someone please tell me what's wrong?
Also, is there any point in explicitly setting the `pixel' field of a
GdkColor? FAQ 7.2 does it, but I thought it was the allocating function's
job.
TIA.
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list