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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Jordi Mas i Hernandez <jordi@ximian.com>
29 using System.ComponentModel;
31 using System.Runtime.InteropServices;
32 using System.Diagnostics;
34 namespace System.Windows.Forms
36 public abstract class DataGridColumnStyle : Component, IDataGridColumnStyleEditingNotificationService
39 protected class DataGridColumnHeaderAccessibleObject : AccessibleObject
41 #region Local Variables
42 private DataGridColumnStyle owner;
46 public DataGridColumnHeaderAccessibleObject (DataGridColumnStyle columnstyle)
50 #endregion //Constructors
52 #region Public Instance Properties
54 public override Rectangle Bounds {
56 throw new NotImplementedException ();
60 public override string Name {
62 throw new NotImplementedException ();
66 protected DataGridColumnStyle Owner {
70 public override AccessibleObject Parent {
72 throw new NotImplementedException ();
76 public override AccessibleRole Role {
78 throw new NotImplementedException ();
83 #region Public Instance Methods
85 public override AccessibleObject Navigate (AccessibleNavigation navdir)
87 throw new NotImplementedException ();
89 #endregion Public Instance Methods
92 protected class CompModSwitches
94 public CompModSwitches ()
98 #region Public Instance Methods
100 public static TraceSwitch DGEditColumnEditing {
102 throw new NotImplementedException ();
105 #endregion Public Instance Methods
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;
118 private DataGridColumnHeaderAccessibleObject accesible_object;
119 #endregion // Local Variables
122 public DataGridColumnStyle ()
124 CommmonConstructor ();
125 property_descriptor = null;
128 public DataGridColumnStyle (PropertyDescriptor prop)
130 CommmonConstructor ();
131 property_descriptor = prop;
134 private void CommmonConstructor ()
138 header_text = string.Empty;
139 mapping_name = "(null)";
140 null_text = string.Empty;
141 accesible_object = new DataGridColumnHeaderAccessibleObject (this);
144 alignment = HorizontalAlignment.Left;
149 #region Public Instance Properties
150 public virtual HorizontalAlignment Alignment {
155 if (value != alignment) {
158 if (AlignmentChanged != null) {
159 AlignmentChanged (this, EventArgs.Empty);
165 public virtual DataGridTableStyle DataGridTableStyle {
171 protected int FontHeight {
173 if (fontheight != -1) {
177 if (table_style != null) {
178 //return table_style.DataGrid.FontHeight
182 // TODO: Default Datagrid font height
187 public AccessibleObject HeaderAccessibleObject {
189 return accesible_object;
193 public virtual string HeaderText {
198 if (value != header_text) {
201 if (HeaderTextChanged != null) {
202 HeaderTextChanged (this, EventArgs.Empty);
208 public string MappingName {
213 if (value != mapping_name) {
214 mapping_name = value;
216 if (MappingNameChanged != null) {
217 MappingNameChanged (this, EventArgs.Empty);
223 public virtual string NullText {
228 if (value != null_text) {
231 if (NullTextChanged != null) {
232 NullTextChanged (this, EventArgs.Empty);
238 public virtual PropertyDescriptor PropertyDescriptor {
240 return property_descriptor;
243 if (value != property_descriptor) {
244 property_descriptor = value;
246 if (PropertyDescriptorChanged != null) {
247 PropertyDescriptorChanged (this, EventArgs.Empty);
253 public virtual bool ReadOnly {
258 if (value != read_only) {
261 if (ReadOnlyChanged != null) {
262 ReadOnlyChanged (this, EventArgs.Empty);
268 public virtual int Width {
273 if (value != width) {
276 if (WidthChanged != null) {
277 WidthChanged (this, EventArgs.Empty);
283 #endregion // Public Instance Properties
285 #region Private Instance Properties
286 internal DataGridTableStyle TableStyle {
287 set { table_style = value; }
289 #endregion Private Instance Properties
291 #region Public Instance Methods
292 protected internal abstract void Abort (int rowNum);
295 protected void BeginUpdate ()
301 protected void CheckValidDataSource (CurrencyManager value)
307 protected internal virtual void ColumnStartedEditing (Control editingControl)
312 protected internal abstract bool Commit (CurrencyManager dataSource, int rowNum);
315 protected internal virtual void ConcedeFocus ()
321 protected virtual AccessibleObject CreateHeaderAccessibleObject ()
323 throw new NotImplementedException ();
327 protected internal virtual void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly)
333 protected internal virtual void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText)
338 protected internal abstract void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible);
342 protected void EndUpdate ()
347 protected internal virtual void EnterNullValue ()
353 protected internal virtual object GetColumnValueAtRow (CurrencyManager source, int rowNum)
355 throw new NotImplementedException ();
358 protected internal abstract int GetMinimumHeight ();
360 protected internal abstract int GetPreferredHeight (Graphics g, object value);
362 protected internal abstract Size GetPreferredSize (Graphics g, object value);
364 void IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing (Control editingControl)
369 protected virtual void Invalidate ()
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);
378 protected internal virtual void Paint (Graphics g, Rectangle bounds, CurrencyManager source, int rowNum,
379 Brush backBrush, Brush foreBrush, bool alignToRight)
384 protected internal virtual void ReleaseHostedControl ()
389 public void ResetHeaderText ()
391 HeaderText = string.Empty;
394 protected internal virtual void SetColumnValueAtRow (CurrencyManager source, int rowNum, object value)
399 protected virtual void SetDataGrid (DataGrid value)
404 protected virtual void SetDataGridInColumn (DataGrid value)
409 protected internal virtual void UpdateUI (CurrencyManager source, int rowNum, string instantText)
414 #endregion // Public Instance Methods
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;