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:
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
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.
23 * Namespace: System.Web.UI.WebControls
\r
24 * Class: TableItemStyle
\r
26 * Author: Gaurav Vaish
\r
27 * Maintainer: gvaish@iitk.ac.in
\r
28 * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
\r
29 * Implementation: yes
\r
32 * (C) Gaurav Vaish (2002)
\r
36 using System.ComponentModel;
\r
38 using System.Web.UI;
\r
40 namespace System.Web.UI.WebControls
\r
42 public class TableItemStyle: Style
\r
44 private static int H_ALIGN = (0x01 << 16);
\r
45 private static int V_ALIGN = (0x01 << 17);
\r
46 private static int WRAP = (0x01 << 18);
\r
48 public TableItemStyle(): base()
\r
52 public TableItemStyle(StateBag bag): base(bag)
\r
57 [DefaultValue(HorizontalAlign.NotSet)]
\r
58 [NotifyParentProperty(true)]
\r
59 [WebCategory("Layout")]
\r
60 [WebSysDescription("TableItemStyle_HorizontalAlign")]
\r
61 public virtual HorizontalAlign HorizontalAlign
\r
66 return (HorizontalAlign)ViewState["HorizontalAlign"];
\r
67 return HorizontalAlign.NotSet;
\r
71 if(!Enum.IsDefined(typeof(HorizontalAlign), value))
\r
73 throw new ArgumentException();
\r
75 ViewState["HorizontalAlign"] = value;
\r
81 [DefaultValue(VerticalAlign.NotSet)]
\r
82 [NotifyParentProperty(true)]
\r
83 [WebCategory("Layout")]
\r
84 [WebSysDescription("TableItemStyle_VerticalAlign")]
\r
85 public virtual VerticalAlign VerticalAlign
\r
90 return (VerticalAlign)ViewState["VerticalAlign"];
\r
91 return VerticalAlign.NotSet;
\r
95 if(!Enum.IsDefined(typeof(VerticalAlign), value))
\r
97 throw new ArgumentException();
\r
99 ViewState["VerticalAlign"] = value;
\r
105 [DefaultValue(VerticalAlign.NotSet)]
\r
106 [NotifyParentProperty(true)]
\r
107 [WebCategory("Layout")]
\r
108 [WebSysDescription("TableItemStyle_Wrap")]
\r
109 public virtual bool Wrap
\r
114 return (bool)ViewState["Wrap"];
\r
119 ViewState["Wrap"] = value;
\r
124 public override void CopyFrom(Style s)
\r
126 if(s!=null && !s.IsEmpty)
\r
130 if (!(s is TableItemStyle))
\r
133 TableItemStyle from = (TableItemStyle)s;
\r
134 if(from.IsSet(H_ALIGN))
\r
136 HorizontalAlign = from.HorizontalAlign;
\r
138 if(from.IsSet(V_ALIGN))
\r
140 VerticalAlign = from.VerticalAlign;
\r
142 if(from.IsSet(WRAP))
\r
149 public override void MergeWith(Style s)
\r
151 if(s!=null && !s.IsEmpty)
\r
159 if (!(s is TableItemStyle))
\r
162 TableItemStyle with = (TableItemStyle)s;
\r
163 if(with.IsSet(H_ALIGN) && !IsSet(H_ALIGN))
\r
165 HorizontalAlign = with.HorizontalAlign;
\r
167 if(with.IsSet(V_ALIGN) && !IsSet(V_ALIGN))
\r
169 VerticalAlign = with.VerticalAlign;
\r
171 if(with.IsSet(WRAP) && !IsSet(WRAP))
\r
178 public override void Reset()
\r
181 ViewState.Remove("HorizontalAlign");
\r
183 ViewState.Remove("VerticalAlign");
\r
185 ViewState.Remove("Wrap");
\r
189 public override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)
\r
191 base.AddAttributesToRender(writer, owner);
\r
194 writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
\r
196 if(HorizontalAlign != HorizontalAlign.NotSet)
\r
198 // Temporarily commented out. I'm having problems in cygwin.
\r
199 //writer.AddAttribute(HtmlTextWriterAttribute.Align, TypeDescriptor.GetConverter(typeof(HorizontalAlign)).ConvertToString(HorizontalAlign));
\r
200 writer.AddAttribute(HtmlTextWriterAttribute.Align, HorizontalAlign.ToString ());
\r
202 if(VerticalAlign != VerticalAlign.NotSet)
\r
204 // Temporarily commented out. I'm having problems in cygwin.
\r
205 //writer.AddAttribute(HtmlTextWriterAttribute.Valign, TypeDescriptor.GetConverter(typeof(VerticalAlign)).ConvertToString(VerticalAlign));
\r
206 writer.AddAttribute(HtmlTextWriterAttribute.Valign, VerticalAlign.ToString ());
\r