2004-09-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / CheckBoxList.cs
index 6b8b0e21b1ae3c1627167eee9af642b7f320b53d..c3be3f946419295bbf6e7e522a7b663501c422ff 100644 (file)
@@ -1,15 +1,34 @@
-/**\r
-* Namespace: System.Web.UI.WebControls\r
-* Class:     CheckBoxList\r
-*\r
-* Author:  Gaurav Vaish\r
-* Maintainer: gvaish@iitk.ac.in\r
-* Contact: <gvaish@iitk.ac.in>\r
-* Implementation: yes\r
-* Status:  100%\r
-*\r
-* (C) Gaurav Vaish (2001)\r
-*/\r
+//
+// System.Web.UI.WebControls.CheckBoxList.cs
+//
+// Authors:
+//   Gaurav Vaish (gvaish@iitk.ac.in)
+//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) Gaurav Vaish (2002)
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
 \r
 using System;\r
 using System.Collections.Specialized;\r
@@ -20,10 +39,6 @@ using System.Web.UI;
 \r
 namespace System.Web.UI.WebControls\r
 {\r
-       [DefaultEvent("SelectedIndexChanged")]\r
-       [DefaultProperty("DataSource")]\r
-       [ParseChildren(true, "Items")]\r
-       [PersistChildren(false)]\r
        public class CheckBoxList: ListControl, IRepeatInfoUser, INamingContainer, IPostBackDataHandler\r
        {\r
                CheckBox checkBoxRepeater;\r
@@ -34,10 +49,12 @@ namespace System.Web.UI.WebControls
                        checkBoxRepeater = new CheckBox();\r
                        checkBoxRepeater.ID = "0";\r
                        checkBoxRepeater.EnableViewState = false;\r
-                       checkBoxRepeater.Controls.Add(this);\r
+                       Controls.Add (checkBoxRepeater);\r
                        isChangeNotified = false;\r
                }\r
-\r
+
+               [DefaultValue (-1), Bindable (true), WebCategory ("Layout")]
+               [WebSysDescription ("The border left within a CheckBox.")]\r
                public virtual int CellPadding\r
                {\r
                        get\r
@@ -49,7 +66,9 @@ namespace System.Web.UI.WebControls
                                ((TableStyle)ControlStyle).CellPadding = value;\r
                        }\r
                }\r
-\r
+
+               [DefaultValue (-1), Bindable (true), WebCategory ("Layout")]
+               [WebSysDescription ("The border left between CheckBoxes.")]\r
                public virtual int CellSpacing\r
                {\r
                        get\r
@@ -61,7 +80,9 @@ namespace System.Web.UI.WebControls
                                ((TableStyle)ControlStyle).CellSpacing = value;\r
                        }\r
                }\r
-\r
+
+               [DefaultValue (0), Bindable (true), WebCategory ("Layout")]
+               [WebSysDescription ("The number of columns that should be used to display the CheckBoxes.")]\r
                public virtual int RepeatColumns\r
                {\r
                        get\r
@@ -78,7 +99,9 @@ namespace System.Web.UI.WebControls
                                ViewState["RepeatColumns"] = value;\r
                        }\r
                }\r
-\r
+
+               [DefaultValue (typeof (RepeatDirection), "Vertical"), Bindable (true), WebCategory ("Layout")]
+               [WebSysDescription ("The direction that is followed when doing the layout.")]\r
                public virtual RepeatDirection RepeatDirection\r
                {\r
                        get\r
@@ -95,7 +118,9 @@ namespace System.Web.UI.WebControls
                                ViewState["RepeatDirection"] = value;\r
                        }\r
                }\r
-\r
+
+               [DefaultValue (typeof (RepeatLayout), "Table"), Bindable (true), WebCategory ("Layout")]
+               [WebSysDescription ("The method used to create the layout.")]\r
                public virtual RepeatLayout RepeatLayout\r
                {\r
                        get\r
@@ -112,7 +137,9 @@ namespace System.Web.UI.WebControls
                                ViewState["RepeatLayout"] = value;\r
                        }\r
                }\r
-\r
+
+               [DefaultValue (typeof (TextAlign), "Right"), Bindable (true), WebCategory ("Appearance")]
+               [WebSysDescription ("The alignment of the CheckBox text.")]\r
                public virtual TextAlign TextAlign\r
                {\r
                        get\r
@@ -163,7 +190,7 @@ namespace System.Web.UI.WebControls
                        bool dirtyFlag = false;\r
                        short  tTabIndex = TabIndex;\r
                        Style s = (ControlStyleCreated ? ControlStyle : null);\r
-                       if(TabIndex > 0)\r
+                       if(TabIndex != 0)\r
                        {\r
                                if(!ViewState.IsItemDirty("TabIndex"))\r
                                        dirtyFlag = true;\r
@@ -173,7 +200,7 @@ namespace System.Web.UI.WebControls
                        ri.RepeatLayout  = RepeatLayout;\r
                        ri.RepeatDirection = RepeatDirection;\r
                        ri.RenderRepeater(writer, this, s, this);\r
-                       if(tTabIndex > 0)\r
+                       if(tTabIndex != 0)\r
                        {\r
                                TabIndex = tTabIndex;\r
                        }\r
@@ -182,13 +209,17 @@ namespace System.Web.UI.WebControls
                                ViewState.SetItemDirty("TabIndex", false);\r
                        }\r
                }\r
-\r
-               bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)\r
-               {\r
+
+               bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
+               {
+                       if (!Enabled)
+                               return false;
+
                        int index = Int32.Parse(postDataKey.Substring(UniqueID.Length + 1));\r
-                       if(index >= 0 && index < Items.Count)\r
-                       {\r
-                               bool exists = (postCollection[postDataKey]!=null);\r
+                       if(index >= 0 && index < Items.Count)
+                       {
+                               string v = postCollection [postDataKey];
+                               bool exists = (v != null);
                                if(Items[index].Selected != exists)\r
                                {\r
                                        Items[index].Selected = exists;\r
@@ -250,6 +281,7 @@ namespace System.Web.UI.WebControls
                        checkBoxRepeater.Text = Items[repeatIndex].Text;\r
                        checkBoxRepeater.TextAlign = TextAlign;\r
                        checkBoxRepeater.Checked = Items[repeatIndex].Selected;\r
+                       checkBoxRepeater.Enabled = Enabled;\r
                        checkBoxRepeater.RenderControl(writer);\r
                }\r
        }\r