Esempio n. 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 || view is IRadioButtonCellViewFrontend)
            {
                crd = new CustomCellRendererToggle();
            }
            else if (view is IImageCellViewFrontend)
            {
                crd = new CustomCellRendererImage();
            }
            else if (view is ICanvasCellViewFrontend)
            {
                crd = new CustomCellRenderer();
            }
            else if (view is IComboBoxCellViewFrontend)
            {
                crd = new CustomCellRendererComboBox();
            }
            else
            {
                throw new NotSupportedException("Unknown cell view type: " + view.GetType());
            }

            crd.Initialize(view, col, target);
            col.PackStart(target, crd.CellRenderer, view.Expands);
            col.SetCellDataFunc(target, crd.CellRenderer, (cellLayout, cell, treeModel, iter) => crd.LoadData(treeModel, iter));
            view.AttachBackend(widget, crd);
            return(crd);
        }
Esempio n. 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());
 }
Esempio n. 3
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 ());
 }
Esempio n. 4
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;
		}
Esempio n. 5
0
 public static Gtk.CellRenderer CreateCellRenderer(ApplicationContext actx, ICellRendererTarget col, object target, CellView view, Gtk.TreeModel model)
 {
     if (view is TextCellView) {
         Gtk.CellRendererText cr = new Gtk.CellRendererText ();
         if (((TextCellView)view).Editable) {
             cr.Editable = true;
             cr.Edited += (o, args) => {
                 Gtk.TreeIter iter;
                 if (model.GetIterFromString (out iter, args.Path))
                     model.SetValue (iter, ((TextCellView)view).TextField.Index, args.NewText);
             };
         }
         col.PackStart (target, cr, false);
         col.AddAttribute (target, cr, "text", ((TextCellView)view).TextField.Index);
         return cr;
     }
     else if (view is CheckBoxCellView) {
         Gtk.CellRendererToggle cr = new Gtk.CellRendererToggle ();
         col.PackStart (target, cr, false);
         col.AddAttribute (target, cr, "active", ((CheckBoxCellView)view).ActiveField.Index);
         return cr;
     }
     else if (view is ImageCellView) {
         CellRendererImage cr = new CellRendererImage (actx);
         col.PackStart (target, cr, false);
         col.AddAttribute (target, cr, "image", ((ImageCellView)view).ImageField.Index);
         return cr;
     }
     else if (view is CanvasCellView) {
         var canvas = (CanvasCellView) view;
         var cr = new CustomCellRenderer (canvas);
         col.PackStart (target, cr, false);
         col.SetCellDataFunc (target, cr, delegate (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
             cr.LoadData (cell_layout, cell, tree_model, iter);
             ((CanvasCellView) view).Initialize (cr);
         });
         return cr;
     }
     throw new NotSupportedException ("Unknown cell view type: " + view.GetType ());
 }