2 // System.Web.UI.WebControls.SubMenuStyle.cs
5 // Lluis Sanchez Gual (lluis@novell.com)
7 // (C) 2004 Novell, Inc (http://www.novell.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
28 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
35 using System.ComponentModel;
37 namespace System.Web.UI.WebControls
39 public class SubMenuStyle: Style
41 private static int HORZ_PADD = (0x01 << 16);
42 private static int VERT_PADD = (0x01 << 17);
44 public SubMenuStyle ()
48 public SubMenuStyle (StateBag bag): base (bag)
52 [DefaultValue (typeof(Unit), "")]
53 [NotifyParentProperty (true)]
54 public Unit HorizontalPadding {
57 return (Unit)(ViewState["HorizontalPadding"]);
61 ViewState["HorizontalPadding"] = value;
66 [DefaultValue (typeof(Unit), "")]
67 [NotifyParentProperty (true)]
68 public Unit VerticalPadding {
71 return (Unit)(ViewState["VerticalPadding"]);
75 ViewState["VerticalPadding"] = value;
80 public override void CopyFrom (Style s)
82 if (s == null || s.IsEmpty)
86 SubMenuStyle from = s as SubMenuStyle;
90 if (from.IsSet (HORZ_PADD))
91 HorizontalPadding = from.HorizontalPadding;
93 if (from.IsSet (VERT_PADD))
94 VerticalPadding = from.VerticalPadding;
97 public override void MergeWith(Style s)
99 if(s != null && !s.IsEmpty)
107 SubMenuStyle with = s as SubMenuStyle;
108 if (with == null) return;
110 if (with.IsSet(HORZ_PADD) && !IsSet(HORZ_PADD)) {
111 HorizontalPadding = with.HorizontalPadding;
113 if (with.IsSet(VERT_PADD) && !IsSet(VERT_PADD)) {
114 VerticalPadding = with.VerticalPadding;
119 public override void Reset()
122 ViewState.Remove("HorizontalPadding");
124 ViewState.Remove("VerticalPadding");
128 protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
130 base.FillStyleAttributes (attributes, urlResolver);
131 if (IsSet (HORZ_PADD)) {
132 attributes.Add (HtmlTextWriterStyle.PaddingLeft, HorizontalPadding.ToString () + "px");
133 attributes.Add (HtmlTextWriterStyle.PaddingRight, HorizontalPadding.ToString () + "px");
135 if (IsSet (VERT_PADD)) {
136 attributes.Add (HtmlTextWriterStyle.PaddingTop, VerticalPadding.ToString () + "px");
137 attributes.Add (HtmlTextWriterStyle.PaddingBottom, VerticalPadding.ToString () + "px");