2008-04-23 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Wed, 23 Apr 2008 16:58:21 +0000 (16:58 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Wed, 23 Apr 2008 16:58:21 +0000 (16:58 -0000)
* DataGridViewColumnHeaderCell.cs: Implement some NIEX stuffs.

svn path=/trunk/mcs/; revision=101568

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs

index 9d6a2a00869eb0a9189a52faa8ff94c540082a31..63ebbff396147519ca33f3e95379f03bc256be31 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-23  Jonathan Pobst  <monkey@jpobst.com>
+
+       * DataGridViewColumnHeaderCell.cs: Implement some NIEX stuffs.
+
 2008-04-23  Andreia Gaita <avidigal@novell.com> 
 
        * HtmlElement.cs, HtmlDocument.cs: Implement javscript method
index 0ff545517a83a4e4a509ab0c3ca0aa510265fa41..ded0b150210bdfe722d16693278f0a8edc4d08c7 100644 (file)
@@ -135,12 +135,35 @@ namespace System.Windows.Forms {
                        
                }
 
-               protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
-                       return new Rectangle();
+               protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)
+               {
+                       if (DataGridView == null)
+                               return Rectangle.Empty;
+
+                       object o = GetValue (-1);
+                       
+                       if (o == null || o.ToString () == string.Empty)
+                               return Rectangle.Empty;
+                               
+                       Size s = Size.Empty;
+
+                       if (o != null)
+                               s = DataGridViewCell.MeasureTextSize (graphics, o.ToString (), cellStyle.Font, TextFormatFlags.Default);
+
+                       return new Rectangle (3, (DataGridView.ColumnHeadersHeight - s.Height) / 2, s.Width, s.Height);
                }
 
-               protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
-                       throw new NotImplementedException();
+               protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+               {
+                       object o = header_text;
+
+                       if (o != null) {
+                               Size s = DataGridViewCell.MeasureTextSize (graphics, o.ToString (), cellStyle.Font, TextFormatFlags.Default);
+                               s.Height = Math.Max (s.Height, 18);
+                               s.Width += 25;
+                               return s;
+                       } else
+                               return new Size (19, 12);
                }
 
                protected override object GetValue (int rowIndex) {