public void AddCell(WidgetTableCell cell)
 {
     if (cell == null)
     {
         return;
     }
     Cells.Add(cell);
 }
        void UpdateRowHeightsNormal(IGUIContext ctx, SizeF proposedSize)
        {
            int   FillRowCount   = 0;
            float FixedRowHeight = 0;

            for (int i = 0; i < Table.RowCount; i++)
            {
                WidgetTableRow row = Table.Rows [i];
                switch (row.SizeMode)
                {
                case TableSizeModes.Content:
                    float maxHeight = 0;
                    for (int k = 0; k < row.CellCount; k++)
                    {
                        WidgetTableCell cell = row.Cells [k];
                        if (cell.RowSpan == 1 && cell.Widget != null && cell.Widget.Visible)
                        {
                            float w = 0;
                            for (int m = cell.Column; m < cell.Column + cell.ColumnSpan; m++)
                            {
                                w += Table.Columns [m].Width + CellPadding.Width;
                            }
                            cell.ProposedSize = new Size((int)w, (int)row.Height);
                            cell.UpdatePreferredSize(ctx);
                            maxHeight = Math.Max(maxHeight, cell.PreferredSize.Height);
                        }
                    }
                    row.Height      = maxHeight;
                    FixedRowHeight += maxHeight;
                    break;

                case TableSizeModes.None:
                case TableSizeModes.Fill:
                    FillRowCount++;
                    break;

                case TableSizeModes.Fixed:
                    FixedRowHeight += row.Height;
                    break;
                }
            }

            if (FillRowCount > 0)
            {
                float fillRowHeight = (proposedSize.Height - FixedRowHeight - ((Table.RowCount - 1) * CellPadding.Height)) / FillRowCount;
                for (int i = 0; i < Table.RowCount; i++)
                {
                    WidgetTableRow row = Table.Rows [i];
                    if (row.SizeMode == TableSizeModes.Fill || row.SizeMode == TableSizeModes.None)
                    {
                        row.Height = fillRowHeight;
                    }
                }
            }

            Height = (int)(Table.Rows.Sum(row => row.Height) + ((Table.Rows.Count - 1) * CellPadding.Height));
        }
        // *** Layout table and cells / children ***

        void LayoutNormal(IGUIContext ctx, RectangleF bounds)
        {
            // ToDo:
            // this would be a nice optimization
            // unfortunately Image Layout happens too late
            // and is not ready on first OnLayout()
            // The Dirty flag is updated with some strange side effects,
            // this has to be checked later

            /***
             * if (false && !force && m_LastLayoutBounds == bounds) {
             *      LayoutCells (ctx);
             *      return;
             * }
             * m_LastLayoutBounds = bounds;
             ***/

            int rows = Table.RowCount;
            int cols = Table.ColumnCount;

            if (rows == 0 || cols == 0)
            {
                return;
            }

            float width  = bounds.Width;
            float height = bounds.Height;

            //UpdateColumnWidthsNormal (ctx, bounds);
            //UpdateRowHeightsNormal (ctx, bounds);
            //LayoutCells (ctx);
            //return;

            float top = bounds.Top;
            float left;

            for (int i = 0; i < Table.Rows.Count; i++)
            {
                WidgetTableRow row = Table.Rows [i];

                left = bounds.Left;
                int lastColumn = 0;
                for (int k = 0; k < row.Cells.Count; k++)
                {
                    float           colHeight = row.Height;
                    WidgetTableCell cell      = row.Cells [k];

                    if (cell != null)
                    {
                        // Skip columns
                        for (int m = lastColumn; m < cell.Column; m++)
                        {
                            left += Table.Columns [m].Width + CellPadding.Width;
                        }

                        float colWidth = 0;
                        for (int m = cell.Column; m < cell.Column + cell.ColumnSpan; m++)
                        {
                            colWidth += Table.Columns [m].Width;
                        }
                        colWidth += CellPadding.Width * (cell.ColumnSpan - 1);

                        lastColumn = cell.Column + cell.ColumnSpan;

                        // Skip rows
                        int j = i;
                        while (cell.Row > j && j < rows)
                        {
                            top += Table.Rows [j].Height + CellPadding.Height;
                            j++;
                        }

                        while (j < cell.Row + cell.RowSpan - 1)
                        {
                            j++;
                            if (j < rows)
                            {
                                colHeight += Table.Rows [j].Height + CellPadding.Height;
                            }
                        }

                        // calculate cell
                        cell.OnLayout(ctx, new RectangleF(left, top, colWidth, colHeight));
                        left += colWidth + CellPadding.Width;
                    }
                    else
                    {
                        left += Table.Columns[k].Width + CellPadding.Width;
                    }
                }

                top += Table.Rows [i].Height + CellPadding.Height;
            }
        }
        // *** auf den hier würde ich auch gerne verzichten..
        void UpdateColumnWidthsNormal(IGUIContext ctx, SizeF proposedSize)
        {
            int columnCount = Table.ColumnCount;

            int   FillColCount  = 0;
            float FixedColWidth = 0;

            for (int i = 0; i < columnCount; i++)
            {
                WidgetTableColumn col = Table.Columns [i];
                switch (col.SizeMode)
                {
                case TableSizeModes.Content:
                    float maxWidth = 0;
                    for (int k = 0; k < Table.RowCount; k++)
                    {
                        WidgetTableRow row = Table.Rows [k];
                        for (int m = 0; m < row.Cells.Count; m++)
                        {
                            WidgetTableCell cell = row.Cells [m];
                            if (cell.Column == i)
                            {
                                if (cell.ColumnSpan == 1)
                                {
                                    cell.UpdatePreferredSize(ctx);
                                    maxWidth = Math.Max(maxWidth, cell.PreferredSize.Width);
                                }
                                break;
                            }
                        }
                    }
                    col.Width      = maxWidth;
                    FixedColWidth += maxWidth;
                    break;

                case TableSizeModes.None:
                case TableSizeModes.Fill:
                    FillColCount++;
                    break;

                case TableSizeModes.Fixed:
                    FixedColWidth += col.Width;
                    break;
                }
            }

            if (FillColCount > 0)
            {
                float fillColWidth = (int)(((proposedSize.Width - FixedColWidth - ((columnCount - 1) * CellPadding.Width)) / FillColCount));
                for (int i = 0; i < columnCount; i++)
                {
                    WidgetTableColumn col = Table.Columns [i];
                    if (col.SizeMode == TableSizeModes.Fill || col.SizeMode == TableSizeModes.None)
                    {
                        col.Width = fillColWidth;
                    }
                }
            }

            Width = (int)(Table.Columns.Sum(col => col.Width) + ((Table.Columns.Count - 1) * CellPadding.Width) + 0.5f);

            //DumpColumns ();
        }