[Gtk-sharp-list] NullReferenceException on DrawingLayout
Tiago Lima
tiago.lima@vianw.pt
Wed, 18 Feb 2004 20:34:17 +0000
Hi,
I'm trying this code and it gives me a NulllReferenceException when calling
the DrawLayout... Am I missing something ?
Pango.Layout layout = new Pango.Layout(_gtkDrawingArea.PangoContext);
Pango.FontDescription font = new Pango.FontDescription();
Gdk.Pixmap pixmap = new Gdk.Pixmap(_gtkDrawingArea.GdkWindow, 400, 400, -1);
pixmap.DrawRectangle(_gtkDrawingArea.Style.WhiteGC, true, 0, 0, 400, 400);
font.Size = 30 * (int)Pango.Scale.PangoScale;
font.Family = "Courier";
layout.FontDescription = font;
layout.SetText("Test Text : ");
Attribute attribute = Attr.ForegroundNew(0xff, 0xff, 0);
attribute.start_index = 0;
attribute.end_index = 1;
layout.Attributes = new AttrList();
layout.Attributes.Insert(attribute);
_gtkDrawingArea.GdkWindow.DrawLayout(_gtkDrawingArea.Style.BlackGC, 20, 200,
layout); // <<<<<<<<<<<<<< error inside
Unhandled Exception: System.Reflection.TargetInvocationException: Exception
has been thrown by the target of an invocation. --->
System.NullReferenceException: A null value was found where an object
instance was required
in (unmanaged) (wrapper managed-to-native) Gdk.Drawable:gdk_draw_layout
(intptr,intptr,int,int,intptr)
in <0x00004> (wrapper managed-to-native) Gdk.Drawable:gdk_draw_layout
(intptr,intptr,int,int,intptr)
in <0x00061> Gdk.Drawable:DrawLayout (Gdk.GC,int,int,Pango.Layout)
And if i remove the attribute it works fine...
Thanks in advance,
Tiago Lima