- 论坛徽章:
- 0
|
RT
我程序大概是这样子的
刚开始就用gdk_draw_pixbuf把一张图像给绘到drawarea里
然后按照gtk-demo里的例子给他加入"configure_event"和"expose_event"
两个事件两个事件的代码是从gtk-demo里复制过来的
但是做好后发现当我覆盖图片的时候,只恢复gdk_draw_rectangle时画的黑色区域,图片没有恢复
不知道为什么会出现在这样问题.
- gboolean scribble_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
- {
- if (pixmap) //全局变量
- g_object_unref (pixmap);
- pixmap= gdk_pixmap_new (widget->window, widget->allocation.width, widget->allocation.height,-1);
- gdk_draw_rectangle (pixmap, widget->style->black_gc,TRUE, 0, 0, widget->allocation.width, widget->allocation.height);
- //gdk_draw_pixmap(widget->window, widget->style->bg_gc[GTK_WIDGET_STATE (widget)],pixmap,0,0,0,0,widget->allocation.width,widget->allocation.height);
- return TRUE;
- }
- gboolean scribble_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data)
- {
- gdk_draw_drawable (widget->window,widget->style->bg_gc[GTK_WIDGET_STATE (widget)],pixmap, event->area.x, event->area.y, event->area.x, event->area.y, event->area.width, event->area.height);
- //gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)],pixmap, event->area.x, event->area.y, event->area.x, event->area.y, event->area.width, event->area.height);
- return FALSE;
- }
复制代码 |
|