raise OnDataSourceViewChanged events when data changes
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / MenuItemStyle.cs
index 85f99a6dc6a3f2c3dd11803e079452859b434b76..6e2c9a1865b18a05b86b4af24f9c784c0274f5ef 100644 (file)
@@ -36,56 +36,64 @@ using System.ComponentModel;
 
 namespace System.Web.UI.WebControls
 {
-       public class MenuItemStyle: Style
+       public sealed class MenuItemStyle: Style
        {
-               private static int HORZ_PADD = (0x01 << 16);
-               private static int SPACING = (0x01 << 17);
-               private static int VERT_PADD = (0x01 << 18);
+               private const string HORZ_PADD = "HorizontalPadding";
+               private const string SPACING = "ItemSpacing";
+               private const string VERT_PADD = "VerticalPadding";
                
-               [DefaultValue (0)]
+               bool IsSet (string v)
+               {
+                       return ViewState [v] != null;
+               }
+               
+               [DefaultValue (typeof (Unit), "")]
                [NotifyParentProperty (true)]
-               public int HorizontalPadding {
+               public Unit HorizontalPadding {
                        get {
                                if(IsSet(HORZ_PADD))
-                                       return (int)(ViewState["HorizontalPadding"]);
-                               return 0;
+                                       return (Unit)(ViewState["HorizontalPadding"]);
+                               return Unit.Empty;
                        }
                        set {
                                ViewState["HorizontalPadding"] = value;
-                               Set(HORZ_PADD);
                        }
                }
 
-               [DefaultValue (0)]
+               [DefaultValue (typeof (Unit), "")]
                [NotifyParentProperty (true)]
-               public int VerticalPadding {
+               public Unit VerticalPadding {
                        get {
                                if(IsSet(VERT_PADD))
-                                       return (int)(ViewState["VerticalPadding"]);
-                               return 0;
+                                       return (Unit)(ViewState["VerticalPadding"]);
+                               return Unit.Empty;
                        }
                        set {
                                ViewState["VerticalPadding"] = value;
-                               Set(VERT_PADD);
                        }
                }
 
-               [DefaultValue (0)]
+               [DefaultValue (typeof (Unit), "")]
                [NotifyParentProperty (true)]
-               public int ItemSpacing {
+               public Unit ItemSpacing {
                        get {
                                if(IsSet(SPACING))
-                                       return (int)(ViewState["ItemSpacing"]);
-                               return 0;
+                                       return (Unit)(ViewState["ItemSpacing"]);
+                               return Unit.Empty;
                        }
                        set {
                                ViewState["ItemSpacing"] = value;
-                               Set(SPACING);
                        }
                }
 
-               protected internal override bool IsEmpty {
-                       get { return base.IsEmpty; }
+               // FIXME: shouldn't be part of the public API
+               public override bool IsEmpty {
+                       get {
+                               return base.IsEmpty && 
+                                      !IsSet(HORZ_PADD) &&
+                                      !IsSet(VERT_PADD) &&
+                                      !IsSet(SPACING);
+                       }
                }
                
                public override void CopyFrom (Style s)
@@ -143,6 +151,19 @@ namespace System.Web.UI.WebControls
                                ViewState.Remove("VerticalPadding");
                        base.Reset();
                }
+               
+               protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
+               {
+                       base.FillStyleAttributes (attributes, urlResolver);
+                       if (IsSet (HORZ_PADD)) {
+                               attributes.Add (HtmlTextWriterStyle.PaddingLeft, HorizontalPadding.ToString ());
+                               attributes.Add (HtmlTextWriterStyle.PaddingRight, HorizontalPadding.ToString ());
+                       }
+                       if (IsSet (VERT_PADD)) {
+                               attributes.Add (HtmlTextWriterStyle.PaddingTop, VerticalPadding.ToString ());
+                               attributes.Add (HtmlTextWriterStyle.PaddingBottom, VerticalPadding.ToString ());
+                       }
+               }
        }
 }