dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms Menu.cs,NONE,1.1


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms Menu.cs,NONE,1.1 MenuItem.cs,NONE,1.1 ContextMenu.cs,1.1,1.2 Control.cs,1.19,1.20 Form.cs,1.13,1.14 MainMenu.cs,1.1,1.2
Date: Mon, 23 Jun 2003 19:12:09 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv24156/System.Windows.Forms

Modified Files:
        ContextMenu.cs Control.cs Form.cs MainMenu.cs 
Added Files:
        Menu.cs MenuItem.cs 
Log Message:


Stub out the menu-related classes in Forms.


--- NEW FILE ---
/*
 * Menu.cs - Implementation of the "System.Windows.Forms.Menu" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Windows.Forms
{

using System.ComponentModel;
using System.Collections;

public abstract class Menu
#if CONFIG_COMPONENT_MODEL
        : Component
#endif
{
        // Internal state.
        private int numItems;
        private MenuItem[] itemList;
        private MenuItemCollection items;
        private int suppressUpdates;

        // Constructor.
        protected Menu(MenuItem[] items)
                        {
                                if(items != null)
                                {
                                        this.numItems = items.Length;
                                        this.itemList = new MenuItem [numItems];
                                        Array.Copy(items, 0, this.itemList, 0, 
numItems);
                                        this.items = null;
                                        this.suppressUpdates = 0;
                                }
                                else
                                {
                                        this.numItems = 0;
                                        this.itemList = new MenuItem [0];
                                        this.items = null;
                                        this.suppressUpdates = 0;
                                }
                        }

        // Suppress updates on this menu while it is being modified.
        internal void SuppressUpdates()
                        {
                                ++suppressUpdates;
                        }

        // Allow updates on this menu after it was modified.
        [TODO]
        internal void AllowUpdates()
                        {
                                --suppressUpdates;
                                if(suppressUpdates == 0)
                                {
                                        // TODO: force a repaint/recalc of the 
menu
                                }
                        }

        // Get or set this object's properties.
        public IntPtr Handle
                        {
                                get
                                {
                                        // Menu handles are not used in this 
implementation.
                                        return IntPtr.Zero;
                                }
                        }
        public virtual bool IsParent
                        {
                                get
                                {
                                        return (numItems > 0);
                                }
                        }
        public MenuItem MdiListItem
                        {
                                get
                                {
                                        int index;
                                        MenuItem list;
                                        for(index = 0; index < numItems; 
++index)
                                        {
                                                if(itemList[index].MdiList)
                                                {
                                                        return itemList[index];
                                                }
                                                else
                                                {
                                                        list = 
itemList[index].MdiListItem;
                                                        if(list != null)
                                                        {
                                                                return list;
                                                        }
                                                }
                                        }
                                        return null;
                                }
                        }
        public MenuItemCollection MenuItems
                        {
                                get
                                {
                                        if(items == null)
                                        {
                                                items = new 
MenuItemCollection(this);
                                        }
                                        return items;
                                }
                        }

        // Get the context menu that contains this item.
        public ContextMenu GetContextMenu()
                        {
                                Menu menu = this;
                                while(menu != null && !(menu is ContextMenu))
                                {
                                        if(menu is MenuItem)
                                        {
                                                menu = ((MenuItem)menu).parent;
                                        }
                                        else
                                        {
                                                return null;
                                        }
                                }
                                return (ContextMenu)menu;
                        }

        // Get the main menu that contains this item.
        public MainMenu GetMainMenu()
                        {
                                Menu menu = this;
                                while(menu != null && !(menu is MainMenu))
                                {
                                        if(menu is MenuItem)
                                        {
                                                menu = ((MenuItem)menu).parent;
                                        }
                                        else
                                        {
                                                return null;
                                        }
                                }
                                return (MainMenu)menu;
                        }

        // Merge another menu with this one.
        [TODO]
        public virtual void MergeMenu(Menu menuSrc)
                        {
                                // TODO
                        }

        // Convert this object into a string.
        public override String ToString()
                        {
                                return base.ToString() + ", Item.Count=" + 
numItems.ToString();
                        }

        // Clone the contents of another menu into this one.
        [TODO]
        protected void CloneMenu(Menu menuSrc)
                        {
                                // TODO
                        }

        // Collection of menu items.
        public class MenuItemCollection : IList, ICollection, IEnumerable
        {
                // Internal State.
                private Menu owner;

                // Constructor.
                public MenuItemCollection(Menu owner)
                                {
                                        this.owner = owner;
                                }

                // Retrieve a particular item from this collection.
                public virtual MenuItem this[int index]
                                {
                                        get
                                        {
                                                if(index < 0 || index >= 
owner.numItems)
                                                {
                                                        throw new 
ArgumentOutOfRangeException
                                                                ("index", 
S._("SWF_MenuItemIndex"));
                                                }
                                                return owner.itemList[index];
                                        }
                                }

                // Implement the ICollection interface.
                public void CopyTo(Array array, int index)
                                {
                                        IEnumerator e = GetEnumerator();
                                        while(e.MoveNext())
                                        {
                                                array.SetValue(e.Current, 
index);
                                        }
                                }
                public int Count
                                {
                                        get
                                        {
                                                return owner.numItems;
                                        }
                                }
                bool ICollection.IsSynchronized
                                {
                                        get
                                        {
                                                return false;
                                        }
                                }
                Object ICollection.SyncRoot
                                {
                                        get
                                        {
                                                return this;
                                        }
                                }

                // Implement the IList interface.
                int IList.Add(Object value)
                                {
                                        MenuItem item = (value as MenuItem);
                                        if(item != null)
                                        {
                                                return Add(item);
                                        }
                                        else
                                        {
                                                throw new ArgumentException
                                                        
(S._("SWF_InvalidMenuItem"), "value");
                                        }
                                }
                public void Clear()
                                {
                                        if(owner.numItems != 0)
                                        {
                                                owner.SuppressUpdates();
                                                while(owner.numItems > 0)
                                                {
                                                        RemoveAt(owner.numItems 
- 1);
                                                }
                                                owner.AllowUpdates();
                                        }
                                }
                bool IList.Contains(Object value)
                                {
                                        MenuItem item = (value as MenuItem);
                                        if(item != null)
                                        {
                                                return Contains(item);
                                        }
                                        else
                                        {
                                                return false;
                                        }
                                }
                int IList.IndexOf(Object value)
                                {
                                        MenuItem item = (value as MenuItem);
                                        if(item != null)
                                        {
                                                return IndexOf(item);
                                        }
                                        else
                                        {
                                                return -1;
                                        }
                                }
                void IList.Insert(int index, Object value)
                                {
                                        MenuItem item = (value as MenuItem);
                                        if(item != null)
                                        {
                                                Add(index, item);
                                        }
                                        else
                                        {
                                                throw new ArgumentException
                                                        
(S._("SWF_InvalidMenuItem"), "value");
                                        }
                                }
                void IList.Remove(Object value)
                                {
                                        MenuItem item = (value as MenuItem);
                                        if(item != null)
                                        {
                                                Remove(item);
                                        }
                                }
                public virtual void RemoveAt(int index)
                                {
                                        if(index < 0 || index >= owner.numItems)
                                        {
                                                throw new 
ArgumentOutOfRangeException
                                                        ("index", 
S._("SWF_MenuItemIndex"));
                                        }
                                        else
                                        {
                                                owner.SuppressUpdates();
                                                owner.itemList[index].parent = 
null;
                                                MenuItem[] items = new MenuItem 
[owner.numItems - 1];
                                                Array.Copy(owner.itemList, 0, 
items, 0, index);
                                                Array.Copy(owner.itemList, 
index + 1, items, index,
                                                                   
owner.numItems - index - 1);
                                                owner.itemList = items;
                                                --(owner.numItems);
                                                owner.AllowUpdates();
                                        }
                                }
                bool IList.IsFixedSize
                                {
                                        get
                                        {
                                                return false;
                                        }
                                }
                bool IList.IsReadOnly
                                {
                                        get
                                        {
                                                return false;
                                        }
                                }
                Object IList.this[int index]
                                {
                                        get
                                        {
                                                return this[index];
                                        }
                                        set
                                        {
                                                throw new 
NotSupportedException();
                                        }
                                }

                // Implement the IEnumerable interface.
                public IEnumerator GetEnumerator()
                                {
                                        return owner.itemList.GetEnumerator();
                                }

                // Add a menu item to this menu.
                public virtual int Add(MenuItem item)
                                {
                                        return Add(owner.numItems, item);
                                }
                public virtual int Add(int index, MenuItem item)
                                {
                                        if(item == null)
                                        {
                                                throw new 
ArgumentNullException("item");
                                        }
                                        else if(item.parent != null)
                                        {
                                                throw new ArgumentException
                                                        
(S._("SWF_ItemAlreadyInUse"), "item");
                                        }
                                        if(index < 0 || index > owner.numItems)
                                        {
                                                throw new 
ArgumentOutOfRangeException
                                                        ("index", 
S._("SWF_MenuItemIndex"));
                                        }
                                        owner.SuppressUpdates();
                                        MenuItem[] items = new MenuItem 
[owner.numItems + 1];
                                        Array.Copy(owner.itemList, 0, items, 0, 
index);
                                        items[index] = item;
                                        item.parent = owner;
                                        if(index < owner.numItems)
                                        {
                                                Array.Copy(owner.itemList, 
index, items, index + 1,
                                                                   
owner.numItems - index);
                                        }
                                        owner.itemList = items;
                                        ++(owner.numItems);
                                        owner.AllowUpdates();
                                        return index;
                                }
                public virtual MenuItem Add(String caption)
                                {
                                        MenuItem item = new MenuItem(caption);
                                        Add(item);
                                        return item;
                                }
                public virtual MenuItem Add(String caption, EventHandler 
onClick)
                                {
                                        MenuItem item = new MenuItem(caption, 
onClick);
                                        Add(item);
                                        return item;
                                }
                public virtual MenuItem Add(String caption, MenuItem[] items)
                                {
                                        MenuItem item = new MenuItem(caption, 
items);
                                        Add(item);
                                        return item;
                                }

                // Add a range of menu items to this menu.
                public virtual void AddRange(MenuItem[] items)
                                {
                                        if(items == null)
                                        {
                                                throw new 
ArgumentNullException("items");
                                        }
                                        owner.SuppressUpdates();
                                        foreach(MenuItem item in items)
                                        {
                                                Add(owner.numItems, item);
                                        }
                                        owner.AllowUpdates();
                                }

                // Determine if this menu contains a particular item
                public bool Contains(MenuItem item)
                                {
                                        foreach(MenuItem i in owner.itemList)
                                        {
                                                if(i == item)
                                                {
                                                        return true;
                                                }
                                        }
                                        return false;
                                }

                // Get the index of a specific menu item.
                public int IndexOf(MenuItem item)
                                {
                                        int index;
                                        for(index = 0; index < owner.numItems; 
++index)
                                        {
                                                if(owner.itemList[index] == 
item)
                                                {
                                                        return index;
                                                }
                                        }
                                        return -1;
                                }

                // Remove a specific menu item.
                public virtual void Remove(MenuItem item)
                                {
                                        owner.SuppressUpdates();
                                        int index = IndexOf(item);
                                        if(index != -1)
                                        {
                                                owner.itemList[index].parent = 
null;
                                                MenuItem[] items = new MenuItem 
[owner.numItems - 1];
                                                Array.Copy(owner.itemList, 0, 
items, 0, index);
                                                Array.Copy(owner.itemList, 
index + 1, items, index,
                                                                   
owner.numItems - index - 1);
                                                owner.itemList = items;
                                                --(owner.numItems);
                                        }
                                        owner.AllowUpdates();
                                }

                // Move a menu item to a new position.
                internal void Move(MenuItem item, int index)
                                {
                                        if(index < 0 || index >= owner.numItems)
                                        {
                                                throw new 
ArgumentOutOfRangeException
                                                        ("index", 
S._("SWF_MenuItemIndex"));
                                        }
                                        int oldIndex = IndexOf(item);
                                        owner.SuppressUpdates();
                                        if(index < oldIndex)
                                        {
                                                RemoveAt(oldIndex);
                                                Add(index, item);
                                        }
                                        else if(index > oldIndex)
                                        {
                                                RemoveAt(oldIndex);
                                                Add(index - 1, item);
                                        }
                                        owner.AllowUpdates();
                                }

        }; // class MenuItemCollection

}; // class Menu

}; // namespace System.Windows.Forms

--- NEW FILE ---
/*
 * MenuItem.cs - Implementation of the "System.Windows.Forms.MenuItem" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Windows.Forms
{

public class MenuItem : Menu
{
        // Internal state.
        internal Menu parent;
        private ItemFlags flags;
        private int mergeOrder;
        private MenuMerge mergeType;
        private Shortcut shortcut;
        private String text;

        // Flag bits for the menu item's state.
        [Flags]
        private enum ItemFlags
        {
                BarBreak                = 0x0001,
                Break                   = 0x0002,
                Checked                 = 0x0004,
                DefaultItem             = 0x0008,
                Enabled                 = 0x0010,
                MdiList                 = 0x0020,
                OwnerDraw               = 0x0040,
                RadioCheck              = 0x0080,
                ShowShortcut    = 0x0100,
                Visible                 = 0x0200,
                Default                 = Enabled | ShowShortcut | Visible,

        }; // enum ItemFlags

        // Constructors.
        public MenuItem()
                        : this(MenuMerge.Add, 0, Shortcut.None, null,
                               null, null, null, null) {}
        public MenuItem(String text)
                        : this(MenuMerge.Add, 0, Shortcut.None, text,
                                   null, null, null, null) {}
        public MenuItem(String text, EventHandler onClick)
                        : this(MenuMerge.Add, 0, Shortcut.None, text,
                                   onClick, null, null, null) {}
        public MenuItem(String text, MenuItem[] items)
                        : this(MenuMerge.Add, 0, Shortcut.None, text,
                                   null, null, null, items) {}
        public MenuItem(String text, EventHandler onClick, Shortcut shortcut)
                        : this(MenuMerge.Add, 0, shortcut, text,
                                   onClick, null, null, null) {}
        public MenuItem(MenuMerge mergeType, int mergeOrder, Shortcut shortcut,
                                        String text, EventHandler onClick, 
EventHandler onPopup,
                                        EventHandler onSelect, MenuItem[] items)
                        : base(items)
                        {
                                this.flags = ItemFlags.Default;
                                this.mergeType = mergeType;
                                this.mergeOrder = mergeOrder;
                                this.shortcut = shortcut;
                                this.text = text;
                                if(onClick != null)
                                {
                                        Click += onClick;
                                }
                                if(onPopup != null)
                                {
                                        Popup += onPopup;
                                }
                                if(onSelect != null)
                                {
                                        Select += onSelect;
                                }
                        }

        // Update this menu item after a non-trivial state change.
        [TODO]
        private void UpdateMenuItem()
                        {
                                // TODO
                        }

        // Get the value of a menu item flag.
        private bool GetFlag(ItemFlags flag)
                        {
                                return ((flags & flag) != 0);
                        }

        // Set the value of a menu item flag.
        private void SetFlag(ItemFlags flag, bool value)
                        {
                                if(value != ((flags & flag) != 0))
                                {
                                        // The flag has been changed.
                                        if(value)
                                        {
                                                flags |= flag;
                                        }
                                        else
                                        {
                                                flags &= ~flag;
                                        }
                                        UpdateMenuItem();
                                }
                        }

        // Get or set this item's properties.
        public bool BarBreak
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.BarBreak);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.BarBreak, value);
                                }
                        }
        public bool Break
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.Break);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.Break, value);
                                }
                        }
        public bool Checked
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.Checked);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.Checked, value);
                                }
                        }
        public bool DefaultItem
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.DefaultItem);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.DefaultItem, value);
                                }
                        }
        public bool Enabled
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.Enabled);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.Enabled, value);
                                }
                        }
        public int Index
                        {
                                get
                                {
                                        if(parent != null)
                                        {
                                                return 
parent.MenuItems.IndexOf(this);
                                        }
                                        else
                                        {
                                                return -1;
                                        }
                                }
                                set
                                {
                                        if(parent != null)
                                        {
                                                parent.MenuItems.Move(this, 
value);
                                        }
                                }
                        }
        public override bool IsParent
                        {
                                get
                                {
                                        if(GetFlag(ItemFlags.MdiList))
                                        {
                                                return true;
                                        }
                                        else
                                        {
                                                return base.IsParent;
                                        }
                                }
                        }
        public bool MdiList
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.MdiList);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.MdiList, value);
                                }
                        }
        public int MergeOrder
                        {
                                get
                                {
                                        return mergeOrder;
                                }
                                set
                                {
                                        mergeOrder = value;
                                }
                        }
        public MenuMerge MergeType
                        {
                                get
                                {
                                        return mergeType;
                                }
                                set
                                {
                                        mergeType = value;
                                }
                        }
        public char Mnemonic
                        {
                                get
                                {
                                        String text = Text;
                                        if(text != null)
                                        {
                                                int index = text.IndexOf('&');
                                                if(index != -1 && (index + 1) < 
text.Length)
                                                {
                                                        return 
Char.ToUpper(text[index + 1]);
                                                }
                                        }
                                        return '\0';
                                }
                        }
        public bool OwnerDraw
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.OwnerDraw);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.OwnerDraw, value);
                                }
                        }
        public Menu Parent
                        {
                                get
                                {
                                        return parent;
                                }
                        }
        public bool RadioCheck
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.RadioCheck);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.RadioCheck, value);
                                }
                        }
        public Shortcut Shortcut
                        {
                                get
                                {
                                        return shortcut;
                                }
                                set
                                {
                                        if(shortcut != value)
                                        {
                                                shortcut = value;
                                                UpdateMenuItem();
                                        }
                                }
                        }
        public bool ShowShortcut
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.ShowShortcut);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.ShowShortcut, value);
                                }
                        }
        public String Text
                        {
                                get
                                {
                                        return text;
                                }
                                set
                                {
                                        if(text != value)
                                        {
                                                text = value;
                                                UpdateMenuItem();
                                        }
                                }
                        }
        public bool Visible
                        {
                                get
                                {
                                        return GetFlag(ItemFlags.Visible);
                                }
                                set
                                {
                                        SetFlag(ItemFlags.Visible, value);
                                }
                        }
        protected int MenuID
                        {
                                get
                                {
                                        // Menu identifiers are not used, so 
just return the index.
                                        return Index;
                                }
                        }

        // Create a copy of the current menu item.
        public virtual MenuItem CloneMenu()
                        {
                                // TODO
                                return this;
                        }
        protected void CloneMenu(MenuItem itemSrc)
                        {
                                // TODO
                        }

        // Merge this menu item with another.
        public virtual MenuItem MergeMenu()
                        {
                                // TODO
                                return this;
                        }
        public void MergeMenu(MenuItem itemSrc)
                        {
                                // TODO
                        }

        // Generate a "Click" event from this menu item.
        public void PerformClick()
                        {
                                OnClick(EventArgs.Empty);
                        }

        // Generate a "Select" event from this menu item.
        public virtual void PerformSelect()
                        {
                                OnSelect(EventArgs.Empty);
                        }

        // Convert this object into a string.
        public override String ToString()
                        {
                                return base.ToString() + ", Text: " + text;
                        }

        // Event that is raised when this menu item is clicked.
        public event EventHandler Click;

        // Event that is raised when this owner-draw item must be drawn.
        public event DrawItemEventHandler DrawItem;

        // Event that is raised when this owner-draw item must be measured.
        public event MeasureItemEventHandler MeasureItem;

        // Event that is raised just before a menu is popped up.
        public event EventHandler Popup;

        // Event that is raised when the cursor moves over a menu item.
        public event EventHandler Select;

        // Raise the "Click" event.
        protected virtual void OnClick(EventArgs e)
                        {
                                if(Click != null)
                                {
                                        Click(this, e);
                                }
                        }

        // Raise the "DrawItem" event.
        protected virtual void OnDrawItem(DrawItemEventArgs e)
                        {
                                if(DrawItem != null)
                                {
                                        DrawItem(this, e);
                                }
                        }

        // Raise the "MeasureItem" event.
        protected virtual void OnMeasureItem(MeasureItemEventArgs e)
                        {
                                if(MeasureItem != null)
                                {
                                        MeasureItem(this, e);
                                }
                        }

        // Raise the "Popup" event.
        protected virtual void OnPopup(EventArgs e)
                        {
                                if(Popup != null)
                                {
                                        Popup(this, e);
                                }
                        }

        // Raise the "Select" event.
        protected virtual void OnSelect(EventArgs e)
                        {
                                if(Select != null)
                                {
                                        Select(this, e);
                                }
                        }

}; // class MenuItem

}; // namespace System.Windows.Forms

Index: ContextMenu.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/ContextMenu.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ContextMenu.cs      11 Jun 2003 07:07:19 -0000      1.1
--- ContextMenu.cs      23 Jun 2003 23:12:07 -0000      1.2
***************
*** 23,29 ****
  {
  
! public class ContextMenu
  {
!       // TODO
  
  }; // class ContextMenu
--- 23,103 ----
  {
  
! using System.Drawing;
! 
! public class ContextMenu : Menu
  {
!       // Internal state.
!       private RightToLeft rightToLeft;
!       private Control sourceControl;
! 
!       // Constructors.
!       public ContextMenu() : base(null)
!                       {
!                               rightToLeft = RightToLeft.Inherit;
!                       }
!       public ContextMenu(MenuItem[] items) : base(items)
!                       {
!                               rightToLeft = RightToLeft.Inherit;
!                       }
! 
!       // Get or set the right-to-left property.
!       public virtual RightToLeft RightToLeft
!                       {
!                               get
!                               {
!                                       if(rightToLeft != RightToLeft.Inherit)
!                                       {
!                                               return rightToLeft;
!                                       }
!                                       else if(sourceControl != null)
!                                       {
!                                               return 
sourceControl.RightToLeft;
!                                       }
!                                       else
!                                       {
!                                               return RightToLeft.No;
!                                       }
!                               }
!                               set
!                               {
!                                       if(rightToLeft != value)
!                                       {
!                                               SuppressUpdates();
!                                               rightToLeft = value;
!                                               AllowUpdates();
!                                       }
!                               }
!                       }
! 
!       // Get the control that owns this context menu.
!       public Control SourceControl
!                       {
!                               get
!                               {
!                                       return sourceControl;
!                               }
!                       }
! 
!       // Show this context menu at the specified control-relative 
co-ordinates.
!       [TODO]
!       public void Show(Control control, Point pos)
!                       {
!                               // TODO: display the menu and wait for it to be 
dismissed
!                       }
! 
!       // Event that is emitted just before the menu pops up.
!       public event EventHandler Popup;
! 
!       // Add this main menu to a control.
!       internal void AddToControl(Control control)
!                       {
!                               sourceControl = control;
!                       }
! 
!       // Remove this main menu from its owning control.
!       internal void RemoveFromControl()
!                       {
!                               sourceControl = null;
!                       }
  
  }; // class ContextMenu

Index: Control.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Control.cs,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** Control.cs  23 Jun 2003 05:35:20 -0000      1.19
--- Control.cs  23 Jun 2003 23:12:07 -0000      1.20
***************
*** 67,70 ****
--- 67,71 ----
        private ControlStyles styles;
        private CreateParams createParams;
+       private ContextMenu contextMenu;
        private static Font defaultFont;
  #if !CONFIG_COMPACT_FORMS
***************
*** 440,454 ****
                                }
                        }
-       [TODO]
        public ContextMenu ContextMenu
                        {
                                get
                                {
!                                       // TODO
!                                       return null;
                                }
                                set
                                {
!                                       // TODO
                                }
                        }
--- 441,472 ----
                                }
                        }
        public ContextMenu ContextMenu
                        {
                                get
                                {
!                                       return contextMenu;
                                }
                                set
                                {
!                                       if(contextMenu != null)
!                                       {
!                                               if(contextMenu != null)
!                                               {
!                                                       
contextMenu.RemoveFromControl();
!                                               }
!                                               if(value != null)
!                                               {
!                                                       Control control = 
value.SourceControl;
!                                                       if(control != null)
!                                                       {
!                                                               
control.ContextMenu = null;
!                                                       }
!                                               }
!                                               contextMenu = value;
!                                               if(contextMenu != null)
!                                               {
!                                                       
contextMenu.AddToControl(this);
!                                               }
!                                       }
                                }
                        }

Index: Form.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Form.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** Form.cs     23 Jun 2003 05:35:20 -0000      1.13
--- Form.cs     23 Jun 2003 23:12:07 -0000      1.14
***************
*** 391,395 ****
                                set
                                {
!                                       menu = value;
                                }
                        }
--- 391,414 ----
                                set
                                {
!                                       if(menu != value)
!                                       {
!                                               if(menu != null)
!                                               {
!                                                       menu.RemoveFromForm();
!                                               }
!                                               if(value != null)
!                                               {
!                                                       Form other = 
value.GetForm();
!                                                       if(other != null)
!                                                       {
!                                                               other.Menu = 
null;
!                                                       }
!                                               }
!                                               menu = value;
!                                               if(menu != null)
!                                               {
!                                                       menu.AddToForm(this);
!                                               }
!                                       }
                                }
                        }

Index: MainMenu.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/MainMenu.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** MainMenu.cs 12 Jun 2003 05:50:29 -0000      1.1
--- MainMenu.cs 23 Jun 2003 23:12:07 -0000      1.2
***************
*** 23,30 ****
  {
  
! [TODO]
! public class MainMenu
  {
!       // TODO
  
  }; // class MainMenu
--- 23,120 ----
  {
  
! public class MainMenu : Menu
  {
!       // Internal state.
!       private RightToLeft rightToLeft;
!       private Form ownerForm;
! 
!       // Constructors.
!       public MainMenu() : base(null)
!                       {
!                               rightToLeft = RightToLeft.Inherit;
!                       }
!       public MainMenu(MenuItem[] items) : base(items)
!                       {
!                               rightToLeft = RightToLeft.Inherit;
!                       }
! 
!       // Get or set the right-to-left property.
!       public virtual RightToLeft RightToLeft
!                       {
!                               get
!                               {
!                                       if(rightToLeft != RightToLeft.Inherit)
!                                       {
!                                               return rightToLeft;
!                                       }
!                                       else if(ownerForm != null)
!                                       {
!                                               return ownerForm.RightToLeft;
!                                       }
!                                       else
!                                       {
!                                               return RightToLeft.No;
!                                       }
!                               }
!                               set
!                               {
!                                       if(rightToLeft != value)
!                                       {
!                                               SuppressUpdates();
!                                               rightToLeft = value;
!                                               AllowUpdates();
!                                       }
!                               }
!                       }
! 
!       // Clone this main menu.
!       [TODO]
!       public virtual MainMenu CloneMenu()
!                       {
!                               // TODO
!                               return this;
!                       }
! 
!       // Get the form that owns this menu.
!       public Form GetForm()
!                       {
!                               return ownerForm;
!                       }
! 
!       // Convert this object into a string.
!       public override String ToString()
!                       {
!                               if(ownerForm != null)
!                               {
!                                       return base.ToString() + ", GetForm: " +
!                                                  ownerForm.ToString();
!                               }
!                               else
!                               {
!                                       return base.ToString();
!                               }
!                       }
! 
! #if CONFIG_COMPONENT_MODEL
! 
!       // Dispose of this menu.
!       protected override void Dispose(bool disposing)
!                       {
!                               base.Dispose(disposing);
!                       }
! 
! #endif
! 
!       // Add this main menu to a form.
!       internal void AddToForm(Form form)
!                       {
!                               ownerForm = form;
!                       }
! 
!       // Remove this main menu from its owning form.
!       internal void RemoveFromForm()
!                       {
!                               ownerForm = null;
!                       }
  
  }; // class MainMenu





reply via email to

[Prev in Thread] Current Thread [Next in Thread]