2008-10-24 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlTableCell.cs
1 //
2 // System.Web.UI.HtmlControls.HtmlTableRow.cs
3 //
4 // Author:
5 //      Sebastien Pouliot  <sebastien@ximian.com>
6 //
7 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using System.ComponentModel;
30 using System.Globalization;
31 using System.Security.Permissions;
32
33 namespace System.Web.UI.HtmlControls {
34
35         // CAS
36         [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
37         [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
38         // attributes
39         [ConstructorNeedsTag (true)]
40         public class HtmlTableCell : HtmlContainerControl {
41
42                 public HtmlTableCell ()
43                         : base ("td")
44                 {
45                 }
46
47                 public HtmlTableCell (string tagName)
48                         : base (tagName)
49                 {
50                 }
51
52
53                 [DefaultValue ("")]
54                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
55                 [WebSysDescription("")]
56                 [WebCategory("Layout")]
57                 public string Align {
58                         get {
59                                 string s = Attributes ["align"];
60                                 return (s == null) ? String.Empty : s;
61                         }
62                         set {
63                                 if (value == null)
64                                         Attributes.Remove ("align");
65                                 else
66                                         Attributes ["align"] = value;
67                         }
68                 }
69
70                 [DefaultValue ("")]
71                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
72                 [WebSysDescription("")]
73                 [WebCategory("Appearance")]
74                 public string BgColor {
75                         get {
76                                 string s = Attributes ["bgcolor"];
77                                 return (s == null) ? String.Empty : s;
78                         }
79                         set {
80                                 if (value == null)
81                                         Attributes.Remove ("bgcolor");
82                                 else
83                                         Attributes ["bgcolor"] = value;
84                         }
85                 }
86
87                 [DefaultValue ("")]
88                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
89                 [WebSysDescription("")]
90                 [WebCategory("Appearance")]
91                 public string BorderColor {
92                         get {
93                                 string s = Attributes ["bordercolor"];
94                                 return (s == null) ? String.Empty : s;
95                         }
96                         set {
97                                 if (value == null)
98                                         Attributes.Remove ("bordercolor");
99                                 else
100                                         Attributes ["bordercolor"] = value;
101                         }
102                 }
103
104                 [DefaultValue ("")]
105                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
106                 [WebSysDescription("")]
107                 [WebCategory("Layout")]
108                 public int ColSpan {
109                         get {
110                                 string s = Attributes ["colspan"];
111                                 return (s == null) ? -1 : Convert.ToInt32 (s);
112                         }
113                         set {
114                                 if (value == -1)
115                                         Attributes.Remove ("colspan");
116                                 else
117                                         Attributes ["colspan"] = value.ToString (CultureInfo.InvariantCulture);
118                         }
119                 }
120
121                 [DefaultValue ("")]
122                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
123                 [WebSysDescription("")]
124                 [WebCategory("Layout")]
125                 public string Height {
126                         get {
127                                 string s = Attributes ["height"];
128                                 return (s == null) ? String.Empty : s;
129                         }
130                         set {
131                                 if (value == null)
132                                         Attributes.Remove ("align");
133                                 else
134                                         Attributes ["height"] = value;
135                         }
136                 }
137
138                 [DefaultValue ("")]
139                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
140 #if NET_2_0
141                 [TypeConverter (typeof (MinimizableAttributeTypeConverter))]
142 #endif
143                 [WebSysDescription("")]
144                 [WebCategory("Behavior")]
145                 public bool NoWrap {
146                         get { return (Attributes ["nowrap"] == "nowrap"); }
147                         set {
148                                 if (value)
149                                         Attributes ["nowrap"] = "nowrap";
150                                 else
151                                         Attributes.Remove ("nowrap");
152                         }
153                 }
154
155                 [DefaultValue ("")]
156                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
157                 [WebSysDescription("")]
158                 [WebCategory("Layout")]
159                 public int RowSpan {
160                         get {
161                                 string s = Attributes ["rowspan"];
162                                 return (s == null) ? -1 : Convert.ToInt32 (s);
163                         }
164                         set {
165                                 if (value == -1)
166                                         Attributes.Remove ("rowspan");
167                                 else
168                                         Attributes ["rowspan"] = value.ToString (CultureInfo.InvariantCulture);
169                         }
170                 }
171
172                 [DefaultValue ("")]
173                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
174                 [WebSysDescription("")]
175                 [WebCategory("Appearance")]
176                 public string VAlign {
177                         get {
178                                 string s = Attributes ["valign"];
179                                 return (s == null) ? String.Empty : s;
180                         }
181                         set {
182                                 if (value == null)
183                                         Attributes.Remove ("valign");
184                                 else
185                                         Attributes ["valign"] = value;
186                         }
187                 }
188
189                 [DefaultValue ("")]
190                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
191                 [WebSysDescription("")]
192                 [WebCategory("Layout")]
193                 public string Width {
194                         get {
195                                 string s = Attributes ["width"];
196                                 return (s == null) ? String.Empty : s;
197                         }
198                         set {
199                                 if (value == null)
200                                         Attributes.Remove ("width");
201                                 else
202                                         Attributes ["width"] = value;
203                         }
204                 }
205
206
207                 protected override void RenderEndTag (HtmlTextWriter writer)
208                 {
209                         writer.WriteEndTag (TagName);
210                         if (writer.Indent == 0)
211                                 writer.WriteLine ();
212                 }
213         }
214 }