I am able to draw rectangle on offscreen. Here's the code
Now I have one question. Now I wanted to render main window contents and offscreen contents simultaneously and for that, I have registered "expose" event handlers for both.
offscreen expose handler will draw green rectangle and main window expose handler will draw blue rectangle but it seem it only draws green rectangle.
Can anyone suggest how can I make sure both main window contents and offscreen contents are rendered simultaneously in the below code?
Thanks in advance!!
==========
#include <gtk/gtk.h>
static gboolean
expose_event_offscr (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
GdkPixbuf *pbuf;
cairo_t *cr;
printf("expose_event_ofscr called\n");
cr = gdk_cairo_create(widget->window);
cairo_set_source_rgb(cr, 0, 1, 0);
cairo_rectangle(cr, 300, 300, 200, 200); // green rectangle
//cairo_fill(cr);
cairo_stroke(cr);
cairo_destroy(cr);
return FALSE;
}
static gboolean
expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
printf("expose_event called\n");
GdkPixbuf *pbuf;
cairo_t *cr;
cr = gdk_cairo_create(widget->window);
cairo_set_source_rgb(cr, 0, 0, 1); // blue rectangle
cairo_rectangle(cr, 100, 100, 200, 200);
//cairo_fill(cr);
cairo_stroke(cr);
cairo_destroy(cr);
return FALSE;
}
int main(int argc, char* argv[])
{
GtkWidget *image;
// Initialize GTK+
gtk_init(&argc, &argv);
// Create an 800x600 window that will contain the browser instance
GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(main_window), 1200, 800);
#if 1
GtkWidget *da = gtk_drawing_area_new();
g_signal_connect (da , "expose-event", G_CALLBACK(expose_event_offscr), NULL);
gtk_container_add(GTK_CONTAINER(main_window), da);
gtk_widget_show(da);
#endif
g_signal_connect (main_window , "expose-event", G_CALLBACK(expose_event), NULL);
// Make sure the main window and all its contents are visible
gtk_widget_show(main_window);
// Run the main GTK+ event loop
gtk_main();
return 0;
}
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list