private void PaintCell(int column_index, int row_index, Rectangle area, bool sensitive, StateType state, bool dragging)
        {
            Cell cell = column_cache [column_index].Column.ListCell;

            try {
                cell.BindListItem(row_index);
            } catch (CellNotValidException) {
                return;
            }

            if (dragging)
            {
                Cairo.Color fill_color = Theme.Colors.GetWidgetColor(GtkColorClass.Base, StateType.Normal);
                fill_color.A        = 0.5;
                cairo_context.Color = fill_color;
                cairo_context.Rectangle(area.X, area.Y, area.Width, area.Height);
                cairo_context.Fill();
            }

            cairo_context.Save();
            cairo_context.Translate(area.X, area.Y);
            cell_context.Area      = area;
            cell_context.Sensitive = sensitive;
            ISizeRequestCell sr_cell = cell as ISizeRequestCell;

            if (sr_cell != null && sr_cell.RestrictSize)
            {
                int w, h;
                sr_cell.GetSize(out w, out h);
                column_cache [column_index].Column.MinWidth = w;
                column_cache [column_index].Column.MaxWidth = w;
            }
            cell.Render(cell_context, dragging ? StateType.Normal : state, area.Width, area.Height, new CellPosition(column_index, row_index));
            cairo_context.Restore();
        }
Esempio n. 2
0
        public void CalculateWidths(Pango.Layout layout, bool headerVisible, int headerHeight)
        {
            bool             min_was_zero = MinWidth == 0;
            bool             was_size_req = false;
            ISizeRequestCell sr_cell      = cells[0] as ISizeRequestCell;

            if (sr_cell != null && sr_cell.RestrictSize)
            {
                int min_w, max_w;
                sr_cell.GetWidthRange(layout, out min_w, out max_w);
                MinWidth     = min_w == -1 ? MinWidth : min_w;
                MaxWidth     = max_w == -1 ? MaxWidth : max_w;
                was_size_req = true;
            }

            if (headerVisible && (min_was_zero || was_size_req) && !String.IsNullOrEmpty(Title))
            {
                int w, h;
                layout.SetText(Title);
                //column_layout.SetText ("\u2026"); // ellipsis char
                layout.GetPixelSize(out w, out h);

                // Pretty sure the 3* is needed here only b/c of the " - 8" in ColumnCellText;
                // See TODO there
                w += 3 * ColumnHeaderCellText.Spacing;
                if (this is ISortableColumn)
                {
                    w += ColumnHeaderCellText.GetArrowWidth(headerHeight);
                }

                MinWidth = Math.Max(MinWidth, w);

                // If the min/max are sufficiently close (arbitrarily choosen as < 8px) then
                // make them equal, so that the column doesn't appear resizable but in reality is on barely.
                if (MaxWidth - MinWidth < 8)
                {
                    MinWidth = MaxWidth;
                }
            }
        }