开发者

Drawing with Mono in GTK# without calling Expose event

I need to create a program to test some procedural world creation algorithms, for which I need a surface to draw on. However, GTK#'s DrawingArea widget requires that all drawing is done in the ExposesEvent. How and in which widget can I draw without going through this event handler? Th开发者_C百科e main problem is that I can't leave the drawing handler attached to the event because the same drawing area is used by multiple algorithms, so after drawing is done I remove it. If I resize or move the window then, all the generated drawings go away which is not very useful.

I tried using Mono.Cairo instead of System.Drawing, but the same rule seems to apply to it. Thanks in advance.


You need to use an offline pixmap (with Gtk/Gdk) or surface (Cairo) so that you'll do all the drawing to it and when the expose event comes you just do a copy of the image to the display widget. See this https://github.com/mono/gtk-sharp/blob/master/sample/Scribble.cs for the Mono.Cairo sample (and check the older revisions of that file for the cairo-less code, but I suggest using Cairo moving forward).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜