On Wed, Aug 8, 2012 at 7:53 AM, Prasanta Sadhukhan <psadhukhan@xxxxxxxxx> wrote:
first of all, you need to grasp the absolutely fundamental fact about drawing widget contents in GTK and more or less any other GUI toolkit: there is only one place you can do this, and that is in the callback/handler that notifies you that the window needs redrawing. In GTK2, that is done in a handler for the expose signal, and in GTK3 its done in a handler for the draw signal. You cannot draw into a widget's on-screen window anywhere other than the code in these handlers.
secondly, you should be using cairo for this (drawing into a cairo pattern and then using it as the source in the handler) or a GdkPixbuf. GdkPixmaps are now deprecated.
finally, you're code never actually draws anything in the main window at all. you've just drawn into a pixmap, and then displayed a window.
Hi,
I am trying to draw something on offscreen surface and then trying to render it on primary window. I started with simple primitives like rectangle but it seems to not draw anything except a blank white window. Here's my code.
Can anyone suggest as to what I need to do to draw a rectangle on an offscreen surface and then render to primary visible window?
first of all, you need to grasp the absolutely fundamental fact about drawing widget contents in GTK and more or less any other GUI toolkit: there is only one place you can do this, and that is in the callback/handler that notifies you that the window needs redrawing. In GTK2, that is done in a handler for the expose signal, and in GTK3 its done in a handler for the draw signal. You cannot draw into a widget's on-screen window anywhere other than the code in these handlers.
secondly, you should be using cairo for this (drawing into a cairo pattern and then using it as the source in the handler) or a GdkPixbuf. GdkPixmaps are now deprecated.
finally, you're code never actually draws anything in the main window at all. you've just drawn into a pixmap, and then displayed a window.
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list