2 // System.Web.UI.WebControls.MenuItemStyle.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 MenuItemStyle: Style
41 private static int HORZ_PADD = (0x01 << 16);
42 private static int SPACING = (0x01 << 17);
43 private static int VERT_PADD = (0x01 << 18);
46 [NotifyParentProperty (true)]
47 public int HorizontalPadding {
50 return (int)(ViewState["HorizontalPadding"]);
54 ViewState["HorizontalPadding"] = value;
60 [NotifyParentProperty (true)]
61 public int VerticalPadding {
64 return (int)(ViewState["VerticalPadding"]);
68 ViewState["VerticalPadding"] = value;
74 [NotifyParentProperty (true)]
75 public int ItemSpacing {
78 return (int)(ViewState["ItemSpacing"]);
82 ViewState["ItemSpacing"] = value;
87 protected internal override bool IsEmpty {
88 get { return base.IsEmpty; }
91 public override void CopyFrom (Style s)
93 if (s == null || s.IsEmpty)
97 MenuItemStyle from = s as MenuItemStyle;
101 if (from.IsSet (HORZ_PADD))
102 HorizontalPadding = from.HorizontalPadding;
104 if (from.IsSet (SPACING))
105 ItemSpacing = from.ItemSpacing;
107 if (from.IsSet (VERT_PADD))
108 VerticalPadding = from.VerticalPadding;
111 public override void MergeWith(Style s)
113 if(s != null && !s.IsEmpty)
121 MenuItemStyle with = s as MenuItemStyle;
122 if (with == null) return;
124 if (with.IsSet(HORZ_PADD) && !IsSet(HORZ_PADD)) {
125 HorizontalPadding = with.HorizontalPadding;
127 if (with.IsSet(SPACING) && !IsSet(SPACING)) {
128 ItemSpacing = with.ItemSpacing;
130 if (with.IsSet(VERT_PADD) && !IsSet(VERT_PADD)) {
131 VerticalPadding = with.VerticalPadding;
136 public override void Reset()
139 ViewState.Remove("HorizontalPadding");
141 ViewState.Remove("ItemSpacing");
143 ViewState.Remove("VerticalPadding");