コード例 #1
0
ファイル: GridColumnHandler.cs プロジェクト: landytest/Eto
        protected virtual nfloat GetRowWidth(ICellHandler cell, int row, CGSize cellSize)
        {
            var item = DataViewHandler.GetItem(row);
            var val  = GetObjectValue(item);

            return(cell.GetPreferredSize(val, cellSize, row, item));
        }
コード例 #2
0
ファイル: GridColumnHandler.cs プロジェクト: wnf0000/Eto
        public nfloat GetPreferredWidth(NSRange?range = null)
        {
            var    handler     = DataViewHandler;
            nfloat width       = (nfloat)0;       //Control.DataCell.CellSize.Width;
            var    outlineView = handler.Table as NSOutlineView;

            if (handler.ShowHeader)
            {
                width = (nfloat)Math.Max(Control.HeaderCell.CellSize.Width, width);
            }

            if (dataCell != null)
            {
                /* If no range specified, size based on visible cells */
                var currentRange = range ?? handler.Table.RowsInRect(handler.GetVisibleRect());

                var cellSize = Control.DataCell.CellSize;
                cellSize.Height = (nfloat)Math.Max(cellSize.Height, handler.RowHeight);
                var cell = DataCellHandler;
                for (int i = (int)currentRange.Location; i < (int)(currentRange.Location + currentRange.Length); i++)
                {
                    var item      = DataViewHandler.GetItem(i);
                    var val       = GetObjectValue(item);
                    var cellWidth = cell.GetPreferredWidth(val, cellSize, i, item);
                    if (outlineView != null && Column == 0)
                    {
                        cellWidth += (float)((outlineView.LevelForRow((nint)i) + 1) * outlineView.IndentationPerLevel);
                    }
                    width = (nfloat)Math.Max(width, cellWidth);
                }
            }
            return(width);
        }
コード例 #3
0
        public nfloat GetPreferredWidth(NSRange?range = null)
        {
            var    handler = DataViewHandler;
            nfloat width   = 0;

            if (!AutoSize)
            {
                return(Width);
            }

            var outlineView = handler.Table as NSOutlineView;

            if (handler.ShowHeader)
            {
                width = (nfloat)Math.Max(Control.HeaderCell.CellSizeForBounds(new CGRect(0, 0, int.MaxValue, int.MaxValue)).Width, width);
                if (outlineView != null && Column == 0)
                {
                    width += (float)outlineView.IndentationPerLevel;
                }
            }

            if (dataCell != null)
            {
                /* If no range specified, size based on visible cells */
                var currentRange = range ?? handler.Table.RowsInRect(handler.GetVisibleRect());

                var cellSize = Control.DataCell.CellSize;
                cellSize.Height = (nfloat)Math.Max(cellSize.Height, handler.RowHeight);
                var cell = DataCellHandler;
                for (int i = (int)currentRange.Location; i < (int)(currentRange.Location + currentRange.Length); i++)
                {
                    var item      = DataViewHandler.GetItem(i);
                    var val       = GetObjectValue(item);
                    var cellWidth = cell.GetPreferredWidth(val, cellSize, i, item);
                    // -1 signifies that it doesn't support getting the preferred width
                    if (cellWidth == -1)
                    {
                        cellWidth = Control.Width;
                    }
                    else if (outlineView != null && Column == 0)
                    {
                        cellWidth += outlineView.GetCellFrame(0, i).X;
                    }
                    width = (nfloat)Math.Max(width, cellWidth);
                }
            }
            width = (nfloat)Math.Max(MinWidth, Math.Min(MaxWidth, width));
            return(width);
        }