* ContextMenu.cs : SourceControl, Show method
authorAleksey Ryabchuk <aleksey@mono-cvs.ximian.com>
Wed, 11 Jun 2003 16:36:24 +0000 (16:36 -0000)
committerAleksey Ryabchuk <aleksey@mono-cvs.ximian.com>
Wed, 11 Jun 2003 16:36:24 +0000 (16:36 -0000)
* Control.cs : ContextMenu, CanSelect, force parent to perform layout when Dock property changes
* GroupBox.cs
* Label.cs
* Panel.cs
* PictureBox.cs
* Splitter.cs
* ProgressBar.cs : remove Selectable style
* RadioButton.cs : set TextAlign to MiddleLeft by default
* tooltip.cs : override Dispose method
* win32Enums.cs
* win32functions.cs : flags and function for context menu

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

13 files changed:
mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/System.Windows.Forms/System.Windows.Forms/ContextMenu.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/GroupBox.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/Label.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/Panel.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/PictureBox.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/ProgressBar.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/RadioButton.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/Splitter.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/tooltip.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/win32Enums.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs

index 95f79475cd6aefd57275a54adb544b189b0683f7..ca6f3d49d0bfd1213bec859f9aa54bd4260448c4 100644 (file)
@@ -1,3 +1,17 @@
+2003-06-09 Aleksey Ryabchuk <ryabchuk@yahoo.com>
+       * ContextMenu.cs : SourceControl, Show method
+       * Control.cs : ContextMenu, CanSelect, force parent to perform layout when Dock property changes
+       * GroupBox.cs
+       * Label.cs
+       * Panel.cs
+       * PictureBox.cs
+       * Splitter.cs
+       * ProgressBar.cs : remove Selectable style
+       * RadioButton.cs : set TextAlign to MiddleLeft by default
+       * tooltip.cs : override Dispose method
+       * win32Enums.cs
+       * win32functions.cs : flags and function for context menu
+
 2003-06-09 Aleksey Ryabchuk <ryabchuk@yahoo.com>
        * Conrols.cs : Disposing property, Dispose method
        * Cursor.cs  : Show, Hide, Copy cursor
index 4e90b15f4164f359fa1f1174f2a9b7015882f06e..b2fe5bd3af09e142c4eabd666600e1e80b88124f 100644 (file)
@@ -16,7 +16,7 @@ using System.Drawing;
 namespace System.Windows.Forms {
 
        /// <summary>
-       /// Represents a Windows combo box control.
+       /// Represents a shortcut menu
        /// </summary>
 
        [MonoTODO]
@@ -24,12 +24,14 @@ namespace System.Windows.Forms {
 
                // private fields
                RightToLeft rightToLeft;
+               Control sourceControl;
 
                // --- Constructor ---
                [MonoTODO]
                public ContextMenu() : base(null)
                {
                        rightToLeft = RightToLeft.Inherit;
+                       sourceControl = null;
                }
 
                [MonoTODO]
@@ -43,18 +45,28 @@ namespace System.Windows.Forms {
                        set { rightToLeft=value; }
                }
                
-               [MonoTODO]
                public Control SourceControl {
-                       get { throw new NotImplementedException (); }
+                       get { return sourceControl; }
                }
                
                /// --- Methods ---
                /// internal .NET framework supporting methods, not stubbed out:
                /// - protected internal virtual void OnPopup(EventArgs e);
                [MonoTODO]
-               public void Show(Control control,Point pos) 
+               public void Show(Control control, Point pos) 
                {
-                       //FIXME:
+                       if ( Handle == IntPtr.Zero )
+                               return;
+
+                       sourceControl = control;
+
+                       POINT pt = new POINT ();
+                       pt.x = pos.X;
+                       pt.y = pos.Y;
+
+                       Win32.ClientToScreen ( control.Handle, ref pt );
+                       Win32.TrackPopupMenu (  Handle, ( uint ) ( TrackPopupMenuFlags.TPM_LEFTALIGN | TrackPopupMenuFlags.TPM_RIGHTBUTTON ),
+                                               pt.x, pt.y, 0, control.Handle , IntPtr.Zero );
                }
                
                /// events
index 8941d9f92148028d48fc4026e1af04484946ea43..eef0b0ee10805851740f5f8bfcc6ed2ea78ccc1d 100644 (file)
@@ -73,7 +73,7 @@
                Rectangle oldBounds;
 
                bool causesValidation;
-               //ContextMenu contextMenu;
+               ContextMenu contextMenu;
                DockStyle dock;
                bool enabled;
                Font font;
                        oldBounds = new Rectangle();
                        // bindingContext = null;
                        causesValidation = true;
-                       // contextMenu = null;
+                       contextMenu = null;
                        dock = DockStyle.None;
                        enabled = true;
                        // font = Control.DefaultFont;
                [MonoTODO]
                public bool CanSelect {
                        get {
-    //                                 if (ControlStyles.Selectable &&
-    //                                     isContainedInAnotherControl &&
-    //                                     parentIsVisiable && isVisialbe &&
-    //                                     parentIsEnabled && isEnabled) {
-    //                                         return true;
-    //                                 }
-    //                                 return false;
-    
-                               throw new NotImplementedException ();
+                               if ( !GetStyle ( ControlStyles.Selectable ) )
+                                       return false;
+
+                               if ( Parent == null )
+                                       return false;
+
+                               Control parent = Parent;
+                               while ( parent != null ) {
+                                       if ( !parent.Visible || !parent.Enabled )
+                                               return false;
+                                       parent = parent.Parent;
+                               }
+
+                               return true;
                        }
                }
                
                [MonoTODO]
                public virtual ContextMenu ContextMenu {
                        get {
-                               //return contextMenu;
-                               throw new NotImplementedException ();
+                               return contextMenu;
                        }
                        set {
-                               //contextMenu=value;
-                               throw new NotImplementedException ();
+                               if ( contextMenu != value ) {
+                                       contextMenu = value;
+                                       OnContextMenuChanged ( EventArgs.Empty );
+                               }
                        }
                }
                
                
                protected virtual void OnDockChanged (EventArgs e)
                {
-                       PerformLayout ( this, "Dock" );
+                       // changing this property does not affect the control directly
+                       // so have its parent to calculate new layout
+                       if ( Parent != null )
+                               Parent.PerformLayout ( this, "Dock" );
                        if (DockChanged != null)
                                DockChanged (this, e);
                }
                                        } else
                                                CallControlWndProc( ref m );
                                break;
+                               case Msg.WM_RBUTTONDOWN:
+                                       if ( contextMenu != null ) {
+                                               contextMenu.Show ( this, 
+                                                       new Point ( Win32.HIGH_ORDER ( m.LParam.ToInt32() ),
+                                                                   Win32.LOW_ORDER ( m.LParam.ToInt32() ) ) );
+                                       }
+                                       CallControlWndProc( ref m );
+                               break;
                                default:
                                        CallControlWndProc(ref m);
 /*
index 1079e5f487b41655bba8f476c5b639d7682dc4be..9fa973fe5bc3168cff3384483b238f9054ad968e 100644 (file)
@@ -24,6 +24,7 @@ namespace System.Windows.Forms {
                [MonoTODO]
                public GroupBox() {
                        SetStyle ( ControlStyles.UserPaint, true);
+                       SetStyle ( ControlStyles.Selectable, false );
                        TabStop = false;
                        flatStyle = FlatStyle.Standard;
                }
index ca2e048234488aeafc70c2d634b8f1f19800754d..b6d63c4a2ee02f77e579316d977049c00589d03b 100644 (file)
                                autoSize = false;\r
                                borderStyle = BorderStyle.None;\r
                                base.TabStop = false;\r
-                               //Defaults not in the spec\r
-                               Image backgroundImage;\r
-                               Image image;\r
-                               ContentAlignment imageAlign;\r
-                               ImeMode defaultImeMode;\r
-                               bool renderTransparent;\r
-                               FlatStyle flatStyle;\r
-                               int preferredHeight;\r
-                               int preferredWidth;\r
-                               bool tabStop;\r
-                               ContentAlignment textAlign;\r
-                               bool useMnemonic;\r
-\r
+                               \r
                                SubClassWndProc_ = true;\r
+                       SetStyle ( ControlStyles.Selectable, false );
                }\r
                \r
                //\r
index 8bfd464685acda38e737350c1eb35aff81afb471..35776b92738c89f15fcb43cb75521aed7d60f86f 100644 (file)
@@ -24,7 +24,8 @@ namespace System.Windows.Forms {
                //
                [MonoTODO]
                public Panel() {
-                       controlStyles_ |= ControlStyles.UserPaint;
+                       SetStyle ( ControlStyles.Selectable, false );
+                       SetStyle ( ControlStyles.UserPaint,  true  );
                }
 
                //
index 1ed7c26ebe0730f2b921eb7935d373f44b35778d..8366eb38b12396dfcb87a3b4deb526c7befc817d 100644 (file)
@@ -27,6 +27,7 @@ namespace System.Windows.Forms {
                        sizeMode = PictureBoxSizeMode.Normal;
                        borderStyle = BorderStyle.None;
                        SetStyle ( ControlStyles.UserPaint, true );
+                       SetStyle ( ControlStyles.Selectable, false );
                }
 
                public BorderStyle BorderStyle {
index 7260dcc38047908346c94e1f7d94c405e3ed57c9..39a8840a6c2225cae7b069973f8f6051b285d2e9 100644 (file)
@@ -31,6 +31,7 @@ namespace System.Windows.Forms {
                #region Constructor
 
                public ProgressBar() {
+                       SetStyle ( ControlStyles.Selectable, false );
                }
 
                #endregion
index 36ed2692fd1b64fe13d36795fb981be31708e383..7473206fae9a86773cbd84cc33935a163711a174 100644 (file)
@@ -29,6 +29,7 @@ namespace System.Windows.Forms {
                        autoCheck  = true;
                        checkAlign = ContentAlignment.MiddleLeft;
                        checked_   = false;
+                       TextAlign  = ContentAlignment.MiddleLeft;                       
                }
 
                public Appearance Appearance {
index 8c989b09b4083284446e6ab9c072efd0f6d0bd99..57ebd31e697428258e33b8a6cc49da131cdd3737 100644 (file)
@@ -22,7 +22,7 @@ namespace System.Windows.Forms {
                [MonoTODO]
                public Splitter()
                {
-                       
+                       SetStyle ( ControlStyles.Selectable, false );
                }
 
                //
index 53aaa2383106f89973c179a9cedb016c2bf449ac..d03ce79ff5a35693d52d604d77fda217669c7a8d 100644 (file)
@@ -249,5 +249,19 @@ namespace System.Windows.Forms {
                                Marshal.FreeHGlobal ( ptr );
                        }
                }
+
+               protected override void Dispose( bool disposing )
+               {
+                       lock ( this ) {
+                               try {
+                                       if ( disposing ) {
+                                               tooltipWnd.DestroyHandle ( );
+                                       }
+                               }
+                               finally {
+                                       base.Dispose ( disposing ); 
+                               }
+                       }
+               }
        }
 }
index 88c085744e3e92592f7537d0ba2d5c76ee8b80c7..25045dc20b9b9318680e8ddf417b7abe527bdd4c 100644 (file)
@@ -2859,4 +2859,21 @@ namespace System.Windows.Forms{
                CDN_TYPECHANGE               = (CDN_FIRST - 0x0006),
                CDN_INCLUDEITEM              = (CDN_FIRST - 0x0007)
        }
+
+       [Flags]
+       internal enum TrackPopupMenuFlags : int {
+               TPM_LEFTBUTTON      = 0x0000,
+               TPM_RIGHTBUTTON     = 0x0002,
+               TPM_LEFTALIGN       = 0x0000,
+               TPM_CENTERALIGN     = 0x0004,
+               TPM_RIGHTALIGN      = 0x0008,
+               TPM_TOPALIGN        = 0x0000,
+               TPM_VCENTERALIGN    = 0x0010,
+               TPM_BOTTOMALIGN     = 0x0020,
+               TPM_HORIZONTAL      = 0x0000,
+               TPM_VERTICAL        = 0x0040,
+               TPM_NONOTIFY        = 0x0080,
+               TPM_RETURNCMD       = 0x0100,
+               TPM_RECURSE         = 0x0001
+       }
 }
index cc77bb3f126f53fda714b32828477d57677910bc..75ee508eb5a52008922b083deceb45707d4805ad 100644 (file)
@@ -528,6 +528,11 @@ namespace System.Windows.Forms{
                internal static extern IntPtr GetActiveWindow ( );
                [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
                internal static extern IntPtr GetForegroundWindow ( );
+
+               [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
+               internal static extern bool TrackPopupMenu( IntPtr hMenu, uint uFlags, int x, int y, int nReserved,
+                                                               IntPtr hWnd, IntPtr prcRect );
+
                #endregion
 
                #region Shell32.dll functions