(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Web / System.Web.UI.WebControls / TableCell.cs
blob42b200886e92a831c6e966cac7566f36d0fd3ee2
1 //
2 // System.Web.UI.WebControls.TableCell.cs
3 //
4 // Authors:
5 // Gaurav Vaish (gvaish@iitk.ac.in)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 //
8 // (C) Gaurav Vaish (2002)
9 // (C) 2003 Andreas Nahr
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System;
34 using System.Globalization;
35 using System.Web;
36 using System.Web.UI;
37 using System.ComponentModel;
39 namespace System.Web.UI.WebControls
41 [DefaultProperty("Text")]
42 [ToolboxItem(false)]
43 [ControlBuilder(typeof(TableCellControlBuilder))]
44 [ParseChildren(false)]
45 [PersistChildren(true)]
46 public class TableCell: WebControl
48 public TableCell () : base (HtmlTextWriterTag.Td)
50 PreventAutoID ();
53 internal TableCell (HtmlTextWriterTag tag) : base (tag)
55 PreventAutoID ();
58 [DefaultValue (0), Bindable (true), WebCategory ("Appearance")]
59 [WebSysDescription ("The number of columns spanned by this cell.")]
60 public virtual int ColumnSpan
62 get {
63 object o = ViewState ["ColumnSpan"];
64 return (o == null) ? 0 : (int) o;
67 set {
68 if (value < 0)
69 throw new ArgumentOutOfRangeException ("value", "ColumnSpan value has to be >= 0.");
70 ViewState ["ColumnSpan"] = value;
74 [DefaultValue (0), Bindable (true), WebCategory ("Layout")]
75 [WebSysDescription ("The number of rows spanned by this cell.")]
76 public virtual int RowSpan
78 get {
79 object o = ViewState ["RowSpan"];
80 return (o == null) ? 0 : (int) o;
83 set {
84 if (value < 0)
85 throw new ArgumentOutOfRangeException ("value", "RowSpan value has to be >= 0.");
86 ViewState ["RowSpan"] = value;
90 [DefaultValue (""), Bindable (true), WebCategory ("Appearance")]
91 [WebSysDescription ("The text that is shown in this cell.")]
92 public virtual string Text
94 get {
95 object o = ViewState ["Text"];
96 return (o == null) ? String.Empty : (string) o;
99 set {
100 if (HasControls ())
101 Controls.Clear ();
102 ViewState ["Text"] = value;
106 [DefaultValue (typeof (HorizontalAlign), "NotSet"), Bindable (true), WebCategory ("Layout")]
107 [WebSysDescription ("The horizontal alignment for this cell.")]
108 public virtual HorizontalAlign HorizontalAlign
110 get {
111 if (ControlStyleCreated)
112 return ((TableItemStyle) ControlStyle).HorizontalAlign;
113 return HorizontalAlign.NotSet;
115 set { ((TableItemStyle) ControlStyle).HorizontalAlign = value; }
118 [DefaultValue (typeof (VerticalAlign), "NotSet"), Bindable (true), WebCategory ("Layout")]
119 [WebSysDescription ("The horizontal alignment for this cell.")]
120 public virtual VerticalAlign VerticalAlign
122 get {
123 if (ControlStyleCreated)
124 return ((TableItemStyle) ControlStyle).VerticalAlign;
125 return VerticalAlign.NotSet;
128 set { ((TableItemStyle) ControlStyle).VerticalAlign = value; }
131 [DefaultValue (true), Bindable (true), WebCategory ("Layout")]
132 [WebSysDescription ("Determines if the text in the cell should be wraped at line-end.")]
133 public virtual bool Wrap
135 get {
136 if (ControlStyleCreated)
137 return ((TableItemStyle) ControlStyle).Wrap;
138 return true;
140 set { ((TableItemStyle) ControlStyle).Wrap = value; }
143 protected override void AddAttributesToRender (HtmlTextWriter writer)
145 base.AddAttributesToRender (writer);
146 if (ColumnSpan > 0)
147 writer.AddAttribute (HtmlTextWriterAttribute.Colspan,
148 ColumnSpan.ToString (NumberFormatInfo.InvariantInfo));
150 if (RowSpan > 0)
151 writer.AddAttribute (HtmlTextWriterAttribute.Rowspan,
152 RowSpan.ToString (NumberFormatInfo.InvariantInfo));
155 protected override void AddParsedSubObject (object obj)
157 if (HasControls ()){
158 base.AddParsedSubObject (obj);
159 return;
162 if (obj is LiteralControl){
163 Text = ((LiteralControl) obj).Text;
164 return;
167 string text = Text;
168 if (text.Length > 0){
169 Text = String.Empty;
170 base.AddParsedSubObject (new LiteralControl (text));
173 base.AddParsedSubObject (obj);
176 protected override Style CreateControlStyle ()
178 return new TableItemStyle (ViewState);
181 protected override void RenderContents (HtmlTextWriter writer)
183 if (HasControls ())
184 base.RenderContents (writer);
185 else
186 writer.Write (Text);