Beispiel #1
0
		public static CellViewBackend CreateCellRenderer (ApplicationContext actx, Widget widget, ICellRendererTarget col, object target, ICellViewFrontend view)
		{
			CellViewBackend crd;

			if (view is ITextCellViewFrontend) {
				crd = new CustomCellRendererText ();
			}
			else if (view is ICheckBoxCellViewFrontend) {
				crd = new CustomCellRendererToggle ();
			}
			else if (view is IImageCellViewFrontend) {
				crd = new CustomCellRendererImage ();
			}
			else if (view is ICanvasCellViewFrontend) {
				crd = new CustomCellRenderer ();
			}
			else
				throw new NotSupportedException ("Unknown cell view type: " + view.GetType ());

			crd.Initialize (view, col, target);
			col.PackStart (target, crd.CellRenderer, false);
			col.SetCellDataFunc (target, crd.CellRenderer, (cellLayout, cell, treeModel, iter) => crd.LoadData (treeModel, iter));
			view.AttachBackend (widget, crd);
			return crd;
		}
Beispiel #2
0
 public static Gtk.CellRenderer CreateCellRenderer(ApplicationContext actx, ICellRendererTarget col, object target, ICellViewFrontend view, Gtk.TreeModel model)
 {
     if (view is ITextCellViewFrontend) {
         var cr = new CustomCellRendererText ((ITextCellViewFrontend)view);
         col.PackStart (target, cr, false);
         col.SetCellDataFunc (target, cr, (cell_layout, cell, treeModel, iter) => cr.LoadData (treeModel, iter));
         return cr;
     }
     else if (view is ICheckBoxCellViewFrontend) {
         CustomCellRendererToggle cr = new CustomCellRendererToggle ((ICheckBoxCellViewFrontend)view);
         col.PackStart (target, cr, false);
         col.SetCellDataFunc (target, cr, (cellLayout, cell, treeModel, iter) => cr.LoadData (treeModel, iter));
         return cr;
     }
     else if (view is IImageCellViewFrontend) {
         CustomCellRendererImage cr = new CustomCellRendererImage (actx, (IImageCellViewFrontend)view);
         col.PackStart (target, cr, false);
         col.SetCellDataFunc (target, cr, (cellLayout, cell, treeModel, iter) => cr.LoadData (treeModel, iter));
         return cr;
     }
     else if (view is ICanvasCellViewFrontend) {
         var cr = new CustomCellRenderer ((ICanvasCellViewFrontend) view);
         col.PackStart (target, cr, false);
         col.SetCellDataFunc (target, cr, (cellLayout, cell, treeModel, iter) => cr.LoadData (treeModel, iter));
         return cr;
     }
     throw new NotSupportedException ("Unknown cell view type: " + view.GetType ());
 }