Merge pull request #1926 from alexrp/profiler-improvements
[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-2010 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 using System.Web.Util;
33
34 namespace System.Web.UI.HtmlControls
35 {
36         // CAS
37         [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
38         [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
39         // attributes
40         [ConstructorNeedsTag (true)]
41         public class HtmlTableCell : HtmlContainerControl
42         {
43                 public HtmlTableCell ()
44                         : base ("td")
45                 {
46                 }
47
48                 public HtmlTableCell (string tagName)
49                         : base (tagName)
50                 {
51                 }
52
53
54                 [DefaultValue ("")]
55                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
56                 [WebSysDescription("")]
57                 [WebCategory("Layout")]
58                 public string Align {
59                         get {
60                                 string s = Attributes ["align"];
61                                 return (s == null) ? String.Empty : s;
62                         }
63                         set {
64                                 if (value == null)
65                                         Attributes.Remove ("align");
66                                 else
67                                         Attributes ["align"] = value;
68                         }
69                 }
70
71                 [DefaultValue ("")]
72                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
73                 [WebSysDescription("")]
74                 [WebCategory("Appearance")]
75                 public string BgColor {
76                         get {
77                                 string s = Attributes ["bgcolor"];
78                                 return (s == null) ? String.Empty : s;
79                         }
80                         set {
81                                 if (value == null)
82                                         Attributes.Remove ("bgcolor");
83                                 else
84                                         Attributes ["bgcolor"] = value;
85                         }
86                 }
87
88                 [DefaultValue ("")]
89                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
90                 [WebSysDescription("")]
91                 [WebCategory("Appearance")]
92                 public string BorderColor {
93                         get {
94                                 string s = Attributes ["bordercolor"];
95                                 return (s == null) ? String.Empty : s;
96                         }
97                         set {
98                                 if (value == null)
99                                         Attributes.Remove ("bordercolor");
100                                 else
101                                         Attributes ["bordercolor"] = value;
102                         }
103                 }
104
105                 [DefaultValue ("")]
106                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
107                 [WebSysDescription("")]
108                 [WebCategory("Layout")]
109                 public int ColSpan {
110                         get {
111                                 string s = Attributes ["colspan"];
112                                 return (s == null) ? -1 : Convert.ToInt32 (s);
113                         }
114                         set {
115                                 if (value == -1)
116                                         Attributes.Remove ("colspan");
117                                 else
118                                         Attributes ["colspan"] = value.ToString (Helpers.InvariantCulture);
119                         }
120                 }
121
122                 [DefaultValue ("")]
123                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
124                 [WebSysDescription("")]
125                 [WebCategory("Layout")]
126                 public string Height {
127                         get {
128                                 string s = Attributes ["height"];
129                                 return (s == null) ? String.Empty : s;
130                         }
131                         set {
132                                 if (value == null)
133                                         Attributes.Remove ("align");
134                                 else
135                                         Attributes ["height"] = value;
136                         }
137                 }
138
139                 [DefaultValue ("")]
140                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
141                 [TypeConverter (typeof (MinimizableAttributeTypeConverter))]
142                 [WebSysDescription("")]
143                 [WebCategory("Behavior")]
144                 public bool NoWrap {
145                         get { return (Attributes ["nowrap"] == "nowrap"); }
146                         set {
147                                 if (value)
148                                         Attributes ["nowrap"] = "nowrap";
149                                 else
150                                         Attributes.Remove ("nowrap");
151                         }
152                 }
153
154                 [DefaultValue ("")]
155                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
156                 [WebSysDescription("")]
157                 [WebCategory("Layout")]
158                 public int RowSpan {
159                         get {
160                                 string s = Attributes ["rowspan"];
161                                 return (s == null) ? -1 : Convert.ToInt32 (s);
162                         }
163                         set {
164                                 if (value == -1)
165                                         Attributes.Remove ("rowspan");
166                                 else
167                                         Attributes ["rowspan"] = value.ToString (Helpers.InvariantCulture);
168                         }
169                 }
170
171                 [DefaultValue ("")]
172                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
173                 [WebSysDescription("")]
174                 [WebCategory("Appearance")]
175                 public string VAlign {
176                         get {
177                                 string s = Attributes ["valign"];
178                                 return (s == null) ? String.Empty : s;
179                         }
180                         set {
181                                 if (value == null)
182                                         Attributes.Remove ("valign");
183                                 else
184                                         Attributes ["valign"] = value;
185                         }
186                 }
187
188                 [DefaultValue ("")]
189                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
190                 [WebSysDescription("")]
191                 [WebCategory("Layout")]
192                 public string Width {
193                         get {
194                                 string s = Attributes ["width"];
195                                 return (s == null) ? String.Empty : s;
196                         }
197                         set {
198                                 if (value == null)
199                                         Attributes.Remove ("width");
200                                 else
201                                         Attributes ["width"] = value;
202                         }
203                 }
204
205
206                 protected override void RenderEndTag (HtmlTextWriter writer)
207                 {
208                         writer.WriteEndTag (TagName);
209                         if (writer.Indent == 0)
210                                 writer.WriteLine ();
211                 }
212         }
213 }