merge r67228-r67235, r67237, r67251 and r67256-67259 to trunk (they are
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewImageCell.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
27 #if NET_2_0
28
29 using System.Drawing;
30 using System.ComponentModel;
31
32 namespace System.Windows.Forms {
33
34         public class DataGridViewImageCell : DataGridViewCell {
35
36                 private object defaultNewRowValue;
37                 private string description;
38                 private DataGridViewImageCellLayout imageLayout;
39                 private bool valueIsIcon;
40
41                 public DataGridViewImageCell (bool valueIsIcon) {
42                         this.valueIsIcon = valueIsIcon;
43                         this.imageLayout = DataGridViewImageCellLayout.NotSet;
44                 }
45
46                 public DataGridViewImageCell () : this(false) {
47                 }
48
49                 public override object DefaultNewRowValue {
50                         get { return defaultNewRowValue; }
51                 }
52
53                 public string Description {
54                         get { return description; }
55                         set { description = value; }
56                 }
57
58                 public override Type EditType {
59                         get { return null; }
60                 }
61
62                 public override Type FormattedValueType {
63                         get { return (valueIsIcon)? typeof(Icon) : typeof(Image); }
64                 }
65
66                 public DataGridViewImageCellLayout ImageLayout {
67                         get { return imageLayout; }
68                         set {
69                                 if (!Enum.IsDefined(typeof(DataGridViewImageCellLayout), value)) {
70                                         throw new InvalidEnumArgumentException("Value is invalid image cell layout.");
71                                 }
72                                 imageLayout = value;
73                         }
74                 }
75
76                 public bool ValueIsIcon {
77                         get { return valueIsIcon; }
78                         set { valueIsIcon = value; }
79                 }
80
81                 public override Type ValueType {
82                         get {
83                                 if (base.ValueType != null) {
84                                         return base.ValueType;
85                                 }
86                                 if (OwningColumn != null) {
87                                         return OwningColumn.ValueType;
88                                 }
89                                 if (valueIsIcon) {
90                                         return typeof(Icon);
91                                 }
92                                 else {
93                                         return typeof(Image);
94                                 }
95                         }
96                         set { base.ValueType = value; }
97                 }
98
99                 public override object Clone () {
100                         DataGridViewImageCell cell = (DataGridViewImageCell) base.Clone();
101                         cell.defaultNewRowValue = this.defaultNewRowValue;
102                         cell.description = this.description;
103                         cell.valueIsIcon = this.valueIsIcon;
104                         return cell;
105                 }
106
107                 public override string ToString () {
108                         return GetType().Name;
109                 }
110
111                 protected override AccessibleObject CreateAccessibilityInstance () {
112                         return new DataGridViewImageCellAccessibleObject(this);
113                 }
114
115                 protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
116                         throw new NotImplementedException();
117                 }
118
119                 protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
120                         throw new NotImplementedException();
121                 }
122
123                 protected override object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
124                         throw new NotImplementedException();
125                 }
126
127                 protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
128                         throw new NotImplementedException();
129                 }
130
131                 protected override object GetValue (int rowIndex) {
132                         throw new NotImplementedException();
133                 }
134
135                 protected override void OnMouseEnter (int rowIndex) {
136                         throw new NotImplementedException();
137                 }
138
139                 protected override void OnMouseLeave (int rowIndex) {
140                         throw new NotImplementedException();
141                 }
142
143                 protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementeState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
144                         throw new NotImplementedException();
145                 }
146
147                 protected class DataGridViewImageCellAccessibleObject : DataGridViewCellAccessibleObject {
148
149                         public DataGridViewImageCellAccessibleObject (DataGridViewCell owner) : base(owner) {
150                         }
151
152                         public override string DefaultAction {
153                                 get { return ""; }
154                         }
155
156                         public override string Description {
157                                 get { return (Owner as DataGridViewImageCell).Description; }
158                         }
159
160                         public override void DoDefaultAction () {
161                                 // The DataGridViewImageCell has no default action.
162                         }
163
164                         public override int GetChildCount () {
165                                 return -1;
166                         }
167
168                 }
169
170         }
171
172 }
173
174 #endif