Exemplo 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) {
				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;
		}
Exemplo 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 ());
 }
Exemplo n.º 3
0
        static NSCell CreateCell(NSTableView table, CompositeCell source, CellView cell, int column)
        {
            ICellRenderer cr = null;

            if (cell is ITextCellViewFrontend)
            {
                cr = new TextTableCell();
            }
            else if (cell is IImageCellViewFrontend)
            {
                cr = new ImageTableCell();
            }
            else if (cell is ICanvasCellViewFrontend)
            {
                cr = new CanvasTableCell();
            }
            else if (cell is ICheckBoxCellViewFrontend)
            {
                cr = new CheckBoxTableCell();
            }
            else
            {
                throw new NotImplementedException();
            }
            cr.Backend = new CellViewBackend(table, column);
            ICellViewFrontend fr = cell;

            fr.AttachBackend(null, cr.Backend);
            return((NSCell)cr);
        }
Exemplo n.º 4
0
 public override void Initialize(ICellViewFrontend cellView, ICellRendererTarget rendererTarget, object target)
 {
     base.Initialize(cellView, rendererTarget, target);
     CellRenderer = new CanvasRenderer {
         Parent   = this,
         CellView = (ICanvasCellViewFrontend)cellView
     };
 }
Exemplo n.º 5
0
		public override void Initialize (ICellViewFrontend cellView, ICellRendererTarget rendererTarget, object target)
		{
			base.Initialize (cellView, rendererTarget, target);
			CellRenderer = new CanvasRenderer {
				Parent = this,
				CellView = (ICanvasCellViewFrontend) cellView 
			};
		}
Exemplo n.º 6
0
        static NSView CreateCellView(NSTableView table, CellView cell, int column)
        {
            ICellRenderer cr = null;

            if (cell is ITextCellViewFrontend)
            {
                cr = new TextTableCell();
            }
            else if (cell is IImageCellViewFrontend)
            {
                cr = new ImageTableCell();
            }
            else if (cell is ICanvasCellViewFrontend)
            {
                cr = new CanvasTableCell();
            }
            else if (cell is ICheckBoxCellViewFrontend)
            {
                cr = new CheckBoxTableCell();
            }
            else if (cell is IRadioButtonCellViewFrontend)
            {
                cr = new RadioButtonTableCell();
            }
            else
            {
                throw new NotImplementedException();
            }
            ICellViewFrontend fr      = cell;
            CellViewBackend   backend = null;

            try {
                //FIXME: although the cell views are based on XwtComponent, they don't implement
                //       the dynamic registration based backend creation and there is no way to
                //       identify whether the frontend has already a valid backend.
                backend = cell.GetBackend() as CellViewBackend;
            } catch (InvalidOperationException) { }

            if (backend == null)
            {
                cr.Backend = new CellViewBackend(table, column);
                fr.AttachBackend(null, cr.Backend);
            }
            else
            {
                cr.Backend = backend;
            }
            return((NSView)cr);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
 public virtual void Initialize(ICellViewFrontend cellView, ICellRendererTarget rendererTarget, object target)
 {
     Frontend = cellView;
     this.rendererTarget = rendererTarget;
     this.target = target;
 }
Exemplo n.º 9
0
 public virtual void Initialize(ICellViewFrontend cellView, ICellRendererTarget rendererTarget, object target)
 {
     Frontend            = cellView;
     this.rendererTarget = rendererTarget;
     this.target         = target;
 }
Exemplo n.º 10
0
        internal static FrameworkElementFactory CreateBoundCellRenderer(ApplicationContext ctx, WidgetBackend parent, CellView view, string dataPath = ".")
        {
            ICellViewFrontend fr       = view;
            TextCellView      textView = view as TextCellView;

            if (textView != null)
            {
                // if it's an editable textcontrol, use a TextBox, if not use a TextBlock. Reason for this is that
                // a user usually expects to be able to edit a text if a text cursor is appearing above a field.
                FrameworkElementFactory factory;
                if (textView.Editable || textView.EditableField != null)
                {
                    factory = new FrameworkElementFactory(typeof(SWC.TextBox));
                    if (textView.Editable)
                    {
                        factory.SetValue(SWC.TextBox.IsReadOnlyProperty, false);
                    }
                    else
                    {
                        factory.SetBinding(SWC.TextBox.IsEnabledProperty, new Binding(dataPath + "[" + textView.EditableField.Index + "]"));
                    }

                    if (textView.TextField != null)
                    {
                        factory.SetBinding(SWC.TextBox.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]"));
                    }
                    else
                    {
                        factory.SetValue(SWC.TextBox.TextProperty, textView.Text);
                    }
                }
                else
                {
                    factory = new FrameworkElementFactory(typeof(SWC.TextBlock));

                    if (textView.MarkupField != null)
                    {
                        factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.MarkupField.Index + "]")
                        {
                            Converter = new MarkupToPlainTextConverter()
                        });
                    }
                    else if (textView.TextField != null)
                    {
                        factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]"));
                    }
                    else
                    {
                        factory.SetValue(SWC.TextBlock.TextProperty, textView.Text);
                    }
                }

                var cb = new TextCellViewBackend();
                cb.Initialize(view, factory, parent as ICellRendererTarget);
                fr.AttachBackend(parent.Frontend, cb);
                return(factory);
            }

            ImageCellView imageView = view as ImageCellView;

            if (imageView != null)
            {
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ImageBox));

                if (imageView.ImageField != null)
                {
                    var binding = new Binding(dataPath + "[" + imageView.ImageField.Index + "]");
                    binding.Converter = new ImageToImageSourceConverter(ctx);

                    factory.SetBinding(ImageBox.ImageSourceProperty, binding);
                }

                var cb = new CellViewBackend();
                cb.Initialize(view, factory, parent as ICellRendererTarget);
                fr.AttachBackend(parent.Frontend, cb);
                return(factory);
            }

            CanvasCellView canvasView = view as CanvasCellView;

            if (canvasView != null)
            {
                var cb = new CanvasCellViewBackend();
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CanvasCellViewPanel));
                factory.SetValue(CanvasCellViewPanel.CellViewBackendProperty, cb);

                cb.Initialize(view, factory, parent as ICellRendererTarget);
                fr.AttachBackend(parent.Frontend, cb);
                return(factory);
            }

            CheckBoxCellView cellView = view as CheckBoxCellView;

            if (cellView != null)
            {
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(SWC.CheckBox));
                if (cellView.EditableField == null)
                {
                    factory.SetValue(FrameworkElement.IsEnabledProperty, cellView.Editable);
                }
                else
                {
                    factory.SetBinding(SWC.CheckBox.IsEnabledProperty, new Binding(dataPath + "[" + cellView.EditableField.Index + "]"));
                }

                factory.SetValue(SWC.CheckBox.IsThreeStateProperty, cellView.AllowMixed);
                if (cellView.ActiveField != null)
                {
                    factory.SetBinding(SWC.CheckBox.IsCheckedProperty, new Binding(dataPath + "[" + cellView.ActiveField.Index + "]"));
                }

                var cb = new CheckBoxCellViewBackend();
                cb.Initialize(view, factory, parent as ICellRendererTarget);
                fr.AttachBackend(parent.Frontend, cb);
                return(factory);
            }

            throw new NotImplementedException();
        }
Exemplo n.º 11
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());
 }
Exemplo n.º 12
0
 public virtual void InitializeBackend(object frontend, ApplicationContext context)
 {
     Frontend = (ICellViewFrontend)frontend;
 }
Exemplo n.º 13
0
		public virtual void InitializeBackend (object frontend, ApplicationContext context)
		{
			Frontend = (ICellViewFrontend)frontend;
		}