Hi, Gonzalo & everyone.

Attached is a patch for enabling accessibility features in System.Web. Most of 
the features
were implemented in Mono under the NET_2_0 profile but are actually part of the
.Net framework 1.1 (some maybe in a hotfix or service pack 1 for .Net 1.1).
Please review the attached. It was tested with Grasshopper and is now 
integrated into Mono.
BTW, is it good practice to use '#if NET 1_1' or one should simply stop using 
it and assume
Mono is for 1.1 and up?

Eyal.
Index: Table.cs

===================================================================

--- Table.cs    (revision 47365)

+++ Table.cs    (working copy)

@@ -97,7 +97,7 @@

                        set { ((TableStyle) ControlStyle).BackImageUrl = value; 
}

                }

 
-#if NET_2_0

+#if NET_1_1

                [DefaultValue (""), WebCategory ("Accessibility"), Localizable 
(true)]

                public virtual string Caption

                {

@@ -227,12 +227,13 @@

                        return new TableStyle (ViewState);

                }

                

-#if NET_2_0

+#if NET_1_1

        public override void RenderBeginTag (HtmlTextWriter writer)

                {

                        base.RenderBeginTag (writer);

                        if (Caption != "") {

-                               writer.AddAttribute ("align", 
CaptionAlign.ToString());

+                               if (CaptionAlign != TableCaptionAlign.NotSet)   
                        

+                                       
writer.AddAttribute(HtmlTextWriterAttribute.Align, CaptionAlign.ToString());

                                writer.RenderBeginTag 
(HtmlTextWriterTag.Caption);

                                writer.Write (Caption);

                                writer.RenderEndTag ();

Index: Label.cs

===================================================================

--- Label.cs    (revision 47365)

+++ Label.cs    (working copy)

@@ -72,12 +72,14 @@

                        set { ViewState ["Text"] = value; }

                }

                

-#if NET_2_0

+#if NET_1_1

+               [WebCategory ("Accessibility")]

+               [DefaultValueAttribute ("")]

+#if NET_2_0
                [ThemeableAttribute (false)]

-               [DefaultValueAttribute ("")]

                [IDReferencePropertyAttribute (typeof(System.Web.UI.Control))]

-               [WebCategory ("Accessibility")]

                [TypeConverterAttribute (typeof(AssociatedControlConverter))]

+#endif
                public string AssociatedControlID

                {

                        get {

Index: Image.cs

===================================================================

--- Image.cs    (revision 47365)

+++ Image.cs    (working copy)

@@ -129,11 +129,13 @@

                        }

                }

                

-#if NET_2_0

+#if NET_1_1

                [WebCategory ("Accessibility")]

                [DefaultValueAttribute ("")]

+#if NET_2_0
                [UrlPropertyAttribute]

                [EditorAttribute ("System.Web.UI.Design.UrlEditor, 
System.Design, Version=2.0.3600.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, 
System.Drawing, Version=2.0.3600.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a")]

+#endif
                public string DescriptionUrl {

                        get {

                                object o = ViewState["DescriptionUrl"];

@@ -170,9 +172,9 @@

                                
writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveUrl(ImageUrl));

                        }

 

-#if NET_2_0

+#if NET_1_1

                        if (DescriptionUrl.Length > 0)

-                               writer.AddAttribute 
(HtmlTextWriterAttribute.Longdesc, DescriptionUrl);

+                               writer.AddAttribute ("longdesc", 
DescriptionUrl);

                                

                        if (AlternateText.Length > 0 || 
GenerateEmptyAlternateText)

                                
writer.AddAttribute(HtmlTextWriterAttribute.Alt, AlternateText);

Index: BaseDataList.cs

===================================================================

--- BaseDataList.cs     (revision 47365)

+++ BaseDataList.cs     (working copy)

@@ -479,5 +479,29 @@

                                        return null; 
                        }
                #endif
+
+#if NET_1_1
+               public virtual TableCaptionAlign CaptionAlign
+               {
+                       get 
+                       {
+                               object o = ViewState ["CaptionAlign"];
+                               return (o == null) ? TableCaptionAlign.NotSet : 
(TableCaptionAlign) o;
+                       }
+
+                       set { ViewState ["CaptionAlign"] = value; }
+               }
+
+               public virtual bool UseAccessibleHeader
+               {
+                       get 
+                       {
+                               object o = ViewState ["UseAccessibleHeader"];
+                               return (o == null) ? false : (Boolean) o;
+                       }
+
+                       set { ViewState ["UseAccessibleHeader"] = value; }
+               }
+#endif
        }
 }
Index: DataList.cs

===================================================================

--- DataList.cs (revision 47365)

+++ DataList.cs (working copy)

@@ -744,11 +744,20 @@

                                templateTable.ID = ClientID;
                                templateTable.CopyBaseAttributes (this);
                                templateTable.ApplyStyle (ControlStyle);
+#if NET_1_1
+                               templateTable.CaptionAlign = CaptionAlign;
+                               templateTable.Caption = Caption;
+#endif
                                templateTable.RenderBeginTag (writer);
                        } else {
                                repeater.RepeatDirection = RepeatDirection;
                                repeater.RepeatLayout = RepeatLayout;
                                repeater.RepeatColumns = RepeatColumns;
+#if NET_1_1
+                               repeater.CaptionAlign = CaptionAlign;
+                               repeater.Caption = Caption;
+                               repeater.UseAccessibleHeader = 
UseAccessibleHeader;
+#endif
                        }
 
                        repeater.RenderRepeater (writer, this, ControlStyle, 
this);
Index: RepeatInfo.cs

===================================================================

--- RepeatInfo.cs       (revision 47365)

+++ RepeatInfo.cs       (working copy)

@@ -45,6 +45,11 @@

                private int             repeatColumns;

                private RepeatDirection repeatDirection;

                private RepeatLayout    repeatLayout;

+#if NET_1_1

+               private string caption = "";

+               private TableCaptionAlign captionAlign = 
TableCaptionAlign.NotSet;

+               private  bool useAccessibleHeader = false;

+#endif

 

                public RepeatInfo()

                {

@@ -144,6 +149,13 @@

                                if(RepeatLayout == RepeatLayout.Table)

                                {

                                        ctrl = new Table();

+#if NET_1_1

+                                       if (Caption.Length != 0)

+                                       {

+                                               ((Table) ctrl).CaptionAlign = 
CaptionAlign;

+                                               ((Table) ctrl).Caption = 
Caption;                                               

+                                       }

+#endif

                                        isTable = true;

                                } else

                                {

@@ -173,12 +185,24 @@

                                                        colSpan += colsCount;

                                                
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, 
colSpan.ToString(NumberFormatInfo.InvariantInfo));

                                        }

+#if NET_1_1

+                                       if (UseAccessibleHeader)                
                        

+                                               writer.AddAttribute("scope", 
"col", false);

+ 

+#endif

                                        itemStyle = 
user.GetItemStyle(ListItemType.Header, -1);

                                        if(itemStyle != null)

                                        {

                                                
itemStyle.AddAttributesToRender(writer);

                                        }

+#if NET_1_1

+                                       if (UseAccessibleHeader)

+                                               
writer.RenderBeginTag(HtmlTextWriterTag.Th);

+                                       else

+                                               
writer.RenderBeginTag(HtmlTextWriterTag.Td);

+#else

                                        
writer.RenderBeginTag(HtmlTextWriterTag.Td);

+#endif

                                }

                                user.RenderItem(ListItemType.Header, -1, this, 
writer);

                                if(isTable)

@@ -302,7 +326,19 @@

                        bool hasSeps = user.HasSeparators;

                        if (!outerTableImp){

                                isTable = (RepeatLayout == RepeatLayout.Table);

-                               ctrl = (isTable) ? new Table () : new 
WebControl (HtmlTextWriterTag.Span);

+                               if (isTable)

+                               {

+                                       ctrl = new Table ();

+#if NET_1_1

+                                       if (Caption.Length != 0)

+                                       {

+                                               ((Table) ctrl).CaptionAlign = 
CaptionAlign;

+                                               ((Table) ctrl).Caption = 
Caption; 

+                                       }

+#endif

+                               }

+                               else 

+                                       ctrl = new WebControl 
(HtmlTextWriterTag.Span);

                                ctrl.ID = baseControl.ClientID;

                                ctrl.CopyBaseAttributes (baseControl);

                                ctrl.ApplyStyle (controlStyle);

@@ -321,10 +357,21 @@

                                                writer.AddAttribute 
(HtmlTextWriterAttribute.Colspan,

                                                     colSpan.ToString 
(NumberFormatInfo.InvariantInfo));

                                        }

+#if NET_1_1

+                                       if (UseAccessibleHeader)

+                                               writer.AddAttribute("scope", 
"col", false);

+#endif

                                        itemStyle = user.GetItemStyle 
(ListItemType.Header, -1);

                                        if (itemStyle != null)

                                                itemStyle.AddAttributesToRender 
(writer);

+#if NET_1_1

+                                       if (UseAccessibleHeader)

+                                               
writer.RenderBeginTag(HtmlTextWriterTag.Th);

+                                       else

+                                               
writer.RenderBeginTag(HtmlTextWriterTag.Td);

+#else

                                        writer.RenderBeginTag 
(HtmlTextWriterTag.Td);

+#endif

                                }

 

                                user.RenderItem (ListItemType.Header, -1, this, 
writer);

@@ -404,5 +451,28 @@

                        if (ctrl != null)

                                ctrl.RenderEndTag(writer);

                }

+

+#if NET_1_1

+

+               public string Caption

+               {

+                       get {return caption;}

+                       set { caption = value; }

+               }

+

+               public TableCaptionAlign CaptionAlign

+               {

+                       get {return captionAlign;}

+                       set { captionAlign = value; }

+               }

+

+               

+

+               public bool UseAccessibleHeader

+               {

+                       get {return useAccessibleHeader;}

+                       set { useAccessibleHeader = value; }            

+               }

+#endif

        }

 }

Index: ChangeLog

===================================================================

--- ChangeLog   (revision 47418)

+++ ChangeLog   (working copy)

@@ -1,3 +1,8 @@

+2005-07-25  Eyal Alaluf <[EMAIL PROTECTED]>
+       * Table.cs Label.cs Image.cs BaseDataList.cs DataList.cs RepeatInfo.cs
+         DataGrid.cs TableCaptionAlign.cs: Accessiblity feature is part of 
NET_1_1
+         service pack fixes. In Mono it was available only under NET_2_0 
config.
+
 2005-07-19  Eyal Alaluf <[EMAIL PROTECTED]>
        * Added XmlBuilder.jvm.cs for the TARGET_J2EE configuration.
 
Index: DataGrid.cs

===================================================================

--- DataGrid.cs (revision 47365)

+++ DataGrid.cs (working copy)

@@ -944,6 +944,10 @@

 
                        Table display = (Table) Controls [0];
                        display.CopyBaseAttributes (this);
+#if NET_1_1
+                       display.Caption = Caption;
+                       display.CaptionAlign = CaptionAlign;
+#endif
                        if (ControlStyleCreated) {
                                display.ApplyStyle (ControlStyle);
                        } else {
@@ -1182,6 +1186,10 @@

                                        current.Initialize();
                                }
                                deployTable = new DataGridTableInternal();
+#if NET_1_1
+                               deployTable.Caption = Caption;
+                               deployTable.CaptionAlign = CaptionAlign;
+#endif
                                Controls.Add(deployTable);
                                deployRows = deployTable.Rows;
 
@@ -1334,7 +1342,17 @@

                        
                        for(int i = 0; i < columns.Length; i++)
                        {
+#if NET_1_1
+                               if (item.ItemType == ListItemType.Header && 
this.UseAccessibleHeader) 
+                               {
+                                       cCell = new TableHeaderCell();
+                                       cCell.Attributes["scope"] = "col";
+                               }
+                               else
+                                       cCell = new TableCell();
+#else
                                cCell = new TableCell();
+#endif
                                columns[i].InitializeCell(cCell, i, 
item.ItemType);
                                cells.Add(cCell);
                        }
Index: TableCaptionAlign.cs

===================================================================

--- TableCaptionAlign.cs        (revision 47365)

+++ TableCaptionAlign.cs        (working copy)

@@ -25,7 +25,7 @@

 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
 //
 
-#if NET_2_0
+#if NET_1_1
 namespace System.Web.UI.WebControls {
         public enum TableCaptionAlign {
                 NotSet = 0,
_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to