Example #1
0
		public static NSCell CreateCell (ApplicationContext context, NSTableView table, ICellSource source, ICollection<CellView> cells, int column)
		{
			CompositeCell c = new CompositeCell (context, Orientation.Horizontal, source);
			foreach (var cell in cells)
				c.AddCell ((ICellRenderer) CreateCell (table, c, cell, column));
			return c;
		}
Example #2
0
        public void UpdateColumn(ListViewColumn col)
        {
            Editable = true;
            var hc = new NSTableHeaderCell {
                Title = col.Title ?? string.Empty
            };

            HeaderCell           = hc;
            HeaderCell.Alignment = col.Alignment.ToNSTextAlignment();

            DataView            = CellUtil.CreateCellView(context, backend, col.Views, backend.Columns.IndexOf(this));
            DataView.Identifier = Identifier;
            UpdateCachedViews(col.Views);

            if (col.CanResize)
            {
                ResizingMask |= NSTableColumnResizing.UserResizingMask;
            }
            else
            {
                ResizingMask &= ~NSTableColumnResizing.UserResizingMask;
            }
            if (col.Expands)
            {
                ResizingMask |= NSTableColumnResizing.Autoresizing;
            }
            else
            {
                ResizingMask &= ~NSTableColumnResizing.Autoresizing;
            }
            SizeToFit();
            TableView?.InvalidateIntrinsicContentSize();
        }
Example #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);
        }
Example #4
0
            public override nfloat GetSizeToFitColumnWidth(NSOutlineView outlineView, nint column)
            {
                var tableColumn = Backend.Columns[(int)column] as TableColumn;
                var width       = tableColumn.HeaderCell.CellSize.Width;

                CompositeCell templateCell = null;

                for (int i = 0; i < outlineView.RowCount; i++)
                {
                    var cellView = outlineView.GetView(column, i, false) as CompositeCell;
                    if (cellView == null)                       // use template for invisible rows
                    {
                        cellView = templateCell ?? (templateCell = (tableColumn as TableColumn)?.DataView?.Copy() as CompositeCell);
                        if (cellView != null)
                        {
                            cellView.ObjectValue = outlineView.ItemAtRow(i);
                        }
                    }
                    if (cellView != null)
                    {
                        if (column == 0)                         // first column contains expanders
                        {
                            width = (nfloat)Math.Max(width, cellView.Frame.X + cellView.FittingSize.Width);
                        }
                        else
                        {
                            width = (nfloat)Math.Max(width, cellView.FittingSize.Width);
                        }
                    }
                }
                return(width);
            }
Example #5
0
 public static NSCell CreateCell(ICellSource source, ICollection<CellView> cells)
 {
     CompositeCell c = new CompositeCell (Orientation.Horizontal, source);
     foreach (var cell in cells)
         c.AddCell ((ICellRenderer) CreateCell (c, cell));
     return c;
 }
Example #6
0
 public static void UpdateCellView(CompositeCell cellView, NSTableView table, ICollection <CellView> cells, int column)
 {
     cellView.ClearCells();
     foreach (var cell in cells)
     {
         cellView.AddCell((ICellRenderer)CreateCellView(table, cell, column));
     }
 }
Example #7
0
        public static CompositeCell CreateCellView(ApplicationContext context, NSTableView table, ICellSource source, ICollection <CellView> cells, int column)
        {
            CompositeCell c = new CompositeCell(context, source);

            foreach (var cell in cells)
            {
                c.AddCell((ICellRenderer)CreateCellView(table, cell, column));
            }
            return(c);
        }
Example #8
0
        public static NSCell CreateCell(ICellSource source, ICollection <CellView> cells)
        {
            CompositeCell c = new CompositeCell(Orientation.Horizontal, source);

            foreach (var cell in cells)
            {
                c.AddCell((ICellRenderer)CreateCell(c, cell));
            }
            return(c);
        }
Example #9
0
        public static NSCell CreateCell(NSTableView table, ICellSource source, ICollection <CellView> cells, int column)
        {
            CompositeCell c = new CompositeCell(Orientation.Horizontal, source);

            foreach (var cell in cells)
            {
                c.AddCell((ICellRenderer)CreateCell(table, c, cell, column));
            }
            return(c);
        }
Example #10
0
 public static NSCell CreateCell(ICellSource source, ICollection<CellView> cells)
 {
     //			if (cells.Count > 1) {
         CompositeCell c = new CompositeCell (Orientation.Horizontal, source);
         foreach (var cell in cells)
             c.AddCell ((ICellRenderer) CreateCell (source, cell));
         return c;
     //			} else
     //				return CreateCell (source, cells.First ());
 }
Example #11
0
 static NSCell CreateCell(CompositeCell source, CellView cell)
 {
     if (cell is ITextCellViewFrontend)
         return new TextTableCell ((ITextCellViewFrontend) cell);
     if (cell is IImageCellViewFrontend)
         return new ImageTableCell ((IImageCellViewFrontend) cell);
     if (cell is ICanvasCellViewFrontend)
         return new CanvasTableCell ((ICanvasCellViewFrontend) cell);
     if (cell is ICheckBoxCellViewFrontend)
         return new CheckBoxTableCell ((ICheckBoxCellViewFrontend) cell);
     throw new NotImplementedException ();
 }
Example #12
0
        public static NSCell CreateCell(ICellSource source, ICollection <CellView> cells)
        {
//			if (cells.Count > 1) {
            CompositeCell c = new CompositeCell(Orientation.Horizontal, source);

            foreach (var cell in cells)
            {
                c.AddCell((ICellRenderer)CreateCell(source, cell));
            }
            return(c);
//			} else
//				return CreateCell (source, cells.First ());
        }
Example #13
0
        public void UpdateColumn(ListViewColumn col, ListViewColumnChange change)
        {
            if (TableView == null)
            {
                throw new InvalidOperationException("Add the column to a table first");
            }
            switch (change)
            {
            case ListViewColumnChange.CanResize:
                if (col.CanResize)
                {
                    ResizingMask |= NSTableColumnResizing.UserResizingMask;
                }
                else
                {
                    ResizingMask &= ~NSTableColumnResizing.UserResizingMask;
                }
                break;

            case ListViewColumnChange.Expanding:
                if (col.Expands)
                {
                    ResizingMask |= NSTableColumnResizing.Autoresizing;
                }
                else
                {
                    ResizingMask &= ~NSTableColumnResizing.Autoresizing;
                }
                break;

            case ListViewColumnChange.Cells:
                DataView            = CellUtil.CreateCellView(context, backend, col.Views, backend.Columns.IndexOf(this));
                DataView.Identifier = Identifier;
                UpdateCachedViews(col.Views);
                TableView.ReloadData();
                break;

            case ListViewColumnChange.Title:
                HeaderCell.Title = col.Title ?? string.Empty;
                if (!col.CanResize)
                {
                    SizeToFit();
                }
                break;

            case ListViewColumnChange.Alignment:
                HeaderCell.Alignment = col.Alignment.ToNSTextAlignment();
                break;
            }
        }
Example #14
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;
		}
Example #15
0
 static NSCell CreateCell(CompositeCell source, CellView cell)
 {
     if (cell is ITextCellViewFrontend)
     {
         return(new TextTableCell((ITextCellViewFrontend)cell));
     }
     if (cell is IImageCellViewFrontend)
     {
         return(new ImageTableCell((IImageCellViewFrontend)cell));
     }
     if (cell is ICanvasCellViewFrontend)
     {
         return(new CanvasTableCell((ICanvasCellViewFrontend)cell));
     }
     if (cell is ICheckBoxCellViewFrontend)
     {
         return(new CheckBoxTableCell((ICheckBoxCellViewFrontend)cell));
     }
     throw new NotImplementedException();
 }
Example #16
0
            public override nfloat GetSizeToFitColumnWidth(NSTableView tableView, nint column)
            {
                var tableColumn = Backend.Columns[(int)column] as TableColumn;
                var width       = tableColumn.HeaderCell.CellSize.Width;

                CompositeCell templateCell = null;

                for (int i = 0; i < tableView.RowCount; i++)
                {
                    var cellView = tableView.GetView(column, i, false) as CompositeCell;
                    if (cellView == null)                       // use template for invisible rows
                    {
                        cellView = templateCell ?? (templateCell = (tableColumn as TableColumn)?.DataView?.Copy() as CompositeCell);
                        if (cellView != null)
                        {
                            cellView.ObjectValue = NSNumber.FromInt32(i);
                        }
                    }
                    width = (nfloat)Math.Max(width, cellView.FittingSize.Width);
                }
                return(width);
            }
Example #17
0
        nfloat CalcRowHeight(nint row, bool tryReuse = true)
        {
            updatingRowHeight = true;
            var height = Table.RowHeight;

            for (int i = 0; i < Columns.Count; i++)
            {
                CompositeCell cell = tryReuse ? Table.GetView(i, row, false) as CompositeCell : null;
                if (cell == null)
                {
                    cell = (Columns [i] as TableColumn)?.DataView as CompositeCell;
                }

                if (cell != null)
                {
                    cell.ObjectValue = NSNumber.FromNInt(row);
                    height           = (nfloat)Math.Max(height, cell.FittingSize.Height);
                }
            }
            updatingRowHeight = false;
            return(height);
        }
Example #18
0
        nfloat CalcRowHeight(TreeItem pos, bool tryReuse = true)
        {
            updatingRowHeight = true;
            var height = Table.RowHeight;
            var row    = Tree.RowForItem(pos);

            for (int i = 0; i < Columns.Count; i++)
            {
                CompositeCell cell = tryReuse ? Tree.GetView(i, row, false) as CompositeCell : null;
                if (cell == null)
                {
                    cell = (Columns [i] as TableColumn)?.DataView as CompositeCell;
                }

                if (cell != null)
                {
                    cell.ObjectValue = pos;
                    height           = (nfloat)Math.Max(height, cell.FittingSize.Height);
                }
            }
            updatingRowHeight = false;
            return(height);
        }