I'm a complete newbie with Gtk# and Gdk# and I'm completely lost as to how to get started.
All I'm trying to do is to draw points and lines in whatever widget/pixmap/image and then display them in my gtk application.
So far, I understand I must create a Gdk.drawable
object to access the DrawPoints(Point[] points)
and DrawLine(Point[] points)
methods. However, to instantiate a Drawable
object I need a Gdk.GC
object. Both object constructors take an IntPtr
parameter, and I don't know what IntPtr
I should pass here?! Or, a GC constructor could also take a Drawable object, and a Drawable constructor could take a GC object...I'm turning in circle here!
It's been 24h of online research and apart from some python examples that use constructors that take no parameter, I couldn't find any resource to get started in C#.
So, could anyone show me how to correctly use these GC and Drawable objects to draw a line using the DrawLine(Point[] points)
method?
GDKEXAMPLE(){
win = new Gtk.Window ("Gdk nightmare");
win.SetDefaultSize (400, 300);
img=new Gtk.Image();
Drawable dr=new Drawable(null); //how to instantiate this object?
Gdk.GC gc=new Gdk.GC(null); //how to instantiate this object?
Point[] pts=new Point[3];
pts[0]=new Point(10,10);
pts[1]=new Point(15,20);
pts[2]=new Point(20,50);
dr.DrawLines(gc,pts);
Pixmap pxmp=new Pixmap(dr,100,100);
img.SetFromPixmap(pxmp,pxmp); //Requests a pixmap and pixmap mask: what mask?
img.QueueDraw();
win.Add(img);
win.ShowAll();
}
Could anyone help me to use the Gdk.GC
and Gdk.Drawable
class and then display any points or lines in a Gtk widget please? maybe by making the above code to work? or any link to some tutorial in C# using this gdk library?
area.GdkWindow
. The documentation forGdk.Window
says it inherits fromGdk.Drawable
, which seems to be what you're looking for and what you can use to construct a Gdk.GC if you really want Gdk. – Panic