如何在其绘制信号处理程序中获取 GtkDrawingArea 的无效区域
How to get invalid region of GtkDrawingArea in its draw signal handler
在the Reference Manual of GtkDrawingArea中说
Draw signals are normally delivered when a drawing area first comes onscreen, or when it’s covered by another window and then uncovered. You can also force an expose event by adding to the “damage region” of the drawing area’s window; gtk_widget_queue_draw_area()
and gdk_window_invalidate_rect()
are equally good ways to do this. You’ll then get a draw signal for the invalid region.
那么如何在绘制信号的处理程序中获取无效区域呢?
是剪辑区域吗?
这在 the documentation for the draw
signal itself 中得到了回答:
The signal handler will get a cr
with a clip region already set to the widget's dirty region, i.e. to the area that needs repainting. Complicated widgets that want to avoid redrawing themselves completely can get the full extents of the clip region with gdk_cairo_get_clip_rectangle()
, or they can get a finer-grained representation of the dirty region with cairo_copy_clip_rectangle_list()
.
gdk_cairo_get_clip_rectangle()
是 cairo_clip_extents()
的包装器,它使用整数而不是浮点坐标,因此如果您需要浮点坐标,也可以使用后一个函数。
在the Reference Manual of GtkDrawingArea中说
Draw signals are normally delivered when a drawing area first comes onscreen, or when it’s covered by another window and then uncovered. You can also force an expose event by adding to the “damage region” of the drawing area’s window;
gtk_widget_queue_draw_area()
andgdk_window_invalidate_rect()
are equally good ways to do this. You’ll then get a draw signal for the invalid region.
那么如何在绘制信号的处理程序中获取无效区域呢? 是剪辑区域吗?
这在 the documentation for the draw
signal itself 中得到了回答:
The signal handler will get a
cr
with a clip region already set to the widget's dirty region, i.e. to the area that needs repainting. Complicated widgets that want to avoid redrawing themselves completely can get the full extents of the clip region withgdk_cairo_get_clip_rectangle()
, or they can get a finer-grained representation of the dirty region withcairo_copy_clip_rectangle_list()
.
gdk_cairo_get_clip_rectangle()
是 cairo_clip_extents()
的包装器,它使用整数而不是浮点坐标,因此如果您需要浮点坐标,也可以使用后一个函数。