Author: pbartok
Date: 2005-03-15 07:31:53 -0500 (Tue, 15 Mar 2005)
New Revision: 41833

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
Log:
2005-03-15  Peter Bartok  <[EMAIL PROTECTED]>

        * Form.cs: Use Handle for icon, to trigger creation if
          the window does not yet exist
        * Control.cs:
          - CanSelect: Slight performance improvement
          - Focus(): Preventing possible recursion
          - Invalidate(): Removed ControlStyle based clear flag setting
          - WM_PAINT: fixed logic for calling OnPaintBackground
          - WM_ERASEBKGND: Fixed logic, added call to new driver method
            EraseWindowBackground if the control doesn't paint background
        * XplatUIWin32.cs:
          - Moved EraseWindowBackground() method to internal methods
          - Removed unused WM_ERASEBKGND handling in GetMessage; msg never 
comes;
            is sent via SendMessage on BeginPaint call on Win32
        * XplatUIX11.cs:
          - Added EraseWindowBackground() method
          - No longer sends WM_ERASEBKGND on .Expose, but on call to 
            PaintEventStart, which more closely matches Win32 behaviour
          - Fixed Invalidate() call, now updates new ErasePending Hwnd property
          - Fixed SetFocus() to properly deal with client and whole windows
        * Hwnd.cs: Added ErasePending property
        * XplatUIOSX.cs: Stubbed EraseWindowBackground() method
        * XplatUI.cs, XplatUIDriver.cs: Added EraseWindowBackground() method



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-03-15 12:31:53 UTC (rev 41833)
@@ -1,3 +1,28 @@
+2005-03-15  Peter Bartok  <[EMAIL PROTECTED]>
+
+       * Form.cs: Use Handle for icon, to trigger creation if
+         the window does not yet exist
+       * Control.cs:
+         - CanSelect: Slight performance improvement
+         - Focus(): Preventing possible recursion
+         - Invalidate(): Removed ControlStyle based clear flag setting
+         - WM_PAINT: fixed logic for calling OnPaintBackground
+         - WM_ERASEBKGND: Fixed logic, added call to new driver method
+           EraseWindowBackground if the control doesn't paint background
+       * XplatUIWin32.cs:
+         - Moved EraseWindowBackground() method to internal methods
+         - Removed unused WM_ERASEBKGND handling in GetMessage; msg never 
comes;
+           is sent via SendMessage on BeginPaint call on Win32
+       * XplatUIX11.cs:
+         - Added EraseWindowBackground() method
+         - No longer sends WM_ERASEBKGND on .Expose, but on call to 
+           PaintEventStart, which more closely matches Win32 behaviour
+         - Fixed Invalidate() call, now updates new ErasePending Hwnd property
+         - Fixed SetFocus() to properly deal with client and whole windows
+       * Hwnd.cs: Added ErasePending property
+       * XplatUIOSX.cs: Stubbed EraseWindowBackground() method
+       * XplatUI.cs, XplatUIDriver.cs: Added EraseWindowBackground() method
+
 2005-03-12  Geoff Norton  <[EMAIL PROTECTED]>
 
        * XplatUIOSX.cs:

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2005-03-15 12:31:53 UTC (rev 41833)
@@ -1141,7 +1141,7 @@
 
                                parent = this.parent;
                                while (parent != null) {
-                                       if (!parent.Visible || 
!parent.is_enabled) {
+                                       if (!parent.is_visible || 
!parent.is_enabled) {
                                                return false;
                                        }
 
@@ -2081,9 +2081,9 @@
 
                public bool Focus() {
                        if (IsHandleCreated && !has_focus) {
+                               has_focus = true;
                                XplatUI.SetFocus(window.Handle);
                        }
-                       has_focus = true;
                        return true;
                }
 
@@ -2154,7 +2154,7 @@
 
                        NotifyInvalidate(rc);
 
-                       XplatUI.Invalidate(Handle, rc, !GetStyle 
(ControlStyles.AllPaintingInWmPaint));
+                       XplatUI.Invalidate(Handle, rc, false);
 
                        if (invalidateChildren) {
                                for (int i=0; i<child_controls.Count; i++) 
child_controls[i].Invalidate();
@@ -3173,9 +3173,10 @@
 
                                        paint_event = 
XplatUI.PaintEventStart(Handle);
 
-                                       if 
(GetStyle(ControlStyles.AllPaintingInWmPaint)) {
+                                       if ((control_style & 
(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) == 
(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
                                                OnPaintBackground(paint_event);
                                        }
+
                                        OnPaint(paint_event);
                                        XplatUI.PaintEventEnd(Handle);
                                        
@@ -3193,12 +3194,11 @@
                                                                        
Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
                                                        OnPaintBackground 
(eraseEventArgs);
                                                }
-                                               m.Result = (IntPtr)1;
                                        } else {
-                                               m.Result = IntPtr.Zero;
-                                               DefWndProc (ref m);     
-                                       }                                       
-                                               
+                                               
XplatUI.EraseWindowBackground(m.HWnd, m.WParam);
+                                       }
+                                       // The DefWndProc will never have to 
handle this, we don't ever set hbr on the window
+                                       m.Result = (IntPtr)1;
                                        return;
                                }
 

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2005-03-15 12:31:53 UTC (rev 41833)
@@ -340,7 +340,7 @@
                                if (icon != value) {
                                        icon = value;
 
-                                       XplatUI.SetIcon(window.Handle, icon);
+                                       XplatUI.SetIcon(Handle, icon);
                                }
                        }
                }
@@ -1016,9 +1016,18 @@
                protected override void OnCreateControl() {
                        base.OnCreateControl ();
                        if (this.ActiveControl == null) {
+                               bool visible;
+
+                               // This visible hack is to work around 
CanSelect always being false if one of the parents
+                               // is not visible; and we by default create 
Form invisible...
+                               visible = this.is_visible;
+                               this.is_visible = true;
+
                                if (SelectNextControl(this, true, true, true, 
true) == false) {
                                        Select(this);
                                }
+
+                               this.is_visible = visible;
                        }
                        OnLoad(EventArgs.Empty);
 
@@ -1259,13 +1268,17 @@
                                }
 
                                case Msg.WM_KILLFOCUS: {
+                                       base.WndProc(ref m);
                                        return;
                                }
 
                                case Msg.WM_SETFOCUS: {
+#if not
                                        if (this.ActiveControl != null) {
                                                ActiveControl.Focus();
                                        }
+#endif
+                                       base.WndProc(ref m);
                                        return;
                                }
 

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs  
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs  
2005-03-15 12:31:53 UTC (rev 41833)
@@ -58,6 +58,7 @@
                internal bool           visible;
                internal Rectangle      invalid;
                internal bool           expose_pending;
+               internal bool           erase_pending;
                internal bool           nc_expose_pending;
                internal bool           configure_pending;
                internal Graphics       client_dc;
@@ -83,6 +84,7 @@
                        nc_expose_pending = false;
                        edge_style = Border3DStyle.Raised;
                        client_rectangle = Rectangle.Empty;
+                       erase_pending = true;
                }
 
                public void Dispose() {
@@ -286,6 +288,16 @@
                        }
                }
 
+               public bool ErasePending {
+                       get {
+                               return erase_pending;
+                       }
+
+                       set {
+                               erase_pending = value;
+                       }
+               }
+
                public bool ExposePending {
                        get {
                                return expose_pending;

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs       
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs       
2005-03-15 12:31:53 UTC (rev 41833)
@@ -77,7 +77,7 @@
 
                #region Constructor & Destructor
                static XplatUI() {
-                       Console.WriteLine("Mono System.Windows.Forms Assembly 
[Revision: 41586; built: 2005/2/9 1:7:30]");
+                       Console.WriteLine("Mono System.Windows.Forms Assembly 
[Revision: 41731; built: 2005/2/11 23:27:29]");
 
                        // Don't forget to throw the mac in here somewhere, too
                        default_class_name="SWFClass";
@@ -333,6 +333,10 @@
                        driver.Exit();
                }
 
+               internal static void EraseWindowBackground(IntPtr handle, 
IntPtr wParam) {
+                       driver.EraseWindowBackground(handle, wParam);
+               }
+
                internal static IntPtr GetActive() {
                        #if DriverDebug
                                Console.WriteLine("GetActive(): Called");

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs 
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs 
2005-03-15 12:31:53 UTC (rev 41833)
@@ -194,8 +194,9 @@
 
                internal abstract void SetIcon(IntPtr handle, Icon icon);
 
+               internal abstract void EraseWindowBackground(IntPtr handle, 
IntPtr wParam);
+
                // System information
-
                internal abstract int KeyboardSpeed { get; } 
                internal abstract int KeyboardDelay { get; } 
                

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs    
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs    
2005-03-15 12:31:53 UTC (rev 41833)
@@ -1112,6 +1112,11 @@
                        //Like X11 we need not do anything here
                }
 
+               internal override void EraseWindowBackground(IntPtr handle, 
IntPtr wParam) {
+                       throw new NotImplementedException();
+               }
+
+
                internal override void Exit() {
                        GetMessageResult = false;
                        ExitToShell ();

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs  
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs  
2005-03-15 12:31:53 UTC (rev 41833)
@@ -552,28 +552,7 @@
                        return Win32DefWindowProc(hWnd, msg, wParam, lParam);
                }
 
-               private void EraseWindowBackground(IntPtr hWnd, IntPtr hDc) {
-                       IntPtr          hbr;
-                       LOGBRUSH        lb;
-                       uint            argb;
-                       RECT            rect;
-                                               
-                       //msg.wParam
-                       argb = Win32GetWindowLong(hWnd, 
WindowLong.GWL_USERDATA);
-                       lb = new LOGBRUSH();
-                                               
-                       lb.lbColor.B = (byte)((argb & 0xff0000)>>16);
-                       lb.lbColor.G = (byte)((argb & 0xff00)>>8);
-                       lb.lbColor.R = (byte)(argb & 0xff);
-
-                       lb.lbStyle = LogBrushStyle.BS_SOLID;
-                       hbr = Win32CreateBrushIndirect(ref lb);
-                       Win32GetClientRect(hWnd, out rect);
-                       Win32FillRect(hDc, ref rect, hbr);
-                       Win32DeleteObject(hbr);
-               }
-
-               private static bool MessageWaiting {
+               private static bool MessageWaiting {
                        get {
                                if (message_queue.Count == 0) {
                                        return false;
@@ -933,7 +912,8 @@
                                clip_rect = new Rectangle(ps.rcPaint.left, 
ps.rcPaint.top, ps.rcPaint.right-ps.rcPaint.left, 
ps.rcPaint.bottom-ps.rcPaint.top);
 //                             clip_rect = new Rectangle(rect.left, rect.top, 
rect.right-rect.left, rect.bottom-rect.top);
 
-                               if (ps.fErase!=0) {
+                               if (ps.fErase != 0) {
+Console.WriteLine("Hit Clear background");
                                        EraseWindowBackground(handle, hdc);
                                }
                        } else {
@@ -1068,11 +1048,6 @@
                                        break;
                                }
 
-                               case Msg.WM_ERASEBKGND: {
-                                       EraseWindowBackground(msg.hwnd, 
msg.wParam);
-                                       break;
-                               }
-
                                case Msg.WM_ASYNC_MESSAGE: {
                                        GCHandle handle = (GCHandle)msg.lParam;
                                        AsyncMethodData asyncdata = 
(AsyncMethodData) handle.Target;
@@ -1589,7 +1564,28 @@
                internal override void SetIcon(IntPtr hwnd, Icon icon) {
                        Win32SendMessage(hwnd, Msg.WM_SETICON, (IntPtr)1, 
icon.Handle); // 1 = large icon (0 would be small)
                }
-
+
+               internal override void EraseWindowBackground(IntPtr hWnd, 
IntPtr hDc) {
+                       IntPtr          hbr;
+                       LOGBRUSH        lb;
+                       uint            argb;
+                       RECT            rect;
+
+                       //msg.wParam
+                       argb = Win32GetWindowLong(hWnd, 
WindowLong.GWL_USERDATA);
+                       lb = new LOGBRUSH();
+
+                       lb.lbColor.B = (byte)((argb & 0xff0000)>>16);
+                       lb.lbColor.G = (byte)((argb & 0xff00)>>8);
+                       lb.lbColor.R = (byte)(argb & 0xff);
+
+                       lb.lbStyle = LogBrushStyle.BS_SOLID;
+                       hbr = Win32CreateBrushIndirect(ref lb);
+                       Win32GetClientRect(hWnd, out rect);
+                       Win32FillRect(hDc, ref rect, hbr);
+                       Win32DeleteObject(hbr);
+               }
+
                internal override int KeyboardSpeed {
                        get {
                                Console.WriteLine ("KeyboardSpeed: need to 
query Windows");

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2005-03-15 12:11:30 UTC (rev 41832)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2005-03-15 12:31:53 UTC (rev 41833)
@@ -1703,7 +1703,7 @@
                                        hwnd = Hwnd.ObjectFromHandle(msg.HWnd);
                                        XClearArea(DisplayHandle, 
hwnd.client_window, hwnd.invalid.X, hwnd.invalid.Y, hwnd.invalid.Width, 
hwnd.invalid.Height, false);
 
-                                       return IntPtr.Zero;
+                                       return (IntPtr)1;
                                }
                        }
                        return IntPtr.Zero;
@@ -1783,6 +1783,16 @@
                        // We do nothing; On X11 SetModal is used to create 
modal dialogs, on Win32 this function is used (see comment there)
                }
 
+               internal override void EraseWindowBackground(IntPtr handle, 
IntPtr wParam) {
+                       Hwnd    hwnd;
+
+                       hwnd = Hwnd.ObjectFromHandle(handle);
+
+                       lock (XlibLock) {
+                               XClearArea (DisplayHandle, hwnd.client_window, 
hwnd.invalid.Left, hwnd.invalid.Top, hwnd.invalid.Width, hwnd.invalid.Height, 
false);
+                       }
+               }
+
                internal override void Exit() {
                        GetMessageResult = false;
                }
@@ -2201,8 +2211,6 @@
                                                HideCaret();
                                        }
 
-                                       NativeWindow.WndProc(msg.hwnd, 
Msg.WM_ERASEBKGND, IntPtr.Zero, IntPtr.Zero);
-
                                        if (Caret.Visible == 1) {
                                                ShowCaret();
                                                Caret.Paused = false;
@@ -2437,24 +2445,31 @@
                }
 
                internal override void Invalidate(IntPtr handle, Rectangle rc, 
bool clear) {
+                       Hwnd    hwnd;
+                       XEvent  xevent;
+
+                       hwnd = Hwnd.ObjectFromHandle(handle);
+
+
+                       xevent = new XEvent ();
+                       xevent.type = XEventName.Expose;
+                       xevent.ExposeEvent.display = DisplayHandle;
+                       xevent.ExposeEvent.window = 
Hwnd.ObjectFromHandle(handle).client_window;
+
                        if (clear) {
-                               lock (XlibLock) {
-                                       XClearArea (DisplayHandle, 
Hwnd.ObjectFromHandle(handle).client_window, rc.Left, rc.Top, rc.Width, 
rc.Height, true);
-                               }
+                               hwnd.erase_pending = true;
+                               xevent.ExposeEvent.x = hwnd.X;
+                               xevent.ExposeEvent.y = hwnd.Y;
+                               xevent.ExposeEvent.width = hwnd.Width;
+                               xevent.ExposeEvent.height = hwnd.Height;
                        } else {
-                               XEvent xevent;
-
-                               xevent = new XEvent ();
-                               xevent.type = XEventName.Expose;
-                               xevent.ExposeEvent.display = DisplayHandle;
-                               xevent.ExposeEvent.window = 
Hwnd.ObjectFromHandle(handle).client_window;
                                xevent.ExposeEvent.x = rc.X;
                                xevent.ExposeEvent.y = rc.Y;
                                xevent.ExposeEvent.width = rc.Width;
                                xevent.ExposeEvent.height = rc.Height;
+                       }
 
-                               AddExpose (xevent);
-                       }
+                       AddExpose (xevent);
                }
 
                internal override bool IsVisible(IntPtr handle) {
@@ -2482,6 +2497,13 @@
                                HideCaret();
                        }
 
+                       if (hwnd.erase_pending) {
+                               // In our implementation WM_ERASEBKGND always 
returns 1; otherwise we'd check the result and only call clear if it returned 0
+                               NativeWindow.WndProc(hwnd.client_window, 
Msg.WM_ERASEBKGND, IntPtr.Zero, IntPtr.Zero);
+                               hwnd.erase_pending = false;
+                       }
+
+
                        hwnd.client_dc  = Graphics.FromHwnd 
(hwnd.client_window);
                        paint_event = new PaintEventArgs(hwnd.client_dc, 
hwnd.invalid);
 
@@ -2714,11 +2736,15 @@
                }
 
                internal override void SetFocus(IntPtr handle) {
+                       Hwnd    hwnd;
+
+                       hwnd = Hwnd.ObjectFromHandle(handle);
+
                        if (FocusWindow != IntPtr.Zero) {
-                               PostMessage(FocusWindow, Msg.WM_KILLFOCUS, 
handle, IntPtr.Zero);
+                               PostMessage(FocusWindow, Msg.WM_KILLFOCUS, 
hwnd.client_window, IntPtr.Zero);
                        }
-                       PostMessage(handle, Msg.WM_SETFOCUS, FocusWindow, 
IntPtr.Zero);
-                       FocusWindow = handle;
+                       PostMessage(hwnd.client_window, Msg.WM_SETFOCUS, 
FocusWindow, IntPtr.Zero);
+                       FocusWindow = hwnd.client_window;
 
                        //XSetInputFocus(DisplayHandle, 
Hwnd.ObjectFromHandle(handle).client_window, RevertTo.None, IntPtr.Zero);
                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to