* Form.cs : TopLevel, AcceptButton, CancelButton
authorAleksey Ryabchuk <aleksey@mono-cvs.ximian.com>
Mon, 30 Jun 2003 16:41:02 +0000 (16:41 -0000)
committerAleksey Ryabchuk <aleksey@mono-cvs.ximian.com>
Mon, 30 Jun 2003 16:41:02 +0000 (16:41 -0000)
* Application.cs : allow keyboard messages in modal forms
* Control.cs : basic impl. of GetTopLevel, SetTopLevel

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

mcs/class/System.Windows.Forms/System.Windows.Forms/Application.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs

index b4db4f29ed51e0ec2f565e8f35fd61d2da408739..f5b28580a3ef999ec60ceeba44db508da6741107 100644 (file)
@@ -283,13 +283,20 @@ namespace System.Windows.Forms {
                        MSG msg = new MSG();
                        while( Win32.GetMessageA( ref msg, 0, 0, 0 ) != 0 ) {
 
-                               if ( mainForm.ExitModalLoop ) {
+                               if ( mainForm.ExitModalLoop )
                                        break;
-                               }
 
-                               if( Win32.IsDialogMessage ( mainForm.Handle, ref msg ) )
-                                       continue;
-                               
+                               Message message = new Message ();
+                               message.HWnd = msg.hwnd;
+                               message.Msg = msg.message;
+                               message.WParam = msg.wParam;
+                               message.LParam = msg.lParam;
+
+                               Control receiver = Control.FromChildHandle ( message.HWnd );
+                               if ( receiver != null )
+                                       if ( receiver.PreProcessMessage ( ref message ) )
+                                               continue;
+
                                Win32.TranslateMessage (ref msg);
                                Win32.DispatchMessageA (ref msg);
                        }
index 9b2b327f9fe55dee4028aed9a30d57a8264fa688..9e3926652ebd7a3021dc83755a14684eb443ac2f 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-30 Aleksey Ryabchuk <ryabchuk@yahoo.com>
+       * Form.cs : TopLevel, AcceptButton, CancelButton
+       * Application.cs : allow keyboard messages in modal forms
+       * Control.cs : basic impl. of GetTopLevel, SetTopLevel
+
 2003-06-30 Aleksey Ryabchuk <ryabchuk@yahoo.com>
        * Cursors.cs : VSplit, HSplit cursors
        * Form.cs: WindowState ( not finished ), changes to Form.Close
index 995e97d237063d90fa63dc359457788c70c85cd4..ab4bbd4b6cb91fa68abe0fdd306662eb33c679e6 100644 (file)
                private static readonly int RECREATING_HANDLE= BitVector32.CreateMask( DISPOSED );
                private static readonly int CREATED          = BitVector32.CreateMask( RECREATING_HANDLE );
                private static readonly int DISPOSING        = BitVector32.CreateMask( CREATED );
+               private static readonly int TOPLEVEL         = BitVector32.CreateMask( DISPOSING );
 
                        object tag;
                        protected bool mouseIsInside_;
                [MonoTODO]
                protected bool GetTopLevel () 
                {
-                       throw new NotImplementedException ();
+                       return statuses [ TOPLEVEL ];
                }
                
                public void Hide ()
                        }
                
                protected void SetTopLevel (bool value)
-               {
+               {/*
                        if (value)
                                // FIXME: verify on whether this is supposed
                                // to activate/deactive the window
                                // FIXME: this does not make sense but
                                // the docs say the window is hidden
                                Win32.ShowWindow (Handle, ShowWindowStyles.SW_HIDE);
+               */
+                       if ( GetTopLevel ( ) != value && Parent != null )
+                               throw new ArgumentException ( );
+
+                       statuses [ TOPLEVEL ] = value;
                }
                
                [MonoTODO]
index c16e669d012df4998356d7885fba188b78a3c5c9..b2d7cfd8794153fda1fa27440e13f51e283430a7 100644 (file)
@@ -23,7 +23,6 @@
                        Size maximumSize;
                        Size minimumSize;
                        double opacity;
-                       bool   topLevel;
                        bool   autoScale;
 
                        private bool controlBox;
                SizeGripStyle sizeGripStyle;
                FormStartPosition formStartPosition;
                FormWindowState   formWindowState;
+               IButtonControl    acceptButton;
+               IButtonControl    cancelButton;
 
                public Form () : base ()
                {
                        opacity = 1.00;
-                       topLevel = true;
+                       TopLevel = true;
                        modal    = false;
                        dialogResult = DialogResult.None;
                        autoScale = true;
                        formStartPosition = FormStartPosition.WindowsDefaultLocation;
                        visible = false;
                        formWindowState = FormWindowState.Normal;
+                       acceptButton = null;
+                       cancelButton = null;
                }
                
                static Form ()
                //
                [MonoTODO]
                public IButtonControl AcceptButton {
-                       get {
-                               throw new NotImplementedException ();
-                       }
-                       set {
-                                       //FIXME:
-                               }
+                       get { return acceptButton; }
+                       set { 
+                               acceptButton = value;
+                       }
                }
     
                [MonoTODO]
     
                [MonoTODO]
                public IButtonControl CancelButton {
-                       get {
-                               throw new NotImplementedException ();
-                       }
-                       set {
-                                       //FIXME:
-                               }
+                       get { return cancelButton;  }
+                       set { 
+                               cancelButton = value;
+                       }
                }
     
                [MonoTODO]
     
                [MonoTODO]
                public bool TopLevel {
-                       get { return topLevel;  }
-                       set { topLevel = value; }
+                       get { return GetTopLevel ( );  }
+                       set { SetTopLevel ( value );   }
                }
     
                public bool TopMost {
     
                protected override bool ProcessDialogKey (Keys keyData)
                {
+                       if ( keyData == Keys.Enter && AcceptButton != null ) {
+                               AcceptButton.PerformClick ( );
+                               return true;
+                       }
+                       if ( keyData == Keys.Escape && CancelButton != null ) {
+                               CancelButton.PerformClick ( );
+                               return true;
+                       }
                        return base.ProcessDialogKey (keyData);
                }