Re: [Java-gnome-developer] Assertion failure while drawing on DrawingArea
Brought to you by:
afcowie
From: Jaime <re...@sa...> - 2004-12-12 19:40:38
|
On Sun, 2004-12-12 at 16:55 +0000, Mark Howard wrote: > Hi, > > I'm not familiar with the drawing widgets, so this is completely off the top of > my head: > > You've created a window and filled it with a DrawingArea. > You try to draw on the window, but this fails. I'm guessing that this fails > since there is already something else on the window -- the DrawingArea. > > Try changing your code to DrawPoint on the drawingarea instead. Please write > back saying if it works or not. > Hi Mark. Unfortunately, neither the "top level window" (of type org.gnu.gtk.Window) nor the DrawingArea embedded inside it (of type org.gnu.gtk.DrawingArea) possess a drawPoint() method - the only class which does (according to the javadocs) is an "org.gnu.gdk.Window" (notice the change from gtk.Window to gdk.Window!) This itself, is fine, as it seems to agree with the following documentation: a) The javadocs for org.gnu.gtk.Widget.getWindow() ("Return the widget's gdk window. This is the window to draw upon when writing custom widgets. It's available after the widget has been mapped. Thus if you listen to LifeCycleEvents, you can fetch the Window instance using this method after an LifeCycleEvent of type MAP has occured. Returns: the widget's gdk window, or null if a) it hasn't been mapped yet or b) it is of a type that doesn't have a gdk window. b) http://www.pygtk.org/pygtk2tutorial/sec-DrawingMethods.html The example code "drawingarea.py" is what I'm actually trying to port to java - line 41, for example, refers to: self.area.window.draw_point(self.gc, x+30, y+30) ("area" is the drawing area, the "window" attribute is its embedded gdkWindow, which gets drawn upon using the "draw_point" method) c) http://developer.gnome.org/doc/API/2.0/gtk/GtkDrawingArea.html and http://www.gtk.org/tutorial/sec-thedrawingareawidget.html Incidently, I've tried using both the gdk.Window returned by both area.getWindow() _and_ window.getWindow(), but they both return the same error. Hope some of this makes sense, Jaime :-) |