updating to the latest module.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridColumnStyle.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 //      Jordi Mas i Hernandez <jordi@ximian.com>
24 //
25 //
26
27 // NOT COMPLETE
28
29 using System.ComponentModel;
30 using System.Drawing;
31 using System.Runtime.InteropServices;
32 using System.Diagnostics;
33
34 namespace System.Windows.Forms
35 {
36         public abstract class DataGridColumnStyle : Component, IDataGridColumnStyleEditingNotificationService
37         {
38                 [ComVisible(true)]
39                 protected class DataGridColumnHeaderAccessibleObject : AccessibleObject
40                 {
41                         #region Local Variables
42                         private DataGridColumnStyle owner;
43                         #endregion
44
45                         #region Constructors
46                         public DataGridColumnHeaderAccessibleObject (DataGridColumnStyle columnstyle)
47                         {
48                                 owner = columnstyle;
49                         }
50                         #endregion //Constructors
51
52                         #region Public Instance Properties
53                         [MonoTODO]
54                         public override Rectangle Bounds {
55                                 get {
56                                         throw new NotImplementedException ();
57                                 }
58                         }
59
60                         public override string Name {
61                                 get {
62                                         throw new NotImplementedException ();
63                                 }
64                         }
65
66                         protected DataGridColumnStyle Owner {
67                                 get { return owner; }
68                         }
69
70                         public override AccessibleObject Parent {
71                                 get {
72                                         throw new NotImplementedException ();
73                                 }
74                         }
75
76                         public override AccessibleRole Role {
77                                 get {
78                                         throw new NotImplementedException ();
79                                 }
80                         }
81                         #endregion
82
83                         #region Public Instance Methods
84                         [MonoTODO]
85                         public override AccessibleObject Navigate (AccessibleNavigation navdir)
86                         {
87                                 throw new NotImplementedException ();
88                         }
89                         #endregion Public Instance Methods
90                 }
91
92                 protected class CompModSwitches
93                 {
94                         public CompModSwitches ()
95                         {
96                         }
97
98                         #region Public Instance Methods
99                         [MonoTODO]
100                         public static TraceSwitch DGEditColumnEditing {
101                                 get {
102                                         throw new NotImplementedException ();
103                                 }
104                         }
105                         #endregion Public Instance Methods
106                 }
107
108                 #region Local Variables
109                 private HorizontalAlignment alignment;
110                 private int fontheight;
111                 private DataGridTableStyle table_style;
112                 private string header_text;
113                 private string mapping_name;
114                 private string null_text;
115                 private PropertyDescriptor property_descriptor;
116                 private bool read_only;
117                 private int width;
118                 private DataGridColumnHeaderAccessibleObject accesible_object;
119                 #endregion      // Local Variables
120
121                 #region Constructors
122                 public DataGridColumnStyle ()
123                 {
124                         CommmonConstructor ();
125                         property_descriptor = null;
126                 }
127
128                 public DataGridColumnStyle (PropertyDescriptor prop)
129                 {
130                         CommmonConstructor ();
131                         property_descriptor = prop;
132                 }
133
134                 private void CommmonConstructor ()
135                 {
136                         fontheight = -1;
137                         table_style = null;
138                         header_text = string.Empty;
139                         mapping_name  = "(null)";
140                         null_text = string.Empty;
141                         accesible_object = new DataGridColumnHeaderAccessibleObject (this);
142                         read_only = false;
143                         width = -1;
144                         alignment = HorizontalAlignment.Left;
145                 }
146
147                 #endregion
148
149                 #region Public Instance Properties
150                 public virtual HorizontalAlignment Alignment {
151                         get {
152                                 return alignment;
153                         }
154                         set {
155                                 if (value != alignment) {
156                                         alignment = value;
157
158                                         if (AlignmentChanged != null) {
159                                                 AlignmentChanged (this, EventArgs.Empty);
160                                         }
161                                 }
162                         }
163                 }
164
165                 public virtual DataGridTableStyle DataGridTableStyle {
166                         get {
167                                 return table_style;
168                         }                       
169                 }
170                 
171                 protected int FontHeight {
172                         get {
173                                 if (fontheight != -1) {
174                                         return fontheight;
175                                 }
176
177                                 if (table_style != null) {
178                                         //return table_style.DataGrid.FontHeight
179                                         return -1;
180                                 }
181
182                                 // TODO: Default Datagrid font height
183                                 return -1;
184                         }
185                 }
186
187                 public AccessibleObject HeaderAccessibleObject {
188                         get {
189                                 return accesible_object;
190                         }
191                 }
192
193                 public virtual string HeaderText {
194                         get {
195                                 return header_text;
196                         }
197                         set {
198                                 if (value != header_text) {
199                                         header_text = value;
200
201                                         if (HeaderTextChanged != null) {
202                                                 HeaderTextChanged (this, EventArgs.Empty);
203                                         }
204                                 }
205                         }
206                 }
207
208                 public string MappingName {
209                         get {
210                                 return mapping_name;
211                         }
212                         set {
213                                 if (value != mapping_name) {
214                                         mapping_name = value;
215
216                                         if (MappingNameChanged != null) {
217                                                 MappingNameChanged (this, EventArgs.Empty);
218                                         }
219                                 }
220                         }
221                 }
222
223                 public virtual string NullText {
224                         get {
225                                 return null_text;
226                         }
227                         set {
228                                 if (value != null_text) {
229                                         null_text = value;
230
231                                         if (NullTextChanged != null) {
232                                                 NullTextChanged (this, EventArgs.Empty);
233                                         }
234                                 }
235                         }
236                 }
237
238                 public virtual PropertyDescriptor PropertyDescriptor {
239                         get {
240                                 return property_descriptor;
241                         }
242                         set {
243                                 if (value != property_descriptor) {
244                                         property_descriptor = value;
245
246                                         if (PropertyDescriptorChanged != null) {
247                                                 PropertyDescriptorChanged (this, EventArgs.Empty);
248                                         }
249                                 }
250                         }
251                 }
252
253                 public virtual bool ReadOnly  {
254                         get {
255                                 return read_only;
256                         }
257                         set {
258                                 if (value != read_only) {
259                                         read_only = value;
260
261                                         if (ReadOnlyChanged != null) {
262                                                 ReadOnlyChanged (this, EventArgs.Empty);
263                                         }
264                                 }
265                         }
266                 }
267
268                 public virtual int Width {
269                         get {
270                                 return width;
271                         }
272                         set {
273                                 if (value != width) {
274                                         width = value;
275
276                                         if (WidthChanged != null) {
277                                                 WidthChanged (this, EventArgs.Empty);
278                                         }
279                                 }
280                         }
281                 }
282
283                 #endregion      // Public Instance Properties
284                 
285                 #region Private Instance Properties
286                 internal DataGridTableStyle TableStyle {                
287                         set { table_style = value; }                    
288                 }
289                 #endregion Private Instance Properties
290
291                 #region Public Instance Methods
292                 protected internal abstract void Abort (int rowNum);
293
294                 [MonoTODO]
295                 protected void BeginUpdate ()
296                 {
297
298                 }
299
300                 [MonoTODO]
301                 protected void CheckValidDataSource (CurrencyManager value)
302                 {
303
304                 }
305
306                 [MonoTODO]
307                 protected internal virtual void ColumnStartedEditing (Control editingControl)
308                 {
309
310                 }
311
312                 protected internal abstract bool Commit (CurrencyManager dataSource, int rowNum);
313
314
315                 protected internal virtual void ConcedeFocus ()
316                 {
317
318                 }
319
320                 [MonoTODO]
321                 protected virtual AccessibleObject CreateHeaderAccessibleObject ()
322                 {
323                         throw new NotImplementedException ();
324                 }
325
326
327                 protected internal virtual void Edit (CurrencyManager source, int rowNum,  Rectangle bounds,  bool readOnly)
328                 {
329
330                 }
331
332                 [MonoTODO]
333                 protected internal virtual void Edit (CurrencyManager source, int rowNum, Rectangle bounds,  bool readOnly,   string instantText)
334                 {
335
336                 }
337
338                 protected internal abstract void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly,   string instantText,  bool cellIsVisible);
339
340
341                 [MonoTODO]
342                 protected void EndUpdate ()
343                 {
344
345                 }
346
347                 protected internal virtual void EnterNullValue ()
348                 {
349
350                 }
351
352                 [MonoTODO]
353                 protected internal virtual object GetColumnValueAtRow (CurrencyManager source, int rowNum)
354                 {
355                         throw new NotImplementedException ();
356                 }
357
358                 protected internal abstract int GetMinimumHeight ();
359
360                 protected internal abstract int GetPreferredHeight (Graphics g, object value);
361
362                 protected internal abstract Size GetPreferredSize (Graphics g,  object value);
363
364                 void  IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing (Control editingControl)
365                 {
366
367                 }
368
369                 protected virtual void Invalidate ()
370                 {
371
372                 }
373
374                 protected internal abstract void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum);
375                 protected internal abstract void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, bool alignToRight);
376
377                 [MonoTODO]
378                 protected internal virtual void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum,
379                         Brush backBrush,  Brush foreBrush, bool alignToRight)
380                 {
381
382                 }
383
384                 protected internal virtual void ReleaseHostedControl ()
385                 {
386
387                 }
388
389                 public void ResetHeaderText ()
390                 {
391                         HeaderText = string.Empty;
392                 }
393
394                 protected internal virtual void SetColumnValueAtRow (CurrencyManager source, int rowNum,  object value)
395                 {
396
397                 }
398
399                 protected virtual void SetDataGrid (DataGrid value)
400                 {
401
402                 }
403
404                 protected virtual void SetDataGridInColumn (DataGrid value)
405                 {
406
407                 }
408
409                 protected internal virtual void UpdateUI (CurrencyManager source, int rowNum, string instantText)
410                 {
411
412                 }
413
414                 #endregion      // Public Instance Methods
415
416
417                 #region Events
418                 public event EventHandler AlignmentChanged;
419                 public event EventHandler FontChanged;
420                 public event EventHandler HeaderTextChanged;
421                 public event EventHandler MappingNameChanged;
422                 public event EventHandler NullTextChanged;
423                 public event EventHandler PropertyDescriptorChanged;
424                 public event EventHandler ReadOnlyChanged;
425                 public event EventHandler WidthChanged;
426                 #endregion      // Events
427         }
428 }