Merge pull request #268 from pcc/menudeactivate
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewCellPaintingEventArgs.cs
index 10472a20e69e81df8c58d9f7cdcdf8205b39347b..ec7fd5807fdcba7a69e6e427e7097cd2be667884 100644 (file)
@@ -24,8 +24,6 @@
 //
 
 
-#if NET_2_0
-
 using System.ComponentModel;
 using System.Drawing;
 
@@ -112,46 +110,36 @@ namespace System.Windows.Forms {
                }
 
                public void Paint (Rectangle clipBounds, DataGridViewPaintParts paintParts) {
-                       if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
+                       if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count)
                                throw new InvalidOperationException("Invalid \"RowIndex.\"");
-                       }
-                       if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
+                       if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count)
                                throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
-                       }
-                       throw new NotImplementedException();
+
+                       DataGridViewCell cell;
+
+                       if (rowIndex == -1 && columnIndex == -1)
+                               cell = dataGridView.TopLeftHeaderCell;
+                       else if (rowIndex == -1)
+                               cell = dataGridView.Columns[columnIndex].HeaderCell;
+                       else if (columnIndex == -1)
+                               cell = dataGridView.Rows[rowIndex].HeaderCell;
+                       else
+                               cell = dataGridView.Rows[rowIndex].Cells[columnIndex];
+
+                       cell.PaintInternal (graphics, clipBounds, cellBounds, rowIndex, cellState, Value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);                               
                }
 
-               public void PaintBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground) {
-                       if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
-                               throw new InvalidOperationException("Invalid \"RowIndex.\"");
-                       }
-                       if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
-                               throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
-                       }
-                       DataGridViewCell cell = dataGridView.Rows[rowIndex].Cells[columnIndex];
-                       Color color;
-                       if (cellsPaintSelectionBackground) {
-                               color = cell.InheritedStyle.SelectionBackColor;
-                       }
-                       else {
-                               color = cell.InheritedStyle.BackColor;
-                       }
-                       ///////// NOT CHECKED //////////////
-                       graphics.FillRectangle(new SolidBrush(color), clipBounds);
-               }
-
-               public void PaintContent (Rectangle clipBounds) {
-                       if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
-                               throw new InvalidOperationException("Invalid \"RowIndex.\"");
-                       }
-                       if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
-                               throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
-                       }
-                       throw new NotImplementedException();
+               public void PaintBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground)
+               {
+                       Paint (clipBounds, DataGridViewPaintParts.Background | DataGridViewPaintParts.Border);
+               }
+                       
+               [MonoInternalNote ("Needs row header cell edit pencil glyph")]
+               public void PaintContent (Rectangle clipBounds)
+               {
+                       Paint (clipBounds, DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground);
                }
 
        }
 
 }
-
-#endif