* Test/System.Windows.Forms/DataGridViewCellTest.cs: Added
[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                 [DefaultValue ("")]
54                 public string Description {
55                         get { return description; }
56                         set { description = value; }
57                 }
58
59                 public override Type EditType {
60                         get { return null; }
61                 }
62
63                 public override Type FormattedValueType {
64                         get { return (valueIsIcon)? typeof(Icon) : typeof(Image); }
65                 }
66
67                 [DefaultValue (DataGridViewImageCellLayout.NotSet)]
68                 public DataGridViewImageCellLayout ImageLayout {
69                         get { return imageLayout; }
70                         set {
71                                 if (!Enum.IsDefined(typeof(DataGridViewImageCellLayout), value)) {
72                                         throw new InvalidEnumArgumentException("Value is invalid image cell layout.");
73                                 }
74                                 imageLayout = value;
75                         }
76                 }
77
78                 [DefaultValue (false)]
79                 public bool ValueIsIcon {
80                         get { return valueIsIcon; }
81                         set { valueIsIcon = value; }
82                 }
83
84                 public override Type ValueType {
85                         get {
86                                 if (base.ValueType != null) {
87                                         return base.ValueType;
88                                 }
89                                 if (OwningColumn != null) {
90                                         return OwningColumn.ValueType;
91                                 }
92                                 if (valueIsIcon) {
93                                         return typeof(Icon);
94                                 }
95                                 else {
96                                         return typeof(Image);
97                                 }
98                         }
99                         set { base.ValueType = value; }
100                 }
101
102                 public override object Clone () {
103                         DataGridViewImageCell cell = (DataGridViewImageCell) base.Clone();
104                         cell.defaultNewRowValue = this.defaultNewRowValue;
105                         cell.description = this.description;
106                         cell.valueIsIcon = this.valueIsIcon;
107                         return cell;
108                 }
109
110                 public override string ToString () {
111                         return GetType().Name;
112                 }
113
114                 protected override AccessibleObject CreateAccessibilityInstance () {
115                         return new DataGridViewImageCellAccessibleObject(this);
116                 }
117
118                 protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
119                         throw new NotImplementedException();
120                 }
121
122                 protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
123                         throw new NotImplementedException();
124                 }
125
126                 protected override object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
127                         throw new NotImplementedException();
128                 }
129
130                 protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
131                         throw new NotImplementedException();
132                 }
133
134                 protected override object GetValue (int rowIndex) {
135                         throw new NotImplementedException();
136                 }
137
138                 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) {
139                         throw new NotImplementedException();
140                 }
141
142                 protected class DataGridViewImageCellAccessibleObject : DataGridViewCellAccessibleObject {
143
144                         public DataGridViewImageCellAccessibleObject (DataGridViewCell owner) : base(owner) {
145                         }
146
147                         public override string DefaultAction {
148                                 get { return ""; }
149                         }
150
151                         public override string Description {
152                                 get { return (Owner as DataGridViewImageCell).Description; }
153                         }
154
155                         public override void DoDefaultAction () {
156                                 // The DataGridViewImageCell has no default action.
157                         }
158
159                         public override int GetChildCount () {
160                                 return -1;
161                         }
162
163                 }
164
165         }
166
167 }
168
169 #endif