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

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

[dotgnu-pnet-commits] pnetlib ./ChangeLog System.Windows.Forms/Contro...


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] pnetlib ./ChangeLog System.Windows.Forms/Contro...
Date: Mon, 27 Mar 2006 14:03:56 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Branch:         
Changes by:     Heiko Weiss <address@hidden>    06/03/27 14:03:55

Modified files:
        .              : ChangeLog 
        System.Windows.Forms: Control.cs Form.cs MdiClient.cs 
                              PopupControl.cs TreeView.cs 
Added files:
        System.Windows.Forms: ControlToolkitMgr.cs 

Log message:
        ControlToolkitMgr.cs: New file, new class for handling create windows 
thread safe.
        Control.cs: using ControlToolkitManager to create toolkitWindow thread 
safe. Now we can Destroy windows, if parent is set to null. Fixed DockStyle 
problem.
        Form.cs: using ControlToolkitManager to create toolkitWindow thread 
safe. Fixed Mdi forms not working.
        MdiClient.cs: using ControlToolkitManager to create toolkitWindow 
thread safe.
        PopupControl.cs: using ControlToolkitManager to create toolkitWindow 
thread safe.
        TreeView.cs: fixed drawing plus and minus buttons.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2375&tr2=1.2376&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Windows.Forms/ControlToolkitMgr.cs?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Windows.Forms/Control.cs.diff?tr1=1.116&tr2=1.117&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Windows.Forms/Form.cs.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Windows.Forms/MdiClient.cs.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Windows.Forms/PopupControl.cs.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Windows.Forms/TreeView.cs.diff?tr1=1.17&tr2=1.18&r1=text&r2=text

Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2375 pnetlib/ChangeLog:1.2376
--- pnetlib/ChangeLog:1.2375    Thu Mar 23 14:38:44 2006
+++ pnetlib/ChangeLog   Mon Mar 27 14:03:45 2006
@@ -1,3 +1,13 @@
+2006-03-27  Heiko Weiss  <address@hidden>
+
+       * System.Windows.Forms/ControlToolkitMgr.cs: New file, new class for 
handling create windows thread safe.
+       * System.Windows.Forms/Control.cs: using ControlToolkitManager to 
create toolkitWindow thread safe. Now we can Destroy windows, if parent is set 
to null. Fixed DockStyle problem.
+       * System.Windows.Forms/Form.cs: using ControlToolkitManager to create 
toolkitWindow thread safe. Fixed Mdi forms not working.
+       * System.Windows.Forms/MdiClient.cs: using ControlToolkitManager to 
create toolkitWindow thread safe.
+       * System.Windows.Forms/PopupControl.cs: using ControlToolkitManager to 
create toolkitWindow thread safe.
+       * System.Windows.Forms/TreeView.cs: fixed drawing plus and minus 
buttons.
+
+
 2006-03-23  Heiko Weiss  <address@hidden>
 
        * System.Windows.Forms/Control.cs: removed my last change in Reparent 
of Controls, because it breaked using invokes.
Index: pnetlib/System.Windows.Forms/Control.cs
diff -u pnetlib/System.Windows.Forms/Control.cs:1.116 
pnetlib/System.Windows.Forms/Control.cs:1.117
--- pnetlib/System.Windows.Forms/Control.cs:1.116       Thu Mar 23 14:38:44 2006
+++ pnetlib/System.Windows.Forms/Control.cs     Mon Mar 27 14:03:55 2006
@@ -94,7 +94,7 @@
        private static MouseButtons mouseButtons;
        private int controlStyle;
        // The thread that was used to create the control.
-       private Thread createThread;
+       // private Thread createThread; not needed anymore
        private Cursor cursor;
        private IToolkitWindowBuffer buffer;
        private ControlBindingsCollection controlBindingsCollection;
@@ -307,17 +307,12 @@
                                        // the toolkit co-ordinates must be 
relative to the draw origin.
                                        x += Parent.ClientOrigin.X - 
Parent.ToolkitDrawOrigin.X;
                                        y += Parent.ClientOrigin.Y - 
Parent.ToolkitDrawOrigin.Y; 
-                                       return parent.Toolkit.CreateChildWindow
-                                                       (parent, x, y, width, 
height, this);
-                               }
-                               else
-                               {
-                                       // Use the default toolkit to create.
-                                       return 
ToolkitManager.Toolkit.CreateChildWindow
-                                               (null, x, y, width, height, 
this);
                                }
+                               // use ControlToolkitManager to create the 
window thread safe
+                               return ControlToolkitManager.CreateChildWindow( 
this, parent, x, y, width, height );
                        }
 
+
        // Process a hoverTimer event
        private void ProcessHoverTimerEvent(object sender, EventArgs e)
        {
@@ -404,8 +399,8 @@
                        {
                                get
                                {
-                                       return (createThread != null &&
-                                                       createThread != 
Thread.CurrentThread);
+                                       // return (createThread != null && 
createThread != Thread.CurrentThread); not needed any more
+                                       return 
ControlToolkitManager.IsInvokeRequired;
                                }
                        }
 
@@ -2083,18 +2078,6 @@
                                                ("control", 
S._("SWF_ControlDisposed"));
                                }
 
-                               // Reparent underneath the new parent if the 
handle
-                               // already exists from some previous 
incarnation.
-                               if(toolkitWindow != null)
-                               {
-                                       if(parent != null &&
-                                          toolkitWindow.Parent != 
parent.toolkitWindow)
-                                       {
-                                               Reparent(parent);
-                                       }
-                                       return;
-                               }
-
                                // Create the handle using the toolkit.
                                if(parent != null)
                                {
@@ -2125,7 +2108,7 @@
                                        cursor.SetCursorOnWindow(toolkitWindow);
                                }
 
-                               createThread = Thread.CurrentThread;
+                               // createThread = Thread.CurrentThread; not 
needed anymore
 
                                // Reparent the children which require it.
                                for(int i = 0; i < numChildren; ++i)
@@ -3549,8 +3532,10 @@
                                        OnVisibleChanged(EventArgs.Empty);
 
                                        // Perform layout on the parent or self.
-                                       if(parent != null)
+                                       if(parent != null) {
                                                parent.PerformLayout(this, 
"Visible");
+                                               if( this.Dock != DockStyle.None 
) parent.PerformActualLayout();
+                                       }
                                        else
                                                PerformLayout(this, "Visible");
                                }
@@ -5517,14 +5502,10 @@
                                         * Then a reference would be still 
kept, and the control never gets disposed.
                                         * So Destroy the handle. If the 
control is reused, the handle gets 
                                         * created again.
+                                        *
+                                        * we can do this again, since we can 
create handles thread  safe with ControlToolkitManager.
                                         */
-                                       /*
-                                       fu..., if we do this, we get a deadlock 
on Invokes!
-                                       because the handle might be created the 
by nother thread.
                                        DestroyHandle();
-                                       */
-                                       toolkitWindow.Reparent(null, left + 
ToolkitDrawOrigin.X,
-                                                                               
                  top + ToolkitDrawOrigin.Y);
                                }
                                else if(newParent.toolkitWindow != null)
                                {
Index: pnetlib/System.Windows.Forms/Form.cs
diff -u pnetlib/System.Windows.Forms/Form.cs:1.50 
pnetlib/System.Windows.Forms/Form.cs:1.51
--- pnetlib/System.Windows.Forms/Form.cs:1.50   Tue Mar 21 10:40:01 2006
+++ pnetlib/System.Windows.Forms/Form.cs        Mon Mar 27 14:03:55 2006
@@ -409,8 +409,10 @@
                                        {
                                                return;
                                        }
+                                       
                                        mdiParent = value;
                                        value.mdiClient.Controls.Add(this);
+                                       Parent = value.mdiClient;
                                }
                        }
        public bool MinimizeBox
@@ -666,86 +668,91 @@
                                }
                        }
 
-       // Create the toolkit window underlying this control.
        internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow 
parent)
-                       {
-                               // When a Form is reparented to a normal 
container control 
-                               // which does work on Win32 unfortunately.
-                               if(mdiParent == null && (!TopLevel))
-                               {
-                                       return base.CreateToolkitWindow(parent);
-                               }
-
-                               CreateParams cp = CreateParams;
+       {
+               // When a Form is reparented to a normal container control 
+               // which does work on Win32 unfortunately.
+               if(mdiParent == null && (!TopLevel))
+               {
+                       return base.CreateToolkitWindow(parent);
+               }
+
+               CreateParams cp = CreateParams;
+
+               // Create the window and set its initial caption.
+               IToolkitTopLevelWindow window;
+               if(mdiParent == null)
+               {
+                       // use ControlToolkitManager to create the window 
thread safe
+                       window = ControlToolkitManager.CreateTopLevelWindow( 
this,
+                                       cp.Width - ToolkitDrawSize.Width,
+                                       cp.Height - ToolkitDrawSize.Height);
+               }
+               else
+               {
+                       mdiParent.mdiClient.CreateControl();
+                       IToolkitMdiClient mdi =
+                                       (mdiParent.mdiClient.toolkitWindow as
+                                       IToolkitMdiClient);
+                       
+                       // use ControlToolkitManager to create the window 
thread safe
+                       window = ControlToolkitManager.CreateMdiChildWindow( 
this, mdi, 
+                                       cp.X, cp.Y,
+                                       cp.Width - ToolkitDrawSize.Width,
+                                       cp.Height - ToolkitDrawSize.Height);
+               }
+               
+               window.SetTitle(cp.Caption);
+               // Win32 requires this because if the window is maximized, the 
windows size needs to be set.
+               toolkitWindow = window;
+
+               // Adjust the window hints to match our requirements.
+               SetWindowFlags(window);
+               if(icon != null)
+               {
+                       window.SetIcon(icon);
+               }
+               window.SetMaximumSize(maximumSize);
+               window.SetMinimumSize(minimumSize);
 
-                               // Create the window and set its initial 
caption.
-                               IToolkitTopLevelWindow window;
-                               if(mdiParent == null)
-                               {
-                                       window = 
ToolkitManager.Toolkit.CreateTopLevelWindow
-                                               (cp.Width - 
ToolkitDrawSize.Width,
-                                                cp.Height - 
ToolkitDrawSize.Height, this);
-                               }
-                               else
-                               {
-                                       mdiParent.mdiClient.CreateControl();
-                                       IToolkitMdiClient mdi =
-                                               
(mdiParent.mdiClient.toolkitWindow as
-                                                       IToolkitMdiClient);
-                                       window = mdi.CreateChildWindow
-                                               (cp.X, cp.Y,
-                                                cp.Width - 
ToolkitDrawSize.Width,
-                                                cp.Height - 
ToolkitDrawSize.Height, this);
-                               }
-                               window.SetTitle(cp.Caption);
-                               // Win32 requires this because if the window is 
maximized, the windows size needs to be set.
-                               toolkitWindow = window;
-
-                               // Adjust the window hints to match our 
requirements.
-                               SetWindowFlags(window);
-                               if(icon != null)
-                               {
-                                       window.SetIcon(icon);
-                               }
-                               window.SetMaximumSize(maximumSize);
-                               window.SetMinimumSize(minimumSize);
-                       #if !CONFIG_COMPACT_FORMS
-                               if(windowState == FormWindowState.Minimized)
-                               {
-                                       window.Iconify();
-                               }
-                               else
-                       #endif
-                               if(windowState == FormWindowState.Maximized)
-                               {
-                                       window.Maximize();
-                               }
+#if !CONFIG_COMPACT_FORMS
+               if(windowState == FormWindowState.Minimized)
+               {
+                       window.Iconify();
+               }
+               else
+#endif
+               if(windowState == FormWindowState.Maximized)
+               {
+                       window.Maximize();
+               }
+
+               // Center the window on-screen if necessary.
+               if(formStartPosition == FormStartPosition.CenterScreen)
+               {
+                       Size screenSize = 
ToolkitManager.Toolkit.GetScreenSize();
+                       window.MoveResize
+                                       ((screenSize.Width - cp.Width) / 2,
+                                       (screenSize.Height - cp.Height) / 2,
+                                       window.Dimensions.Width, 
window.Dimensions.Height);
+               }
+               else if(formStartPosition == FormStartPosition.Manual)
+               {
+                       window.MoveResize
+                                       (
+                                       cp.X,
+                       cp.Y,
+                       window.Dimensions.Width,
+                       window.Dimensions.Height
+                                       );
+               }
+               if(opacity != 1.0)
+               {
+                       window.SetOpacity(opacity);
+               }
+               return window;
+}
 
-                               // Center the window on-screen if necessary.
-                               if(formStartPosition == 
FormStartPosition.CenterScreen)
-                               {
-                                       Size screenSize = 
ToolkitManager.Toolkit.GetScreenSize();
-                                       window.MoveResize
-                                                       ((screenSize.Width - 
cp.Width) / 2,
-                                                        (screenSize.Height - 
cp.Height) / 2,
-                                                        
window.Dimensions.Width, window.Dimensions.Height);
-                               }
-                               else if(formStartPosition == 
FormStartPosition.Manual)
-                               {
-                                       window.MoveResize
-                                               (
-                                                       cp.X,
-                                                       cp.Y,
-                                                       window.Dimensions.Width,
-                                                       window.Dimensions.Height
-                                               );
-                               }
-                               if(opacity != 1.0)
-                               {
-                                       window.SetOpacity(opacity);
-                               }
-                               return window;
-                       }
 
        // Determine if this is a top-level control which cannot have parents.
        internal override bool IsTopLevel
Index: pnetlib/System.Windows.Forms/MdiClient.cs
diff -u pnetlib/System.Windows.Forms/MdiClient.cs:1.2 
pnetlib/System.Windows.Forms/MdiClient.cs:1.3
--- pnetlib/System.Windows.Forms/MdiClient.cs:1.2       Wed Jun 23 13:36:46 2004
+++ pnetlib/System.Windows.Forms/MdiClient.cs   Mon Mar 27 14:03:55 2006
@@ -90,35 +90,38 @@
 
        // Create the toolkit window underlying this control.
        internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow 
parent)
-                       {
-                               CreateParams cp = CreateParams;
-                               int x = cp.X + ToolkitDrawOrigin.X;
-                               int y = cp.Y + ToolkitDrawOrigin.Y;
-                               int width = cp.Width - ToolkitDrawSize.Width;
-                               int height = cp.Height - ToolkitDrawSize.Height;
-                                       
-                               if(parent != null)
-                               {
-                                       // Use the parent's toolkit to create.
-                                       if(Parent is Form)
-                                       {
-                                               return 
parent.Toolkit.CreateMdiClient
-                                                       (parent, x, y, width, 
height, this);
-                                       }
-                                       else
-                                       {
-                                               return 
parent.Toolkit.CreateMdiClient
-                                                       (parent, x + 
Parent.ClientOrigin.X,
-                                                        y +  
Parent.ClientOrigin.Y, width, height, this);
-                                       }
-                               }
-                               else
-                               {
-                                       // Use the default toolkit to create.
-                                       return 
ToolkitManager.Toolkit.CreateMdiClient
-                                               (null, x, y, width, height, 
this);
-                               }
-                       }
+       {
+               CreateParams cp = CreateParams;
+               int x = cp.X + ToolkitDrawOrigin.X;
+               int y = cp.Y + ToolkitDrawOrigin.Y;
+               int width = cp.Width - ToolkitDrawSize.Width;
+               int height = cp.Height - ToolkitDrawSize.Height;
+                                               
+               if(parent != null)
+               {
+                                               // Use the parent's toolkit to 
create.
+                       if(Parent is Form)
+                       {
+                               // use ControlToolkitManager to create the 
window thread safe
+                               return ControlToolkitManager.CreateMdiClient( 
this, 
+                                               parent, x, y, width, height);
+                       }
+                       else
+                       {
+                               // use ControlToolkitManager to create the 
window thread safe
+                               return ControlToolkitManager.CreateMdiClient( 
this,
+                                               parent,
+                                               x + Parent.ClientOrigin.X,
+                                               y +  Parent.ClientOrigin.Y, 
width, height);
+                       }
+               }
+               else
+               {
+                       // Use the default toolkit to create.
+                       // use ControlToolkitManager to create the window 
thread safe
+                       return ControlToolkitManager.CreateMdiClient    (this, 
null, x, y, width, height);
+               }
+       }
 
        // Create a new control collection for this instance.
        protected override Control.ControlCollection CreateControlsInstance()
Index: pnetlib/System.Windows.Forms/PopupControl.cs
diff -u pnetlib/System.Windows.Forms/PopupControl.cs:1.6 
pnetlib/System.Windows.Forms/PopupControl.cs:1.7
--- pnetlib/System.Windows.Forms/PopupControl.cs:1.6    Thu Jan 15 22:40:28 2004
+++ pnetlib/System.Windows.Forms/PopupControl.cs        Mon Mar 27 14:03:55 2006
@@ -49,14 +49,16 @@
                                }
                        }
 
-       // Create the toolkit window underlying this control.
+
        internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow 
parent)
-                       {
-                               CreateParams cp = CreateParams;
-                               return ToolkitManager.Toolkit.CreatePopupWindow
-                                               (cp.X + ToolkitDrawOrigin.X, 
cp.Y + ToolkitDrawOrigin.Y,
-                                                cp.Width - 
ToolkitDrawSize.Width, cp.Height - ToolkitDrawSize.Height, this);
-                       }
+       {
+               CreateParams cp = CreateParams;
+
+               // use ControlToolkitManager to create the window thread safe
+               return ControlToolkitManager.CreatePopupWindow( this,
+                               cp.X + ToolkitDrawOrigin.X, cp.Y + 
ToolkitDrawOrigin.Y,
+                                cp.Width - ToolkitDrawSize.Width, cp.Height - 
ToolkitDrawSize.Height);
+       }
 
        // Trap the "OnMouseDown" event and pop down the window if a
        // mouse click occurs outside the control's bounds.
Index: pnetlib/System.Windows.Forms/TreeView.cs
diff -u pnetlib/System.Windows.Forms/TreeView.cs:1.17 
pnetlib/System.Windows.Forms/TreeView.cs:1.18
--- pnetlib/System.Windows.Forms/TreeView.cs:1.17       Thu Nov 24 20:00:58 2005
+++ pnetlib/System.Windows.Forms/TreeView.cs    Mon Mar 27 14:03:55 2006
@@ -577,12 +577,10 @@
                        int lineTopEnd = midY;
                        if (node.Nodes.Count > 0 && showPlusMinus)
                        {
-                               GraphicsPath path = new GraphicsPath();
-                               path.AddRectangle(new Rectangle(midX - 4, midY 
- 4, 8, 8));
-                               path.AddLine(midX - 2, midY, midX + 2, midY);
+                               g.DrawRectangle(SystemPens.ControlText, midX - 
4, midY - 4, 8, 8 );
+                               g.DrawLine(SystemPens.ControlText, midX - 2, 
midY, midX + 2, midY);
                                if (!node.IsExpanded)
-                                       path.AddLine(midX, midY - 2, midX, midY 
+ 2);
-                               g.DrawPath(SystemPens.ControlText, path);
+                                       g.DrawLine(SystemPens.ControlText, 
midX, midY - 2, midX, midY + 2);
                                lineRightStart += 6;
                                lineTopEnd -= 6;
                        }




reply via email to

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