Hey,

I have attached a small cell renderer which overrides Render and simply paints a red rectangle(but you will have to change the file to override Render, not OnRender).

If you need a click event, you have to override OnActivate, which isn't supported yet. I'm working on a patch to implement that and will write a mail to the list when I'm done.

Christian

Jir(í Zárevúcký wrote:
There are some methods for drawing in Gdk.Drawable (parent class of
Gdk.Window, which is passed as a parameter to the Render method).

2009/2/11 dabatla <daba...@gmail.com>:
Hi, I would like to create CellRendererPixBuf -like cell renderer, but I also
need a click/toggle event on it. I believe the way to proceed is to device
from CellRendererToggle and then just to override the Render(..) method, but
my problem is that I have no clue on how to render the icon or stock item i
need in there.

I'm sure there is a simple way, it just seems that I can't figure it out :-(

please help
--
View this message in context: 
http://www.nabble.com/CellRendererPixBuf-with-toggle-event--tp21954953p21954953.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.

_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list


using System;

namespace PixbufOverride
{
	
	
	public class TestRenderer : Gtk.CellRenderer
	{
		
		public TestRenderer() {
			this.Mode = Gtk.CellRendererMode.Activatable;
			GLib.GType MyType = GLib.GType.Object;
			System.Console.WriteLine(this.TypeName);
			
			// System.Console.WriteLine((this as Gtk.CellRenderer).Activate(Gdk.EventHelper.New(Gdk.EventType.ButtonPress), null, "0", new Gdk.Rectangle(0, 0, 2, 2), new Gdk.Rectangle(0, 0, 1, 1), Gtk.CellRendererState.Selected));
		}
		
		protected override void OnGetSize (Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
		{
			System.Console.WriteLine ("GetSize called");
			base.GetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height);
			cell_area = new Gdk.Rectangle (0, 0, 1, 1);
			x_offset = 0;
			y_offset = 0;
			width = 30;
			height = 30;
		}
		
		protected override void OnRender (Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
		{
			System.Console.WriteLine ("Render called");
			Cairo.Context DrawingContext = Gdk.CairoHelper.Create(window);
			DrawingContext.Color = new Cairo.Color(255, 0, 0);
			DrawingContext.Rectangle(cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);
			DrawingContext.Fill();
			(DrawingContext.Target as System.IDisposable).Dispose();
			(DrawingContext as System.IDisposable).Dispose();
		}
		
		protected override System.Boolean OnActivate(Gdk.Event evnt, Gtk.Widget widget, System.String path, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gtk.CellRendererState flags) {
			System.Console.WriteLine("I was activated! returned value of Gtk.CellRenderer: {0}", base.OnActivate(evnt, widget, path, background_area, cell_area, flags));
			return true;
		}
	}
}
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to