* ToolBar.cs: Added support for displaying ContextMenu
authorRavindra <ravindra@mono-cvs.ximian.com>
Thu, 9 Dec 2004 16:30:00 +0000 (16:30 -0000)
committerRavindra <ravindra@mono-cvs.ximian.com>
Thu, 9 Dec 2004 16:30:00 +0000 (16:30 -0000)
        attached to a button on ToolBar.
        * ToolBarButton.cs: Uncomment/fixed the DropDownMenu
        property.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBar.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBarButton.cs

index d8fac33ae7973fbf493a290d0108768307de09bb..99042ed19111563d081eecb234591ad02aecf428 100644 (file)
@@ -1,3 +1,10 @@
+2004-12-09  Ravindra  <rkumar@novell.com>
+
+       * ToolBar.cs: Added support for displaying ContextMenu
+       attached to a button on ToolBar.
+       * ToolBarButton.cs: Uncomment/fixed the DropDownMenu
+       property.
+
 2004-12-09  Jordi Mas i Hernandez <jordi@ximian.com>
 
        * Label.cs: autosize works in text change and removes unnecessary
index c2a69b8ddb560a050e2743f181c058de05a2603d..eefa291438f98ce568901e19e5bf7db2c0c9e9f5 100644 (file)
@@ -24,7 +24,6 @@
 //     Ravindra (rkumar@novell.com)
 //
 // TODO:
-//   - DropDown ContextMenu
 //   - Tooltip
 //
 // Copyright (C) Novell, Inc. 2004 (http://www.novell.com)
@@ -543,16 +542,18 @@ namespace System.Windows.Forms
 
                protected virtual void OnButtonDropDown (ToolBarButtonClickEventArgs e) 
                {
-                       // if (e.Button.DropDownMenu == null) return;
-                       // TODO: Display the dropdown menu
-
                        // Reset the flag set on DropDown
                        e.Button.dd_pressed = false;
 
                        if (ButtonDropDown != null)
                                ButtonDropDown (this, e);
-                       else
+
+                       if (e.Button.DropDownMenu == null)
                                return;
+
+                       Point loc = new Point (e.Button.Location.X + 1,
+                                              e.Button.Rectangle.Bottom + 2);
+                       ((ContextMenu) e.Button.DropDownMenu).Show (this, loc);
                }
 
                protected override void OnFontChanged (EventArgs e)
index 498dbd7bef0ecb383ad6b7bae96d0213ab774c37..f5943702274a091ffa57cddda527b14572ebdc53 100644 (file)
@@ -26,7 +26,6 @@
 //     Ravindra (rkumar@novell.com)
 //
 // TODO:
-//     - DropDownMenu
 //     - Adding a button to two toolbars
 //
 // $Revision: 1.9 $
@@ -81,9 +80,9 @@ namespace System.Windows.Forms
        public class ToolBarButton : Component
        {
                #region instance variable
-               //private ContextMenu menu; //NotImplemented
                private bool enabled = true;
                private int image_index = -1;
+               private ContextMenu menu;
                private ToolBar parent;
                private bool partial_push = false;
                private bool pushed = false;
@@ -143,7 +142,6 @@ namespace System.Windows.Forms
                #endregion internal properties
 
                #region properties
-               /*
                [DefaultValue (null)]
                [TypeConverter (typeof (ReferenceConverter))]
                public Menu DropDownMenu {
@@ -151,12 +149,11 @@ namespace System.Windows.Forms
 
                        set {
                                if (value is ContextMenu)
-                                       menu = value;
+                                       menu = (ContextMenu) value;
                                else
                                        throw new ArgumentException ("DropDownMenu must be of type ContextMenu.");
                        }
                }
-               */
 
                [DefaultValue (true)]
                [Localizable (true)]