2008-03-06 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewButtonCell.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 #if NET_2_0
27
28 using System.Drawing;
29 using System.ComponentModel;
30
31 namespace System.Windows.Forms {
32
33         public class DataGridViewButtonCell : DataGridViewCell {
34
35                 private FlatStyle flatStyle;
36                 private bool useColumnTextForButtonValue;
37
38                 public DataGridViewButtonCell () {
39                         useColumnTextForButtonValue = false;
40                 }
41
42                 public override Type EditType {
43                         get { return null; }
44                 }
45
46                 [DefaultValue (FlatStyle.Standard)]
47                 public FlatStyle FlatStyle {
48                         get { return flatStyle; }
49                         set {
50                                 if (!Enum.IsDefined(typeof(FlatStyle), value)) {
51                                         throw new InvalidEnumArgumentException("Value is not valid FlatStyle.");
52                                 }
53                                 if (value == FlatStyle.Popup) {
54                                         throw new Exception("FlatStyle cannot be set to Popup in this control.");
55                                 }
56                         }
57                 }
58
59                 public override Type FormattedValueType {
60                         get { return base.FormattedValueType; }
61                 }
62
63                 [DefaultValue (false)]
64                 public bool UseColumnTextForButtonValue {
65                         get { return useColumnTextForButtonValue; }
66                         set { useColumnTextForButtonValue = value; }
67                 }
68
69                 public override Type ValueType {
70                         get { return base.ValueType; }
71                 }
72
73                 public override object Clone () {
74                         DataGridViewButtonCell result = (DataGridViewButtonCell) base.Clone();
75                         result.flatStyle = this.flatStyle;
76                         result.useColumnTextForButtonValue = this.useColumnTextForButtonValue;
77                         return result;
78                 }
79
80                 public override string ToString () {
81                         return GetType().Name + ": RowIndex: " + RowIndex.ToString() + "; ColumnIndex: " + ColumnIndex.ToString() + ";";
82                 }
83
84                 protected override AccessibleObject CreateAccessibilityInstance () {
85                         return new DataGridViewButtonCellAccessibleObject(this);
86                 }
87
88                 protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
89                         throw new NotImplementedException();
90                 }
91
92                 protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
93                         throw new NotImplementedException();
94                 }
95
96                 protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
97                         throw new NotImplementedException();
98                 }
99
100                 protected override object GetValue (int rowIndex) {
101                         throw new NotImplementedException();
102                 }
103
104                 protected override bool KeyDownUnsharesRow (KeyEventArgs e, int rowIndex) {
105                         // true if the user pressed the SPACE key without modifier keys; otherwise, false
106                         throw new NotImplementedException();
107                 }
108
109                 protected override bool KeyUpUnsharesRow (KeyEventArgs e, int rowIndex) {
110                         // true if the user released the SPACE key; otherwise false
111                         throw new NotImplementedException();
112
113                 }
114
115                 protected override bool MouseDownUnsharesRow (DataGridViewCellMouseEventArgs e) {
116                         return (e.Button == MouseButtons.Left);
117                 }
118
119                 protected override bool MouseEnterUnsharesRow (int rowIndex)
120                 {
121                         // true if the cell was the last cell receiving a mouse click; otherwise, false.
122                         throw new NotImplementedException();
123                 }
124
125                 protected override bool MouseLeaveUnsharesRow (int rowIndex)
126                 {
127                         // true if the button displayed by the cell is in the pressed state; otherwise, false.
128                         throw new NotImplementedException();
129                 }
130
131                 protected override bool MouseUpUnsharesRow (DataGridViewCellMouseEventArgs e)
132                 {
133                         // true if the mouse up was caused by the release of the left mouse button; otherwise false.
134                         throw new NotImplementedException();
135                 }
136
137                 protected override void OnKeyDown (KeyEventArgs e, int rowIndex)
138                 {
139                         // when activated by the SPACE key, this method updates the cell's user interface
140                         throw new NotImplementedException();
141                 }
142
143                 protected override void OnKeyUp (KeyEventArgs e, int rowIndex)
144                 {
145                         // when activated by the SPACE key, this method updates the cell's user interface
146                         throw new NotImplementedException();
147                 }
148
149                 protected override void OnLeave (int rowIndex, bool throughMouseClick)
150                 {
151                         throw new NotImplementedException();
152                 }
153
154                 protected override void OnMouseDown (DataGridViewCellMouseEventArgs e)
155                 {
156                         // if activated by depresing the left mouse button, this method updates the cell's user interface
157                         throw new NotImplementedException();
158                 }
159
160                 protected override void OnMouseLeave (int rowIndex)
161                 {
162                         // if the cell's button is not in its normal state, this method causes the cell's user interface to be updated.
163                         throw new NotImplementedException();
164                 }
165
166                 protected override void OnMouseMove (DataGridViewCellMouseEventArgs e)
167                 {
168                         throw new NotImplementedException ();
169                 }
170
171                 protected override void OnMouseUp (DataGridViewCellMouseEventArgs e)
172                 {
173                         // if activated by the left mouse button, this method updates the cell's user interface
174                         throw new NotImplementedException();
175                 }
176
177                 protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
178                         throw new NotImplementedException();
179                 }
180
181                 protected class DataGridViewButtonCellAccessibleObject : DataGridViewCellAccessibleObject {
182
183                         public DataGridViewButtonCellAccessibleObject (DataGridViewCell owner) : base(owner) {
184                         }
185
186                         public override string DefaultAction {
187                                 get {
188                                         if (Owner.ReadOnly) {
189                                                 return "Press";
190                                         }
191                                         else {
192                                                 return "";
193                                         }
194                                 }
195                         }
196
197                         public override void DoDefaultAction () {
198                                 // causes the button in the ButtonCell to be clicked
199                         }
200
201                         public override int GetChildCount () {
202                                 return -1;
203                         }
204
205                 }
206
207         }
208
209 }
210
211 #endif