More files from Toelen
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlTable.cs
1 /*      System.Web.UI.HtmlControls
2 *       Authors
3 *               Leen Toelen (toelen@hotmail.com)
4 */
5
6 using System;
7 using System.Web;
8 using System.Web.UI;
9
10 namespace System.Web.UI.HtmlControls{
11         
12         public class HtmlTable : HtmlContainerControl {
13                 private HtmlTableRowCollection _rows;
14
15                 public HtmlTable():base("table");
16                 
17                 protected override ControlCollection CreateControlCollection(){
18                         return new HtmlTableRowControlCollection;
19                 }
20                 
21                 protected override void RenderChildren(HtmlTextWriter writer){
22                         writer.WriteLine();
23                         writer.Indent = writer.Indent + 1;
24                         base.RenderChildren;
25                         writer.Indent = writer.Indent - 1;
26                 }
27                 
28                 protected override void RenderEndTag(HtmlTextWriter writer){
29                         base.RenderEndTag(writer);
30                         writer.WriteLine;
31                 }
32                 
33                 public string Align {
34                         get{
35                                 string attr = Attributes["align"];
36                                 if (attr != null) return attr;
37                                 return "";
38                         }
39                         set{
40                                 Attributes["align"] = MapStringAttributeToString(value);
41                         }
42                 }
43                 
44                 public string BgColor {
45                         get{
46                                 string attr = Attributes["bgcolor"];
47                                 if (attr != null) return attr;
48                                 return "";
49                         }
50                         set{
51                                 Attributes["bgcolor"] = MapStringAttributeToString(value);
52                         }
53                 }
54                 
55                 public int Border {
56                         get{
57                                 string attr = Attributes["border"];
58                                 if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture);
59                                 return -1;
60                         }
61                         set{
62                                 Attributes["border"] = MapIntegerAttributeToString(value);
63                         }
64                 }
65                 
66                 public string BorderColor {
67                         get{
68                                 string attr = Attributes["bordercolor"];
69                                 if (attr != null) return attr;
70                                 return "";
71                         }
72                         set{
73                                 Attributes["bordercolor"] = MapStringAttributeToString(value);
74                         }
75                 }
76                 
77                 public int CellPadding {
78                         get{
79                                 string attr = Attributes["cellpadding"];
80                                 if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture);
81                                 return -1;
82                         }
83                         set{
84                                 Attributes["cellpadding"] = MapIntegerAttributeToString(value);
85                         }
86                 }
87                 
88                 public int CellSpacing {
89                         get{
90                                 string attr = Attributes["cellspacing"];
91                                 if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture);
92                                 return -1;
93                         }
94                         set{
95                                 Attributes["cellspacing"] = MapIntegerAttributeToString(value);
96                         }
97                 }
98
99                 public string Height {
100                         get{
101                                 string attr = Attributes["height"];
102                                 if (attr != null) return attr;
103                                 return "";
104                         }
105                         set{
106                                 Attributes["height"] = MapStringAttributeToString(value);
107                         }
108                 }
109
110                 public override string InnerHtml {
111                         get{
112                                 throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerHtml_Not_Supported", this.GetType.Name);
113                         }
114                         set{
115                                 throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerHtml_Not_Supported", this.GetType.Name);
116                         }
117                 }
118                 
119                 public override string InnerText {
120                         get{
121                                 throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerText_Not_Supported", this.GetType.Name);
122                         }
123                         set{
124                                 throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerText_Not_Supported", this.GetType.Name);
125                         }
126                 }
127
128                 public virtual HtmlTableRowCollection Rows {
129                         get{
130                                 if (_rows == null) _rows = new HtmlTableRowCollection;
131                                 return _rows;
132                         }
133                 }
134                 
135                 public string Height {
136                         get{
137                                 string attr = Attributes["width"];
138                                 if (attr != null) return attr;
139                                 return "";
140                         }
141                         set{
142                                 Attributes["width"] = MapStringAttributeToString(value);
143                         }
144                 }               
145                 private protected class HtmlTableRowControlCollection : ControlCollection {
146                         internal HtmlTableCellControlCollection(Control owner): base(owner);
147                         
148                         public override void Add(Control child){
149                                 if (child Is HtmlTableCell){
150                                         base.Add(child);
151                                 }
152                                 else{
153                                         throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTableRow",child.GetType.Name.ToString);
154                                 }
155                         }
156                         
157                         public override void AddAt(int index, Control child){
158                                 if (child Is HtmlTableCell){
159                                         base.AddAt(index,child);
160                                 }
161                                 else{
162                                         throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTableRow",child.GetType.Name.ToString);
163                                 }
164                         }
165                 } // end of HtmlTableRowControlCollection
166         }
167         // end of System.Web.UI.HtmlControl
168 }