Hi,
On Sun, 2002-07-07 at 13:50, Jan Luehr wrote:
> Greetings,
>
> I'm new to gtk, so please don't blame me.
>
> I'm trying to paint a green square in an offscreen pixmap. My current
> approach is:
>
> GdkColor green; //Formulas
> GdkGC gc;
> GtkWidget *widget;
> Pixmap *pixmap;
> GdkColormap *map;
> GdkColor color_green;
>
> map = gdk_colormap_get_system(); // Get the System's colormap
> gdk_color_parse("green",&color_green); //Get the color
> gdk_colormap_alloc_color(map,&color_green); //Allocate it
> gdk_draw_rectangle(pixmap,widget -> style -> black_gc,TRUE,30,30,20,20);
> //Works fine.
> gdk_gc_copy(&gc, widget -> style -> white_gc); //Causes a segmentation fault;
> get the new context
In GTK 2.0, GC are GObjects and as such cannot be allocated in the
stack. You need to create one using gdk_gc_new() or
gdk_gc_new_with_values(). Of course the var will be of type GdkGC *.
When you're finished with it don't forget to unref it with
g_object_unref().
HTH,
Gustavo
>
> gdk_gc_set_foreground(&gc, &color_green); //Set the color
>
>
> gdk_draw_rectangle(pixmap,&gc,TRUE,1,1,20,20); //Draw the rectangle
>
> What's wrong here?
>
> Keep smiling
> yanosz
>
> --
> GnuPG Key available at http://www.jluehr.de.vu/public_key.asc
> _______________________________________________
> gtk-list mailing list
> [EMAIL PROTECTED]
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
>
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list