[Gtk-sharp-list] New Gtk# user question

Willem J.W. Semmelink willems@digicore.co.za
Thu, 11 Sep 2003 11:08:07 +0200


Hi everyone. I am still new to Gtk and I need some help using the =
library.

I am trying to draw on an Image and then to display the image in a =
ScrolledWindow.=20
When I run the code below, I get a run-time exception about a null =
reference in the method that
draws on the pixmap.=20

What I would like to know is:
(1) Is Gtk# development already to a point where I can write =
applications using Image, and canvas drawing?
   =20
(2) I am confused between Image, Pixbuf, and Pixmap. Some basic example =
code to draw on an image, and=20
then to display the image in a scrolled window.  I am trying to =
understand the Gtk# classes, but even after=20
reading the Monodoc, and the original Gtk+ documentation, I still cannot =
really understand how the classes=20
relate to each other and to write Gtk# code for drawing on an image's =
canvas.=20

Thanks
Willem Semmelink

I used Gtk# 0.10 on Windows XP. [I did not build it myself - downloaded =
the binaries]

public static int Main(string[] args)
{
	Application.Init();
	Gtk.Window win =3D new Gtk.Window ("Preview Window");
	win.DeleteEvent +=3D new DeleteEventHandler(Window_Delete);			=09
	Gtk.ScrolledWindow scrolled_window =3D new Gtk.ScrolledWindow ();=09
	Gtk.Image im =3D new Gtk.Image();		=09
	Gdk.Pixmap pixmap =3D new Gdk.Pixmap(im.GdkWindow,600,600,-1);			=09
	pixmap.DrawRectangle(im.Style.WhiteGC,15,30,30,100,100);   //NULL =
REFERENCE RUNTIME ERROR=09
	im.SetFromPixmap(pixmap,null);
	scrolled_window.AddWithViewport(im);
	im.Show();
	win.Add (scrolled_window);
	win.ShowAll ();				=09
	Application.Run ();
	return 0;
}