Author: igorz
Date: 2006-10-05 08:44:39 -0400 (Thu, 05 Oct 2006)
New Revision: 66283

Modified:
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlField.cs
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs
Log:
2006-10-05 Igor Zelmanovich <[EMAIL PROTECTED]>

        * GridView.cs:
        * DataControlButton.cs:
        * DataControlField.cs:
        implemented PrepareControlHierarchy()
        styles are applied correct
        command buttons inherit ForeColor



Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2006-10-05 12:33:30 UTC (rev 66282)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2006-10-05 12:44:39 UTC (rev 66283)
@@ -1,5 +1,14 @@
 2006-10-05 Igor Zelmanovich <[EMAIL PROTECTED]>
 
+       * GridView.cs:
+       * DataControlButton.cs:
+       * DataControlField.cs:
+       implemented PrepareControlHierarchy()
+       styles are applied correct
+       command buttons inherit ForeColor
+
+2006-10-05 Igor Zelmanovich <[EMAIL PROTECTED]>
+
        * WebControl.cs: fixed: CreateControlStyle()
 
 2006-10-04 Igor Zelmanovich <[EMAIL PROTECTED]>

Modified: 
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs   
2006-10-05 12:33:30 UTC (rev 66282)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs   
2006-10-05 12:44:39 UTC (rev 66283)
@@ -33,6 +33,7 @@
 using System.Web.UI;
 using System.ComponentModel;
 using System.ComponentModel.Design;
+using System.Drawing;
 
 namespace System.Web.UI.WebControls
 {
@@ -90,6 +91,10 @@
 
                protected internal override void Render (HtmlTextWriter writer)
                {
+                       if (CommandName.Length > 0 && ButtonType == 
ButtonType.Link) {
+                               EnsureForeColor ();
+                       }
+
                        if (CommandName.Length > 0 || ButtonType == 
ButtonType.Button)
                        {
                                string postScript = null;
@@ -173,6 +178,21 @@
                                }
                        }
                }
+
+               private void EnsureForeColor () {
+                       if (ForeColor != Color.Empty)
+                               return;
+
+                       for (Control parent = Parent; parent != null; parent = 
parent.Parent) {
+                               WebControl wc = parent as WebControl;
+                               if (wc != null && wc.ForeColor != Color.Empty) {
+                                       ForeColor = wc.ForeColor;
+                                       break;
+                               }
+                               if (parent == container)
+                                       break;
+                       }
+               }
        }
 }
 

Modified: 
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlField.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlField.cs    
2006-10-05 12:33:30 UTC (rev 66282)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlField.cs    
2006-10-05 12:44:39 UTC (rev 66283)
@@ -204,6 +204,14 @@
                        return new System.NotSupportedException ("The property 
'" + propName + "' is not supported in " + GetType().Name); 
                }
 
+               internal bool ControlStyleCreated { get { return controlStyle 
!= null; } }
+               
+               internal bool HeaderStyleCreated { get { return headerStyle != 
null; } }
+               
+               internal bool FooterStyleCreated { get { return footerStyle != 
null; } }
+               
+               internal bool ItemStyleCreated { get { return itemStyle != 
null; } }
+
                [MonoTODO ("Render this")]
                [DefaultValueAttribute ("")]
                [LocalizableAttribute (true)]

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs    
2006-10-05 12:33:30 UTC (rev 66282)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs    
2006-10-05 12:44:39 UTC (rev 66283)
@@ -974,7 +974,6 @@
                protected virtual ICollection CreateColumns (PagedDataSource 
dataSource, bool useDataSource)
                {
                        ArrayList fields = new ArrayList ();
-                       fields.AddRange (Columns);
                        
                        if (AutoGenerateEditButton || AutoGenerateDeleteButton 
|| AutoGenerateSelectButton) {
                                CommandField field = new CommandField ();
@@ -983,6 +982,8 @@
                                field.ShowSelectButton = 
AutoGenerateSelectButton;
                                fields.Add (field);
                        }
+
+                       fields.AddRange (Columns);
                        
                        if (AutoGenerateColumns) {
                                if (useDataSource)
@@ -1350,10 +1351,75 @@
                        base.PerformDataBinding (data);
                }
 
-               [MonoTODO]
                protected internal virtual void PrepareControlHierarchy ()
                {
-                       throw new NotImplementedException ();
+                       if (table == null)
+                               return;
+                       
+                       table.Caption = Caption;
+                       table.CaptionAlign = CaptionAlign;
+                       
+                       foreach (GridViewRow row in table.Rows) {
+                               switch (row.RowType) {
+                               case DataControlRowType.Header:
+                                       if (headerStyle != null && 
!headerStyle.IsEmpty)
+                                               
row.ControlStyle.CopyFrom(headerStyle);
+                                       row.Visible = ShowHeader;
+                                       break;
+                               case DataControlRowType.Footer:
+                                       if (footerStyle != null && 
!footerStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(footerStyle);
+                                       row.Visible = ShowFooter;
+                                       break;
+                               case DataControlRowType.Pager:
+                                       if (pagerStyle != null && 
!pagerStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(pagerStyle);
+                                       break;
+                               case DataControlRowType.EmptyDataRow:
+                                       if (emptyDataRowStyle != null && 
!emptyDataRowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(emptyDataRowStyle);
+                                       break;
+                               case DataControlRowType.DataRow:
+                                       if (rowStyle != null && 
!rowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(rowStyle);
+                                       if ((row.RowState & 
DataControlRowState.Alternate) != 0 && alternatingRowStyle != null && 
!alternatingRowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(alternatingRowStyle);
+                                       if ((row.RowState & 
DataControlRowState.Selected) != 0 && selectedRowStyle != null && 
!selectedRowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(selectedRowStyle);
+                                       if ((row.RowState & 
DataControlRowState.Edit) != 0 && editRowStyle != null && !editRowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(editRowStyle);
+                                       break;
+                               default:
+                                       break;
+                               }
+
+                               foreach (TableCell cell in row.Cells) {
+                                       DataControlFieldCell fcell = cell as 
DataControlFieldCell;
+                                       if (fcell != null) {
+                                               DataControlField field = 
fcell.ContainingField;
+                                               switch (row.RowType) {
+                                               case DataControlRowType.Header:
+                                                       if 
(field.HeaderStyleCreated && !field.HeaderStyle.IsEmpty)
+                                                               
cell.ControlStyle.CopyFrom (field.HeaderStyle);
+                                                       break;
+                                               case DataControlRowType.Footer:
+                                                       if 
(field.FooterStyleCreated && !field.FooterStyle.IsEmpty)
+                                                               
cell.ControlStyle.CopyFrom (field.FooterStyle);
+                                                       break;
+                                               default:
+                                                       if 
(field.ControlStyleCreated && !field.ControlStyle.IsEmpty)
+                                                               foreach 
(Control c in cell.Controls) {
+                                                                       
WebControl wc = c as WebControl;
+                                                                       if (wc 
!= null)
+                                                                               
wc.ControlStyle.MergeWith (field.ControlStyle);
+                                                               }
+                                                       if 
(field.ItemStyleCreated && !field.ItemStyle.IsEmpty)
+                                                               
cell.ControlStyle.CopyFrom (field.ItemStyle);
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
                }
                
                protected internal override void OnInit (EventArgs e)
@@ -1812,6 +1878,8 @@
 
                protected internal override void Render (HtmlTextWriter writer)
                {
+                       PrepareControlHierarchy ();
+
                        if (EnableSortingAndPagingCallbacks)
                                writer.AddAttribute 
(HtmlTextWriterAttribute.Id, ClientID);
                        writer.RenderBeginTag (HtmlTextWriterTag.Div);
@@ -1826,59 +1894,7 @@
                        if (table == null)
                                return;
 
-                       table.Caption = Caption;
-                       table.CaptionAlign = CaptionAlign;
-                       table.RenderBeginTag (writer);
-                       
-                       foreach (GridViewRow row in table.Rows)
-                       {
-                               switch (row.RowType) {
-                               case DataControlRowType.Header:
-                                       if (!ShowHeader) continue;
-                                       if (headerStyle != 
null)headerStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               case DataControlRowType.Footer:
-                                       if (!ShowFooter) continue;
-                                       if (footerStyle != null) 
footerStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               case DataControlRowType.Pager:
-                                       if (pagerStyle != null) 
pagerStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               case DataControlRowType.EmptyDataRow:
-                                       if (emptyDataRowStyle != null) 
emptyDataRowStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               default:
-                                       break;
-                               }
-
-                               if ((row.RowState & DataControlRowState.Normal) 
!= 0 && rowStyle != null)
-                                       rowStyle.AddAttributesToRender (writer, 
row);
-                               if ((row.RowState & 
DataControlRowState.Alternate) != 0 && alternatingRowStyle != null)
-                                       
alternatingRowStyle.AddAttributesToRender (writer, row);
-                               if ((row.RowState & DataControlRowState.Edit) 
!= 0 && editRowStyle != null)
-                                       editRowStyle.AddAttributesToRender 
(writer, row);
-                               if ((row.RowState & 
DataControlRowState.Selected) != 0 && selectedRowStyle != null)
-                                       selectedRowStyle.AddAttributesToRender 
(writer, row);
-                               
-                               row.RenderBeginTag (writer);
-                               
-                               foreach (TableCell cell in row.Cells) {
-                                       DataControlFieldCell fcell = cell as 
DataControlFieldCell;
-                                       if (fcell != null) {
-                                               Style cellStyle = null;
-                                               switch (row.RowType) {
-                                               case DataControlRowType.Header: 
cellStyle = fcell.ContainingField.HeaderStyle; break;
-                                               case DataControlRowType.Footer: 
cellStyle = fcell.ContainingField.FooterStyle; break;
-                                               default: cellStyle = 
fcell.ContainingField.ItemStyle; break;
-                                               }
-                                               if (cellStyle != null)
-                                                       
cellStyle.AddAttributesToRender (writer, cell);
-                                       }
-                                       cell.Render (writer);
-                               }
-                               row.RenderEndTag (writer);
-                       }
-                       table.RenderEndTag (writer);
+                       table.Render (writer);
                }
 
                [MonoTODO]

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to