(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Web / System.Web.UI.WebControls / TableItemStyle.cs
blob9ecaff98557d9a1295c4144435d6814f63336801
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 /**
23 * Namespace: System.Web.UI.WebControls
24 * Class: TableItemStyle
26 * Author: Gaurav Vaish
27 * Maintainer: gvaish@iitk.ac.in
28 * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
29 * Implementation: yes
30 * Status: 100%
32 * (C) Gaurav Vaish (2002)
35 using System;
36 using System.ComponentModel;
37 using System.Web;
38 using System.Web.UI;
40 namespace System.Web.UI.WebControls
42 public class TableItemStyle: Style
44 private static int H_ALIGN = (0x01 << 16);
45 private static int V_ALIGN = (0x01 << 17);
46 private static int WRAP = (0x01 << 18);
48 public TableItemStyle(): base()
52 public TableItemStyle(StateBag bag): base(bag)
56 [Bindable(true)]
57 [DefaultValue(HorizontalAlign.NotSet)]
58 [NotifyParentProperty(true)]
59 [WebCategory("Layout")]
60 [WebSysDescription("TableItemStyle_HorizontalAlign")]
61 public virtual HorizontalAlign HorizontalAlign
63 get
65 if(IsSet(H_ALIGN))
66 return (HorizontalAlign)ViewState["HorizontalAlign"];
67 return HorizontalAlign.NotSet;
69 set
71 if(!Enum.IsDefined(typeof(HorizontalAlign), value))
73 throw new ArgumentException();
75 ViewState["HorizontalAlign"] = value;
76 Set(H_ALIGN);
80 [Bindable(true)]
81 [DefaultValue(VerticalAlign.NotSet)]
82 [NotifyParentProperty(true)]
83 [WebCategory("Layout")]
84 [WebSysDescription("TableItemStyle_VerticalAlign")]
85 public virtual VerticalAlign VerticalAlign
87 get
89 if(IsSet(V_ALIGN))
90 return (VerticalAlign)ViewState["VerticalAlign"];
91 return VerticalAlign.NotSet;
93 set
95 if(!Enum.IsDefined(typeof(VerticalAlign), value))
97 throw new ArgumentException();
99 ViewState["VerticalAlign"] = value;
100 Set(V_ALIGN);
104 [Bindable(true)]
105 [DefaultValue(VerticalAlign.NotSet)]
106 [NotifyParentProperty(true)]
107 [WebCategory("Layout")]
108 [WebSysDescription("TableItemStyle_Wrap")]
109 public virtual bool Wrap
113 if(IsSet(WRAP))
114 return (bool)ViewState["Wrap"];
115 return true;
119 ViewState["Wrap"] = value;
120 Set(WRAP);
124 public override void CopyFrom(Style s)
126 if(s!=null && !s.IsEmpty)
128 base.CopyFrom(s);
130 if (!(s is TableItemStyle))
131 return;
133 TableItemStyle from = (TableItemStyle)s;
134 if(from.IsSet(H_ALIGN))
136 HorizontalAlign = from.HorizontalAlign;
138 if(from.IsSet(V_ALIGN))
140 VerticalAlign = from.VerticalAlign;
142 if(from.IsSet(WRAP))
144 Wrap = from.Wrap;
149 public override void MergeWith(Style s)
151 if(s!=null && !s.IsEmpty)
153 if (IsEmpty) {
154 CopyFrom (s);
155 return;
157 base.MergeWith(s);
159 if (!(s is TableItemStyle))
160 return;
162 TableItemStyle with = (TableItemStyle)s;
163 if(with.IsSet(H_ALIGN) && !IsSet(H_ALIGN))
165 HorizontalAlign = with.HorizontalAlign;
167 if(with.IsSet(V_ALIGN) && !IsSet(V_ALIGN))
169 VerticalAlign = with.VerticalAlign;
171 if(with.IsSet(WRAP) && !IsSet(WRAP))
173 Wrap = with.Wrap;
178 public override void Reset()
180 if(IsSet(H_ALIGN))
181 ViewState.Remove("HorizontalAlign");
182 if(IsSet(V_ALIGN))
183 ViewState.Remove("VerticalAlign");
184 if(IsSet(WRAP))
185 ViewState.Remove("Wrap");
186 base.Reset();
189 public override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)
191 base.AddAttributesToRender(writer, owner);
192 if(!Wrap)
194 writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
196 if(HorizontalAlign != HorizontalAlign.NotSet)
198 // Temporarily commented out. I'm having problems in cygwin.
199 //writer.AddAttribute(HtmlTextWriterAttribute.Align, TypeDescriptor.GetConverter(typeof(HorizontalAlign)).ConvertToString(HorizontalAlign));
200 writer.AddAttribute(HtmlTextWriterAttribute.Align, HorizontalAlign.ToString ());
202 if(VerticalAlign != VerticalAlign.NotSet)
204 // Temporarily commented out. I'm having problems in cygwin.
205 //writer.AddAttribute(HtmlTextWriterAttribute.Valign, TypeDescriptor.GetConverter(typeof(VerticalAlign)).ConvertToString(VerticalAlign));
206 writer.AddAttribute(HtmlTextWriterAttribute.Valign, VerticalAlign.ToString ());