[Gtk-sharp-list] ImageMenuItem does not display the image (Linux platform)

Steffen Ploetz steffen.ploetz at p-und-z.de
Tue May 10 05:09:50 EDT 2011


I solved the problem this way:


menuItem.ExposeEvent += GtkHelper.DrawImageMenuItemImage;

		
/// <summary> Draw the image to the image menu item. </summary>
///  The event source. <see cref="System.Object"/> 
///  The event args. <see cref="Gtk.ExposeEventArgs"/> 
public static void DrawImageMenuItemImage(object o, Gtk.ExposeEventArgs
args)
{
	if (o as Gtk.ImageMenuItem == null)
		return;
		
	Gtk.Image image = (o as Gtk.ImageMenuItem).Image as Gtk.Image;
	if (image == null || image.Pixbuf == null)
		return;

	Gdk.GC mainGC =
((Gtk.Widget)o).Style.ForegroundGCs[(int)Gtk.StateType.Normal];
	Gdk.Rectangle r = args.Event.Area;
			
	args.Event.Window.DrawPixbuf(mainGC, image.Pixbuf, 0, 0, r.Left + 2,
	                             r.Top + (r.Height - image.Pixbuf.Height) / 2,
-1, -1, Gdk.RgbDither.None, 0, 0);
			
}


Regards, Steffen

--
View this message in context: http://mono.1490590.n4.nabble.com/ImageMenuItem-does-not-display-the-image-Linux-platform-tp3510861p3511376.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.


More information about the Gtk-sharp-list mailing list