Re: [gtk-list] Drawing area color weirdness help?
- From: Jan Kellmer <jkellmer dialup nacamar de>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Drawing area color weirdness help?
- Date: Sun, 10 Jan 1999 12:37:07 +0100
Andrew P. Lentvorski wrote:
> Okay, I created a set of widgets and packed everything together.
> One of the widgets is a GtlDrawingArea. Fine. I attach the expose
> event to the callback function at the bottom of this message.
> Everything comes up fine. It even creates a nice red rectangle.
> Then I resize the window ... urp ... the color in the GtlDrawingArea
> changes to a random color every time I resize it. Yellow .. Green ...
> Blue ... you name it. No particular rhyme or reason.
>
> Why?
>
> I'm assuming that I'm doing something wrong, but I have no idea what.
>
> Also, how do you create a GdkColor from an RGB value?
>
> Thanks,
> Andy Lentvorski
>
> Expose callback function starts here:
> static gint
> wave_expose_event(GtkWidget *widget, GdkEventExpose *event)
> {
> gint width,height;
> GdkColor foreground;
> GdkGC *mygc;
>
> if (!gdk_color_parse("red",&foreground))
> {
> fprintf(stderr,"Failed to parse color\n");
> }
>
> gdk_window_get_size(widget->window,&width,&height);
>
> if (!(mygc = gdk_gc_new(widget->window)))
> {
> fprintf(stderr,"Failed to allocate GC\n");
> }
>
> gdk_gc_set_foreground(mygc,&foreground);
>
> gdk_draw_rectangle(widget->window,
> mygc,
> TRUE,
> 0,0,
> width,height);
>
> gdk_gc_destroy(mygc);
>
> return FALSE;
> }
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
Probably you forgot to allocate the color in the widget colormap. Look at FAQ
5.2
"How do I use color allocation?".
Jan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]