2004-12-03 Lluis Sanchez Gual <lluis@novell.com>
authorLluis Sanchez <lluis@novell.com>
Fri, 3 Dec 2004 19:09:20 +0000 (19:09 -0000)
committerLluis Sanchez <lluis@novell.com>
Fri, 3 Dec 2004 19:09:20 +0000 (19:09 -0000)
* MenuEventArgs.cs: Changed to sealed.
* TreeView.cs: Minor fix.
* Menu.cs, MenuItemBindingCollection.cs, MenuItemCollection.cs,
MenuItemStyle.cs, MenuItemBinding.cs, MenuItem.cs,
MenuItemStyleCollection.cs: Initial Menu code.

svn path=/trunk/mcs/; revision=37044

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI.WebControls/MenuEventArgs.cs
mcs/class/System.Web/System.Web.UI.WebControls/MenuItem.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI.WebControls/MenuItemBinding.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI.WebControls/MenuItemBindingCollection.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI.WebControls/MenuItemCollection.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI.WebControls/MenuItemStyle.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI.WebControls/MenuItemStyleCollection.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs

index a8c2acff90776417445474bb44d2fcc80aecc0ed..c21f3b1b58ba6636d7052e5f7c8e9ffd63b14d0c 100644 (file)
@@ -1,3 +1,11 @@
+2004-12-03 Lluis Sanchez Gual <lluis@novell.com>
+
+       * MenuEventArgs.cs: Changed to sealed.
+       * TreeView.cs: Minor fix.
+       * Menu.cs, MenuItemBindingCollection.cs, MenuItemCollection.cs,
+       MenuItemStyle.cs, MenuItemBinding.cs, MenuItem.cs,
+       MenuItemStyleCollection.cs: Initial Menu code.
+
 2004-12-02 Lluis Sanchez Gual <lluis@novell.com>
 
        * TreeNodeBindingCollection.cs, TreeNodeStyleCollection.cs: 
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs
new file mode 100644 (file)
index 0000000..42f9ae6
--- /dev/null
@@ -0,0 +1,256 @@
+//
+// System.Web.UI.WebControls.Menu.cs
+//
+// Authors:
+//     Lluis Sanchez Gual (lluis@novell.com)
+//
+// (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+using System.Text;
+using System.ComponentModel;
+using System.Web.UI;
+using System.Web.Handlers;
+using System.Collections.Specialized;
+using System.IO;
+
+namespace System.Web.UI.WebControls
+{
+       public class Menu : HierarchicalDataBoundControl, IPostBackEventHandler, INamingContainer
+       {
+               MenuItemCollection items;
+               MenuItemBindingCollection dataBindings;
+               MenuItem selectedItem;
+               Hashtable bindings;
+               
+               [PersistenceMode (PersistenceMode.InnerProperty)]
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+               [Editor ("System.Web.UI.Design.MenuItemBindingsEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               public virtual MenuItemBindingCollection DataBindings {
+                       get {
+                               if (dataBindings == null) {
+                                       dataBindings = new MenuItemBindingCollection ();
+                                       if (IsTrackingViewState)
+                                               ((IStateManager)dataBindings).TrackViewState();
+                               }
+                               return dataBindings;
+                       }
+               }
+
+               [DefaultValue (500)]
+               public virtual int DisappearAfter {
+                       get {
+                               object o = ViewState ["DisappearAfter"];
+                               if (o != null) return (int)o;
+                               return 500;
+                       }
+                       set {
+                               ViewState["DisappearAfter"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [UrlProperty]
+               [WebCategory ("Appearance")]
+               [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               public virtual string DynamicBottomSeparatorImageUrl {
+                       get {
+                               object o = ViewState ["dbsiu"];
+                               if (o != null) return (string)o;
+                               return "";
+                       }
+                       set {
+                               ViewState["dbsiu"] = value;
+                       }
+               }
+
+/*             [DefaultValue (true)]
+               public virtual bool DynamicEnableDefaultPopOutImage {
+                       get {
+                               object o = ViewState ["dedpoi"];
+                               if (o != null) return (bool)o;
+                               return true;
+                       }
+                       set {
+                               ViewState["dedpoi"] = value;
+                       }
+               }
+*/
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+               [PersistenceMode (PersistenceMode.InnerProperty)]
+               [Editor ("System.Web.UI.Design.MenuItemCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               public virtual MenuItemCollection Items {
+                       get {
+                               if (items == null) {
+                                       items = new MenuItemCollection (this);
+                                       if (IsTrackingViewState)
+                                               ((IStateManager)items).TrackViewState();
+                               }
+                               return items;
+                       }
+               }
+
+               [DefaultValue ('/')]
+               public virtual char PathSeparator {
+                       get {
+                               object o = ViewState ["PathSeparator"];
+                               if(o != null) return (char)o;
+                               return '/';
+                       }
+                       set {
+                               ViewState ["PathSeparator"] = value;
+                       }
+               }
+
+               [Browsable (false)]
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               public MenuItem SelectedItem {
+                       get { return selectedItem; }
+               }
+
+               internal void SetSelectedItem (MenuItem item)
+               {
+                       if (selectedItem == item) return;
+                       if (selectedItem != null)
+                               selectedItem.SelectedFlag = false;
+                       selectedItem = item;
+                       selectedItem.SelectedFlag = true;
+       //              OnSelectedItemChanged (new MenuItemEventArgs (selectedItem));
+               }
+               
+               public MenuItem FindItem (string valuePath)
+               {
+                       if (valuePath == null) throw new ArgumentNullException ("valuePath");
+                       string[] path = valuePath.Split (PathSeparator);
+                       int n = 0;
+                       MenuItemCollection col = Items;
+                       bool foundBranch = true;
+                       while (col.Count > 0 && foundBranch) {
+                               foundBranch = false;
+                               foreach (MenuItem item in col) {
+                                       if (item.Value == path [n]) {
+                                               if (++n == path.Length) return item;
+                                               col = item.ChildItems;
+                                               foundBranch = true;
+                                               break;
+                                       }
+                               }
+                       }
+                       return null;
+               }
+               
+               string GetBindingKey (string dataMember, int depth)
+               {
+                       return dataMember + " " + depth;
+               }
+               
+               internal MenuItemBinding FindBindingForItem (string type, int depth)
+               {
+                       if (bindings == null) return null;
+
+                       MenuItemBinding bin = (MenuItemBinding) bindings [GetBindingKey (type, depth)];
+                       if (bin != null) return bin;
+                       
+                       bin = (MenuItemBinding) bindings [GetBindingKey (type, -1)];
+                       if (bin != null) return bin;
+                       
+                       bin = (MenuItemBinding) bindings [GetBindingKey ("", depth)];
+                       if (bin != null) return bin;
+                       
+                       bin = (MenuItemBinding) bindings [GetBindingKey ("", -1)];
+                       return bin;
+               }
+               
+               protected internal override void PerformDataBinding ()
+               {
+                       base.PerformDataBinding ();
+                       HierarchicalDataSourceView data = GetData ("");
+                       IHierarchicalEnumerable e = data.Select ();
+                       foreach (object obj in e) {
+                               IHierarchyData hdata = e.GetHierarchyData (obj);
+                               MenuItem item = new MenuItem ();
+                               item.Bind (hdata);
+                               Items.Add (item);
+                       }
+               }
+               
+               void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
+               {
+               }
+               
+               protected override void TrackViewState()
+               {
+                       EnsureDataBound ();
+                       
+                       base.TrackViewState();
+                       if (dataBindings != null) {
+                               ((IStateManager)dataBindings).TrackViewState ();
+                       }
+                       if (items != null) {
+                               ((IStateManager)items).TrackViewState();;
+                       }
+               }
+
+               protected override object SaveViewState()
+               {
+                       object[] states = new object [2];
+                       states[0] = base.SaveViewState();
+                       states[1] = (dataBindings == null ? null : ((IStateManager)dataBindings).SaveViewState());
+                       states[2] = (items == null ? null : ((IStateManager)items).SaveViewState());
+
+                       for (int i = states.Length - 1; i >= 0; i--) {
+                               if (states [i] != null)
+                                       return states;
+                       }
+
+                       return null;
+               }
+
+               protected override void LoadViewState (object savedState)
+               {
+                       if (savedState == null)
+                               return;
+
+                       object [] states = (object []) savedState;
+                       base.LoadViewState (states[0]);
+                       
+                       if (states[1] != null)
+                               ((IStateManager)dataBindings).LoadViewState(states[8]);
+                       if (states[2] != null)
+                               ((IStateManager)Items).LoadViewState(states[9]);
+               }
+               
+               protected override void RenderContents (HtmlTextWriter writer)
+               {
+                       writer.WriteLine ("This is a menu");
+               }
+               
+       }
+}
+
+#endif
index 2457593991007313d2f96542b8b98326a9eab173..a0a6012dd29f3f92464bbf5a8bdd9f79981fde2f 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace System.Web.UI.WebControls
 {
-       public class MenuEventArgs : CommandEventArgs
+       public sealed class MenuEventArgs : CommandEventArgs
        {
                private MenuItem item; 
                private object source;
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/MenuItem.cs b/mcs/class/System.Web/System.Web.UI.WebControls/MenuItem.cs
new file mode 100644 (file)
index 0000000..cff024b
--- /dev/null
@@ -0,0 +1,494 @@
+//
+// System.Web.UI.WebControls.MenuItem.cs
+//
+// Authors:
+//     Lluis Sanchez Gual (lluis@novell.com)
+//
+// (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+using System.Text;
+using System.ComponentModel;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+       [ParseChildrenAttribute (true, "ChildItems")]
+       public sealed class MenuItem: IStateManager, ICloneable
+       {
+               StateBag ViewState = new StateBag ();
+               MenuItemCollection items;
+               bool marked;
+               Menu menu;
+               MenuItem parent;
+               int index;
+               string path;
+               int depth = -1;
+               
+               IHierarchyData hierarchyData;
+               bool gotBinding;
+               MenuItemBinding binding;
+               PropertyDescriptorCollection boundProperties;
+               
+               public MenuItem ()
+               {
+               }
+               
+               public MenuItem (string text)
+               {
+                       Text = text;
+               }
+               
+               public MenuItem (string text, string value)
+               {
+                       Text = text;
+                       Value = value;
+               }
+               
+               public MenuItem (string text, string value, string imageUrl)
+               {
+                       Text = text;
+                       Value = value;
+                       ImageUrl = imageUrl;
+               }
+               
+               public MenuItem (string text, string value, string imageUrl, string navigateUrl, string target)
+               {
+                       Text = text;
+                       Value = value;
+                       ImageUrl = imageUrl;
+                       NavigateUrl = navigateUrl;
+                       Target = target;
+               }
+               
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [Browsable (false)]
+               public int Depth {
+                       get {
+                               if (depth != -1) return depth;
+                               depth = 0;
+                               MenuItem nod = parent;
+                               while (nod != null) {
+                                       depth++;
+                                       nod = nod.parent;
+                               }
+                               return depth;
+                       }
+               }
+               
+               void ResetPathData ()
+               {
+                       path = null;
+                       depth = -1;
+                       gotBinding = false;
+               }
+               
+               internal Menu Menu {
+                       get { return menu; }
+                       set {
+                               if (SelectedFlag) {
+                                       if (value != null)
+                                               value.SetSelectedItem (this);
+                                       else if (menu != null)
+                                               menu.SetSelectedItem (null);
+                               }
+                               menu = value;
+                               if (items != null)
+                                       items.SetMenu (menu);
+                               ResetPathData ();
+                       }
+               }
+               
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [DefaultValue (false)]
+               [Browsable (false)]
+               public bool DataBound {
+                       get { return hierarchyData != null; }
+               }
+               
+               [DefaultValue (null)]
+               [Browsable (false)]
+               public object DataItem {
+                       get {
+                               if (hierarchyData == null) throw new InvalidOperationException ("MenuItem is not data bound.");
+                               return hierarchyData.Item;
+                       }
+               }
+               
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [DefaultValue ("")]
+               [Browsable (false)]
+               public string DataPath {
+                       get {
+                               if (hierarchyData == null) throw new InvalidOperationException ("MenuItem is not data bound.");
+                               return hierarchyData.Path;
+                       }
+               }
+               
+               [MergableProperty (false)]
+               [Browsable (false)]
+               [PersistenceMode (PersistenceMode.InnerDefaultProperty)]
+               public MenuItemCollection ChildItems {
+                       get {
+                               if (items == null) {
+                                       if (DataBound)
+                                               FillBoundChildren ();
+                                       else
+                                               items = new MenuItemCollection (this);
+                                               
+                                       if (((IStateManager)this).IsTrackingViewState)
+                                               ((IStateManager)items).TrackViewState();
+                               }
+                               return items;
+                       }
+               }
+               
+               [DefaultValue ("")]
+               [UrlProperty]
+               [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               public string ImageUrl {
+                       get {
+                               object o = ViewState ["ImageUrl"];
+                               if (o != null) return (string)o;
+                               if (DataBound) {
+                                       MenuItemBinding bin = GetBinding ();
+                                       if (bin != null) {
+                                               if (bin.ImageUrlField != "")
+                                                       return (string) GetBoundPropertyValue (bin.ImageUrlField);
+                                               return bin.ImageUrl;
+                                       }
+                               }
+                               return "";
+                       }
+                       set {
+                               ViewState ["ImageUrl"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [UrlProperty]
+               [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               public string NavigateUrl {
+                       get {
+                               object o = ViewState ["NavigateUrl"];
+                               if (o != null) return (string)o;
+                               if (DataBound) {
+                                       MenuItemBinding bin = GetBinding ();
+                                       if (bin != null) {
+                                               if (bin.NavigateUrlField != "")
+                                                       return (string) GetBoundPropertyValue (bin.NavigateUrlField);
+                                               return bin.NavigateUrl;
+                                       }
+                               }
+                               return "";
+                       }
+                       set {
+                               ViewState ["NavigateUrl"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               public string Target {
+                       get {
+                               object o = ViewState ["Target"];
+                               if(o != null) return (string)o;
+                               if (DataBound) {
+                                       MenuItemBinding bin = GetBinding ();
+                                       if (bin != null) {
+                                               if (bin.TargetField != "")
+                                                       return (string) GetBoundPropertyValue (bin.TargetField);
+                                               return bin.Target;
+                                       }
+                               }
+                               return "";
+                       }
+                       set {
+                               ViewState ["Target"] = value;
+                       }
+               }
+
+               [Localizable (true)]
+               [DefaultValue ("")]
+               public string Text {
+                       get {
+                               object o = ViewState ["Text"];
+                               if (o != null) return (string)o;
+                               if (DataBound) {
+                                       MenuItemBinding bin = GetBinding ();
+                                       if (bin != null) {
+                                               string text;
+                                               if (bin.TextField != "")
+                                                       text = (string) GetBoundPropertyValue (bin.TextField);
+                                               else if (bin.Text != "")
+                                                       text = bin.Text;
+                                               else
+                                                       text = hierarchyData.ToString ();
+                                                       
+                                               if (bin.FormatString.Length != 0)
+                                                       text = string.Format (bin.FormatString, text);
+                                               return text;
+                                       }
+                                       return hierarchyData.ToString ();
+                               }
+                               return "";
+                       }
+                       set {
+                               ViewState ["Text"] = value;
+                       }
+               }
+
+               [Localizable (true)]
+               [DefaultValue ("")]
+               public string ToolTip {
+                       get {
+                               object o = ViewState ["ToolTip"];
+                               if(o != null) return (string)o;
+                               if (DataBound) {
+                                       MenuItemBinding bin = GetBinding ();
+                                       if (bin != null) {
+                                               if (bin.ToolTipField != "")
+                                                       return (string) GetBoundPropertyValue (bin.ToolTipField);
+                                               return bin.ToolTip;
+                                       }
+                               }
+                               return "";
+                       }
+                       set {
+                               ViewState ["ToolTip"] = value;
+                       }
+               }
+
+               [Localizable (true)]
+               [DefaultValue ("")]
+               public string Value {
+                       get {
+                               object o = ViewState ["Value"];
+                               if(o != null) return (string)o;
+                               if (DataBound) {
+                                       MenuItemBinding bin = GetBinding ();
+                                       if (bin != null) {
+                                               if (bin.ValueField != "")
+                                                       return (string) GetBoundPropertyValue (bin.ValueField);
+                                               if (bin.Value != "")
+                                                       return bin.Value;
+                                       }
+                                       return hierarchyData.ToString ();
+                               }
+                               return "";
+                       }
+                       set {
+                               ViewState ["Value"] = value;
+                       }
+               }
+               
+               [DefaultValue (false)]
+               public bool Selected {
+                       get {
+                               return SelectedFlag;
+                       }
+                       set {
+                               if (menu != null) {
+                                       if (!value && menu.SelectedItem == this)
+                                               menu.SetSelectedItem (null);
+                                       else if (value)
+                                               menu.SetSelectedItem (this);
+                               }
+                               else
+                                       SelectedFlag = value;
+                       }
+               }
+               
+               internal bool SelectedFlag {
+                       get {
+                               object o = ViewState ["Selected"];
+                               if(o != null) return (bool)o;
+                               return false;
+                       }
+                       set {
+                               ViewState ["Selected"] = value;
+                       }
+               }
+               
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [Browsable (false)]
+               public MenuItem Parent {
+                       get { return parent; }
+               }
+               
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [Browsable (false)]
+               public string ValuePath {
+                       get {
+                               if (menu == null) return Value;
+                               
+                               StringBuilder sb = new StringBuilder (Value);
+                               MenuItem item = parent;
+                               while (item != null) {
+                                       sb.Insert (0, menu.PathSeparator);
+                                       sb.Insert (0, item.Value);
+                                       item = item.Parent;
+                               }
+                               return sb.ToString ();
+                       }
+               }
+               
+               internal int Index {
+                       get { return index; }
+                       set { index = value; ResetPathData (); }
+               }
+               
+               internal void SetParent (MenuItem item) {
+                       parent = item;
+                       ResetPathData ();
+               }
+               
+               internal string Path {
+                       get {
+                               if (path != null) return path;
+                               StringBuilder sb = new StringBuilder (index.ToString());
+                               MenuItem item = parent;
+                               while (item != null) {
+                                       sb.Insert (0, '_');
+                                       sb.Insert (0, item.Index.ToString ());
+                                       item = item.Parent;
+                               }
+                               path = sb.ToString ();
+                               return path;
+                       }
+               }
+               
+               internal bool HasChildData {
+                       get { return items != null; }
+               }
+               
+               void IStateManager.LoadViewState (object savedState)
+               {
+                       if (savedState == null)
+                               return;
+
+                       object[] states = (object[]) savedState;
+                       ViewState.LoadViewState (states [0]);
+                       
+                       if (menu != null && SelectedFlag)
+                               menu.SetSelectedItem (this);
+                       
+                       if (states [1] != null)
+                               ((IStateManager)ChildItems).LoadViewState (states [1]);
+               }
+               
+               object IStateManager.SaveViewState ()
+               {
+                       object[] states = new object[2];
+                       states[0] = ViewState.SaveViewState();
+                       states[1] = (items == null ? null : ((IStateManager)items).SaveViewState());
+                       
+                       for (int i = 0; i < states.Length; i++) {
+                               if (states [i] != null)
+                                       return states;
+                       }
+                       return null;
+               }
+               
+               void IStateManager.TrackViewState ()
+               {
+                       if (marked) return;
+                       marked = true;
+                       ViewState.TrackViewState();
+
+                       if (items != null)
+                               ((IStateManager)items).TrackViewState ();
+               }
+               
+               bool IStateManager.IsTrackingViewState
+               {
+                       get { return marked; }
+               }
+               
+               internal void SetDirty ()
+               {
+                       ViewState.SetDirty ();
+               }
+               
+               object ICloneable.Clone ()
+               {
+                       MenuItem nod = new MenuItem ();
+                       foreach (DictionaryEntry e in ViewState)
+                               nod.ViewState [(string)e.Key] = e.Value;
+                               
+                       foreach (ICloneable c in ChildItems)
+                               nod.ChildItems.Add ((MenuItem)c.Clone ());
+                               
+                       return nod;
+               }
+               
+               internal void Bind (IHierarchyData hierarchyData)
+               {
+                       this.hierarchyData = hierarchyData;
+               }
+               
+               MenuItemBinding GetBinding ()
+               {
+                       if (menu == null) return null;
+                       if (gotBinding) return binding;
+                       binding = menu.FindBindingForItem (hierarchyData.Type, Depth);
+                       gotBinding = true;
+                       return binding;
+               }
+               
+               object GetBoundPropertyValue (string name)
+               {
+                       if (boundProperties == null) {
+                               ICustomTypeDescriptor desc = hierarchyData as ICustomTypeDescriptor;
+                               if (desc == null)
+                                       throw new InvalidOperationException ("Property '" + name + "' not found in data bound item");
+                               boundProperties = desc.GetProperties ();
+                       }
+                       
+                       PropertyDescriptor prop = boundProperties.Find (name, true);
+                       if (prop == null)
+                               throw new InvalidOperationException ("Property '" + name + "' not found in data bound item");
+                       return prop.GetValue (hierarchyData);
+               }
+
+               void FillBoundChildren ()
+               {
+                       items = new MenuItemCollection (this);
+                       if (!hierarchyData.HasChildren) return;
+
+                       IHierarchicalEnumerable e = hierarchyData.GetChildren ();
+                       foreach (object obj in e) {
+                               IHierarchyData hdata = e.GetHierarchyData (obj);
+                               MenuItem item = new MenuItem ();
+                               item.Bind (hdata);
+                               items.Add (item);
+                       }
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemBinding.cs b/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemBinding.cs
new file mode 100644 (file)
index 0000000..d7cfe75
--- /dev/null
@@ -0,0 +1,306 @@
+//
+// System.Web.UI.WebControls.MenuItemBinding.cs
+//
+// Authors:
+//     Lluis Sanchez Gual (lluis@novell.com)
+//
+// (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+       [DefaultProperty ("TextField")]
+       public sealed class MenuItemBinding: IStateManager, ICloneable, IDataSourceViewSchemaAccessor
+       {
+               StateBag ViewState = new StateBag ();
+               
+               [DefaultValue ("")]
+               public string DataMember {
+                       get {
+                               object o = ViewState ["DataMember"];
+                               if (o != null) return (string) o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["DataMember"] = value;
+                       }
+               }
+
+               [DefaultValue (-1)]
+               public int Depth {
+                       get {
+                               object o = ViewState ["Depth"];
+                               if (o != null) return (int) o;
+                               return -1;
+                       }
+                       set {
+                               ViewState ["Depth"] = value;
+                       }
+               }
+
+               [DefaultValue (true)]
+               public bool Enabled {
+                       get {
+                               object o = ViewState ["Enabled"];
+                               if (o != null) return (bool) o;
+                               return true;
+                       }
+                       set {
+                               ViewState ["Enabled"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
+               public string EnabledField {
+                       get {
+                               object o = ViewState ["EnabledField"];
+                               if (o != null) return (string) o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["EnabledField"] = value;
+                       }
+               }
+
+               [Localizable (true)]
+               [DefaultValue ("")]
+               public string FormatString {
+                       get {
+                               object o = ViewState ["FormatString"];
+                               if (o != null) return (string) o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["FormatString"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [UrlProperty]
+               [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               public string ImageUrl {
+                       get {
+                               object o = ViewState ["ImageUrl"];
+                               if (o != null) return (string) o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["ImageUrl"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
+               public string ImageUrlField {
+                       get {
+                               object o = ViewState ["ImageUrlField"];
+                               if (o != null) return (string) o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["ImageUrlField"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [UrlProperty]
+               [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               public string NavigateUrl {
+                       get {
+                               object o = ViewState ["NavigateUrl"];
+                               if (o != null) return (string) o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["NavigateUrl"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
+               public string NavigateUrlField {
+                       get {
+                               object o = ViewState ["NavigateUrlField"];
+                               if (o != null) return (string) o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["NavigateUrlField"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               public string Target {
+                       get {
+                               object o = ViewState ["Target"];
+                               if(o != null) return (string)o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["Target"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
+               public string TargetField {
+                       get {
+                               object o = ViewState ["TargetField"];
+                               if (o != null) return (string) o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["TargetField"] = value;
+                       }
+               }
+
+               [Localizable (true)]
+               [DefaultValue ("")]
+               [WebSysDescription ("The display text of the menu item.")]
+               public string Text {
+                       get {
+                               object o = ViewState ["Text"];
+                               if(o != null) return (string)o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["Text"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
+               public string TextField {
+                       get {
+                               object o = ViewState ["TextField"];
+                               if(o != null) return (string)o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["TextField"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [Localizable (true)]
+               public string ToolTip {
+                       get {
+                               object o = ViewState ["ToolTip"];
+                               if(o != null) return (string)o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["ToolTip"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
+               public string ToolTipField {
+                       get {
+                               object o = ViewState ["ToolTipField"];
+                               if(o != null) return (string)o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["ToolTipField"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [Localizable (true)]
+               public string Value {
+                       get {
+                               object o = ViewState ["Value"];
+                               if(o != null) return (string)o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["Value"] = value;
+                       }
+               }
+
+               [DefaultValue ("")]
+               [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
+               public string ValueField {
+                       get {
+                               object o = ViewState ["ValueField"];
+                               if(o != null) return (string)o;
+                               return "";
+                       }
+                       set {
+                               ViewState ["ValueField"] = value;
+                       }
+               }
+
+               void IStateManager.LoadViewState (object savedState)
+               {
+                       ViewState.LoadViewState (savedState);
+               }
+               
+               object IStateManager.SaveViewState ()
+               {
+                       return ViewState.SaveViewState();
+               }
+               
+               void IStateManager.TrackViewState ()
+               {
+                       ViewState.TrackViewState ();
+               }
+               
+               bool IStateManager.IsTrackingViewState {
+                       get { return ViewState.IsTrackingViewState; }
+               }
+               
+               [MonoTODO]
+               object IDataSourceViewSchemaAccessor.DataSourceViewSchema {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+               
+               object ICloneable.Clone ()
+               {
+                       MenuItemBinding bin = new MenuItemBinding ();
+                       foreach (DictionaryEntry e in ViewState)
+                               bin.ViewState [(string)e.Key] = e.Value;
+                       return bin;
+               }
+
+               internal void SetDirty ()
+               {
+                       foreach (string key in ViewState.Keys)
+                               ViewState.SetItemDirty (key, true);
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemBindingCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemBindingCollection.cs
new file mode 100644 (file)
index 0000000..0c81619
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// System.Web.UI.WebControls.MenuItemBindingCollection.cs
+//
+// Authors:
+//     Lluis Sanchez Gual (lluis@novell.com)
+//
+// (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+       public sealed class MenuItemBindingCollection: StateManagedCollection
+       {
+               static Type[] types = new Type[] { typeof (MenuItemBinding) };
+               
+               internal MenuItemBindingCollection ()
+               {
+               }
+               
+               public int Add (MenuItemBinding binding)
+               {
+                       return ((IList)this).Add (binding);
+               }
+               
+               public bool Contains (MenuItemBinding binding)
+               {
+                       return ((IList)this).Contains (binding);
+               }
+               
+               public void CopyTo (MenuItemBinding[] array, int index)
+               {
+                       ((IList)this).CopyTo (array, index);
+               }
+               
+               protected override object CreateKnownType (int index)
+               {
+                       return new MenuItemBinding ();
+               }
+               
+               protected override Type[] GetKnownTypes ()
+               {
+                       return types;
+               }
+               
+               public int IndexOf (MenuItemBinding binding)
+               {
+                       return ((IList)this).IndexOf (binding);
+               }
+               
+               public void Insert (int index, MenuItemBinding binding)
+               {
+                       ((IList)this).Insert (index, binding);
+               }
+               
+               public void Remove (MenuItemBinding binding)
+               {
+                       ((IList)this).Remove (binding);
+               }
+               
+               public void RemoveAt (int index)
+               {
+                       ((IList)this).RemoveAt (index);
+               }
+               
+               public MenuItemBinding this [int i] {
+                       get { return (MenuItemBinding) ((IList)this) [i]; }
+                       set { ((IList)this) [i] = value; }
+               }
+               
+               protected override void SetDirtyObject (object o)
+               {
+                       ((MenuItemBinding)o).SetDirty ();
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemCollection.cs
new file mode 100644 (file)
index 0000000..0151421
--- /dev/null
@@ -0,0 +1,248 @@
+//
+// System.Web.UI.WebControls.MenuItemCollection.cs
+//
+// Authors:
+//     Lluis Sanchez Gual (lluis@novell.com)
+//
+// (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+#if NET_2_0
+
+using System;
+using System.Web.UI;
+using System.Collections;
+
+namespace System.Web.UI.WebControls
+{
+       public sealed class MenuItemCollection: ICollection, IEnumerable, IStateManager
+       {
+               MenuItem[] originalItems;
+               ArrayList items = new ArrayList ();
+               Menu menu;
+               MenuItem parent;
+               bool marked;
+               bool dirty;
+               
+               public MenuItemCollection ()
+               {
+               }
+               
+               public MenuItemCollection (MenuItem owner)
+               {
+                       this.parent = owner;
+                       this.menu = owner.Menu;
+               }
+               
+               internal MenuItemCollection (Menu menu)
+               {
+                       this.menu = menu;
+               }
+               
+               internal void SetMenu (Menu menu)
+               {
+                       this.menu = menu;
+                       foreach (MenuItem item in items)
+                               item.Menu = menu;
+               }
+               
+               public MenuItem this [int i] {
+                       get { return (MenuItem) items [i]; }
+               }
+               
+               public void Add (MenuItem child)
+               {
+                       child.Index = items.Add (child);
+                       child.Menu = menu;
+                       child.SetParent (parent);
+                       if (marked) {
+                               ((IStateManager)child).TrackViewState ();
+                               child.SetDirty ();
+                               dirty = true;
+                       }
+               }
+               
+               public void AddAt (int index, MenuItem child)
+               {
+                       items.Insert (index, child);
+                       child.Index = index;
+                       child.Menu = menu;
+                       child.SetParent (parent);
+                       for (int n=index+1; n<items.Count; n++)
+                               ((MenuItem)items[n]).Index = n;
+                       if (marked) {
+                               ((IStateManager)child).TrackViewState ();
+                               child.SetDirty ();
+                               dirty = true;
+                       }
+               }
+               
+               public void Clear ()
+               {
+                       if (menu != null || parent != null) {
+                               foreach (MenuItem nod in items) {
+                                       nod.Menu = null;
+                                       nod.SetParent (null);
+                               }
+                       }
+                       items.Clear ();
+                       dirty = true;
+               }
+               
+               public bool Contains (MenuItem child)
+               {
+                       return items.Contains (child);
+               }
+               
+               public void CopyTo (Array itemArray, int index)
+               {
+                       items.CopyTo (itemArray, index);
+               }
+               
+               public void CopyTo (MenuItem[] itemArray, int index)
+               {
+                       items.CopyTo (itemArray, index);
+               }
+               
+               public IEnumerator GetEnumerator ()
+               {
+                       return items.GetEnumerator ();
+               }
+               
+               public int IndexOf (MenuItem item)
+               {
+                       return items.IndexOf (item);
+               }
+               
+               public void Remove (MenuItem item)
+               {
+                       int i = IndexOf (item);
+                       if (i == -1) return;
+                       items.RemoveAt (i);
+                       if (menu != null)
+                               item.Menu = null;
+                       dirty = true;
+               }
+               
+               public void RemoveAt (int index)
+               {
+                       MenuItem item = (MenuItem) items [index];
+                       items.RemoveAt (index);
+                       if (menu != null)
+                               item.Menu = null;
+                       dirty = true;
+               }
+               
+               public int Count {
+                       get { return items.Count; }
+               }
+               
+               public bool IsSynchronized {
+                       get { return false; }
+               }
+               
+               public object SyncRoot {
+                       get { return items; }
+               }
+               
+               void System.Collections.ICollection.CopyTo (Array array, int index)
+               {
+                       items.CopyTo (array, index);
+               }
+
+               void IStateManager.LoadViewState (object state)
+               {
+                       if (state == null) return;
+                       object[] its = (object[]) state;
+                       
+                       dirty = (bool)its [0];
+                       
+                       if (dirty)
+                               items.Clear ();
+
+                       for (int n=1; n<its.Length; n++) {
+                               Pair pair = (Pair) its [n];
+                               int oi = (int) pair.First;
+                               MenuItem item;
+                               if (oi != -1) item = originalItems [oi];
+                               else item = new MenuItem ();
+                               if (dirty) Add (item);
+                               ((IStateManager)item).LoadViewState (pair.Second);
+                       }
+               }
+               
+               object IStateManager.SaveViewState ()
+               {
+                       object[] state = null;
+                       bool hasData = false;
+                       
+                       if (dirty) {
+                               state = new object [items.Count + 1];
+                               state [0] = true;
+                               for (int n=0; n<items.Count; n++) {
+                                       MenuItem item = items[n] as MenuItem;
+                                       int oi = Array.IndexOf (originalItems, item);
+                                       object ns = ((IStateManager)item).SaveViewState ();
+                                       if (ns != null) hasData = true;
+                                       state [n + 1] = new Pair (oi, ns);
+                               }
+                       } else {
+                               ArrayList list = new ArrayList ();
+                               for (int n=0; n<items.Count; n++) {
+                                       MenuItem item = items[n] as MenuItem;
+                                       object ns = ((IStateManager)item).SaveViewState ();
+                                       if (ns != null) {
+                                               hasData = true;
+                                               list.Add (new Pair (n, ns));
+                                       }
+                               }
+                               if (hasData) {
+                                       list.Insert (0, false);
+                                       state = list.ToArray ();
+                               }
+                       }
+                       
+                       if (hasData)
+                               return state;
+                       else
+                               return null;
+               }
+               
+               void IStateManager.TrackViewState ()
+               {
+                       marked = true;
+                       originalItems = new MenuItem [items.Count];
+                       for (int n=0; n<items.Count; n++) {
+                               originalItems [n] = (MenuItem) items [n];
+                               ((IStateManager)originalItems [n]).TrackViewState ();
+                       }
+               }
+               
+               bool IStateManager.IsTrackingViewState {
+                       get { return marked; }
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemStyle.cs b/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemStyle.cs
new file mode 100644 (file)
index 0000000..85f99a6
--- /dev/null
@@ -0,0 +1,149 @@
+//
+// System.Web.UI.WebControls.MenuItemStyle.cs
+//
+// Authors:
+//     Lluis Sanchez Gual (lluis@novell.com)
+//
+// (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+#if NET_2_0
+
+using System;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+       public class MenuItemStyle: Style
+       {
+               private static int HORZ_PADD = (0x01 << 16);
+               private static int SPACING = (0x01 << 17);
+               private static int VERT_PADD = (0x01 << 18);
+               
+               [DefaultValue (0)]
+               [NotifyParentProperty (true)]
+               public int HorizontalPadding {
+                       get {
+                               if(IsSet(HORZ_PADD))
+                                       return (int)(ViewState["HorizontalPadding"]);
+                               return 0;
+                       }
+                       set {
+                               ViewState["HorizontalPadding"] = value;
+                               Set(HORZ_PADD);
+                       }
+               }
+
+               [DefaultValue (0)]
+               [NotifyParentProperty (true)]
+               public int VerticalPadding {
+                       get {
+                               if(IsSet(VERT_PADD))
+                                       return (int)(ViewState["VerticalPadding"]);
+                               return 0;
+                       }
+                       set {
+                               ViewState["VerticalPadding"] = value;
+                               Set(VERT_PADD);
+                       }
+               }
+
+               [DefaultValue (0)]
+               [NotifyParentProperty (true)]
+               public int ItemSpacing {
+                       get {
+                               if(IsSet(SPACING))
+                                       return (int)(ViewState["ItemSpacing"]);
+                               return 0;
+                       }
+                       set {
+                               ViewState["ItemSpacing"] = value;
+                               Set(SPACING);
+                       }
+               }
+
+               protected internal override bool IsEmpty {
+                       get { return base.IsEmpty; }
+               }
+               
+               public override void CopyFrom (Style s)
+               {
+                       if (s == null || s.IsEmpty)
+                               return;
+
+                       base.CopyFrom (s);
+                       MenuItemStyle from = s as MenuItemStyle;
+                       if (from == null)
+                               return;
+
+                       if (from.IsSet (HORZ_PADD))
+                               HorizontalPadding = from.HorizontalPadding;
+
+                       if (from.IsSet (SPACING))
+                               ItemSpacing = from.ItemSpacing;
+
+                       if (from.IsSet (VERT_PADD))
+                               VerticalPadding = from.VerticalPadding;
+               }
+               
+               public override void MergeWith(Style s)
+               {
+                       if(s != null && !s.IsEmpty)
+                       {
+                               if (IsEmpty) {
+                                       CopyFrom (s);
+                                       return;
+                               }
+                               base.MergeWith(s);
+
+                               MenuItemStyle with = s as MenuItemStyle;
+                               if (with == null) return;
+                               
+                               if (with.IsSet(HORZ_PADD) && !IsSet(HORZ_PADD)) {
+                                       HorizontalPadding = with.HorizontalPadding;
+                               }
+                               if (with.IsSet(SPACING) && !IsSet(SPACING)) {
+                                       ItemSpacing = with.ItemSpacing;
+                               }
+                               if (with.IsSet(VERT_PADD) && !IsSet(VERT_PADD)) {
+                                       VerticalPadding = with.VerticalPadding;
+                               }
+                       }
+               }
+
+               public override void Reset()
+               {
+                       if(IsSet(HORZ_PADD))
+                               ViewState.Remove("HorizontalPadding");
+                       if(IsSet(SPACING))
+                               ViewState.Remove("ItemSpacing");
+                       if(IsSet(VERT_PADD))
+                               ViewState.Remove("VerticalPadding");
+                       base.Reset();
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemStyleCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/MenuItemStyleCollection.cs
new file mode 100644 (file)
index 0000000..c9413e0
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// System.Web.UI.WebControls.MenuItemStyleCollection.cs
+//
+// Authors:
+//     Lluis Sanchez Gual (lluis@novell.com)
+//
+// (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+       public sealed class MenuItemStyleCollection: StateManagedCollection
+       {
+               static Type[] types = new Type[] { typeof (MenuItemStyle) };
+               
+               internal MenuItemStyleCollection ()
+               {
+               }
+               
+               public int Add (MenuItemStyle style)
+               {
+                       return ((IList)this).Add (style);
+               }
+               
+               public bool Contains (MenuItemStyle style)
+               {
+                       return ((IList)this).Contains (style);
+               }
+               
+               public void CopyTo (MenuItemStyle[] array, int index)
+               {
+                       ((IList)this).CopyTo (array, index);
+               }
+               
+               protected override object CreateKnownType (int index)
+               {
+                       return new MenuItemStyle ();
+               }
+               
+               protected override Type[] GetKnownTypes ()
+               {
+                       return types;
+               }
+               
+               public int IndexOf (MenuItemStyle style)
+               {
+                       return ((IList)this).IndexOf (style);
+               }
+               
+               public void Insert (int index, MenuItemStyle style)
+               {
+                       ((IList)this).Insert (index, style);
+               }
+               
+               public void Remove (MenuItemStyle style)
+               {
+                       ((IList)this).Remove (style);
+               }
+               
+               public void RemoveAt (int index)
+               {
+                       ((IList)this).RemoveAt (index);
+               }
+               
+               public MenuItemStyle this [int i] {
+                       get { return (MenuItemStyle) ((IList)this) [i]; }
+                       set { ((IList)this) [i] = value; }
+               }
+               
+               protected override void SetDirtyObject (object o)
+               {
+                       ((MenuItemStyle)o).SetDirty ();
+               }
+       }
+}
+
+#endif
index 1499d9f26a0aa2da021f81f1874bdb648305ddd1..9a6f440d5a320817a094f4749fef48988af305df 100644 (file)
@@ -630,7 +630,7 @@ namespace System.Web.UI.WebControls
                        bool foundBranch = true;
                        while (col.Count > 0 && foundBranch) {
                                foundBranch = false;
-                               foreach (TreeNode node in Nodes) {
+                               foreach (TreeNode node in col) {
                                        if (node.Value == path [n]) {
                                                if (++n == path.Length) return node;
                                                col = node.ChildNodes;
@@ -766,7 +766,6 @@ namespace System.Web.UI.WebControls
                                ((IStateManager)Nodes).LoadViewState(states[9]);
                }
 
-               [MonoTODO]
                void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
                {
                        string[] args = eventArgument.Split ('|');