Fix bug #395
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewRowPostPaintEventArgs.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
21 //
22 // Author:
23 //      Pedro Martínez Juliá <pedromj@gmail.com>
24 //
25
26 using System.ComponentModel;
27 using System.Drawing;
28
29 namespace System.Windows.Forms {
30
31         public class DataGridViewRowPostPaintEventArgs : EventArgs {
32
33                 private DataGridView dataGridView;
34                 private Graphics graphics;
35                 private Rectangle clipBounds;
36                 private Rectangle rowBounds;
37                 private int rowIndex;
38                 private DataGridViewElementStates rowState;
39                 private string errorText;
40                 private DataGridViewCellStyle inheritedRowStyle;
41                 private bool isFirstDisplayedRow;
42                 private bool isLastVisibleRow;
43
44                 public DataGridViewRowPostPaintEventArgs (DataGridView dataGridView, Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, string errorText, DataGridViewCellStyle inheritedRowStyle, bool isFirstDisplayedRow, bool isLastVisibleRow) {
45                         this.dataGridView = dataGridView;
46                         this.graphics = graphics;
47                         this.clipBounds = clipBounds;
48                         this.rowBounds = rowBounds;
49                         this.rowIndex = rowIndex;
50                         this.rowState = rowState;
51                         this.errorText = errorText;
52                         this.inheritedRowStyle = inheritedRowStyle;
53                         this.isFirstDisplayedRow = isFirstDisplayedRow;
54                         this.isLastVisibleRow = isLastVisibleRow;
55                 }
56
57                 public Rectangle ClipBounds {
58                         get { return clipBounds; }
59                         set { clipBounds = value; }
60                 }
61
62                 public string ErrorText {
63                         get { return errorText; }
64                 }
65
66                 public Graphics Graphics {
67                         get { return graphics; }
68                 }
69
70                 public DataGridViewCellStyle InheritedRowStyle {
71                         get { return inheritedRowStyle; }
72                 }
73
74                 public bool IsFirstDisplayedRow {
75                         get { return isFirstDisplayedRow; }
76                 }
77
78                 public bool IsLastVisibleRow {
79                         get { return isLastVisibleRow; }
80                 }
81
82                 public Rectangle RowBounds {
83                         get { return rowBounds; }
84                 }
85
86                 public int RowIndex {
87                         get { return rowIndex; }
88                 }
89
90                 public DataGridViewElementStates State {
91                         get { return rowState; }
92                 }
93
94                 public void DrawFocus (Rectangle bounds, bool cellsPaintSelectionBackground)
95                 {
96                         if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count)
97                                 throw new InvalidOperationException ("Invalid RowIndex.");
98
99                         DataGridViewRow row = dataGridView.GetRowInternal (rowIndex);
100
101                         row.PaintCells (graphics, clipBounds, bounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, DataGridViewPaintParts.Focus);
102                 }
103
104                 public void PaintCells (Rectangle clipBounds, DataGridViewPaintParts paintParts)
105                 {
106                         if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count)
107                                 throw new InvalidOperationException ("Invalid RowIndex.");
108
109                         DataGridViewRow row = dataGridView.GetRowInternal (rowIndex);
110
111                         row.PaintCells (graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, paintParts);
112                 }
113
114                 public void PaintCellsBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground)
115                 {
116                         if (cellsPaintSelectionBackground)
117                                 PaintCells (clipBounds, DataGridViewPaintParts.All);
118                         else
119                                 PaintCells (clipBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.SelectionBackground);
120                 }
121
122                 public void PaintCellsContent (Rectangle clipBounds)
123                 {
124                         PaintCells (clipBounds, DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground);
125                 }
126
127                 public void PaintHeader (bool paintSelectionBackground)
128                 {
129                         if (paintSelectionBackground)
130                                 PaintHeader (DataGridViewPaintParts.All);
131                         else
132                                 PaintHeader (DataGridViewPaintParts.All & ~DataGridViewPaintParts.SelectionBackground);
133                 }
134
135                 public void PaintHeader (DataGridViewPaintParts paintParts)
136                 {
137                         if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count)
138                                 throw new InvalidOperationException ("Invalid RowIndex.");
139
140                         DataGridViewRow row = dataGridView.GetRowInternal (rowIndex);
141
142                         row.PaintHeader (graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, paintParts);
143                 }
144         }
145 }