Re: help on graphics context colors not honored? (newbie)



Use cairo instead. Basically you create a an expose event handler, in which you create a cairo context from the GdkWindow and then you draw on it. I couldn't find a good tutorial example, but there is plenty of code showing how to do it. E.g. look for view_ocr_face_expose() at http://markmail.org/message/ezbcboy7somxnwqn .

That said gdk drawing should also work though it is considered deprecated. You should still make sure that you draw in your expose handle. Perhaps you simply forgot to show your widgets? Post the code here if nothing else helps.

Regards,
Dov

2009/5/22 Lars Oliver Hansen <lolh ymail com>
Hello,
 
I'm new to GTK+ programming and I may have to do some custom drawing. I have gone through the tutorial for DrawingArea at http://library.gnome.org/devel/gtk-tutorial/stable/x2472.html and did everything as written there, yet my window remains the default gray when compiled on Ubuntu 9.04. So the tutorials directives already don't work!
I've made sure it's not the exposing of the pixmap by always copying the entire pixmap, so I suspect the graphics context isn't honored. I haven't yet understood the default gcs but I also did this: gc=gdk_gc_new_with_values(pixmap,&values,values_mask); for which I defined a GdkGCValues structure with foreground.r.../g.../b...=0 and background.~=65535 and an appropriate mask. Yet the window remains gray.
In particular gdk_draw_rectangle and gdk_draw_line don't have any visual effect.
Regarding GdkColor s (for graphic contexts fore- and background), what is an allocated color?
I've noticed that the configure_event gets fired whenever my window (the window from above tutorial link) gets partially hidden, moved or selected rather than the expose_event. I thought the configure_event gets fired only when the window is resized, according to the tutorial? That would be less cpu and memory bandwidth-consuming :-)
Summarised I need help to get a primitive visible in my window in a custom color.
Thanks for any help in advance!
Lars


_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list




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