2008-06-11 George Giolfan <georgegiolfan@yahoo.com>
authorGeorge Giolfan <ggiolfan@mono-cvs.ximian.com>
Wed, 11 Jun 2008 10:27:18 +0000 (10:27 -0000)
committerGeorge Giolfan <ggiolfan@mono-cvs.ximian.com>
Wed, 11 Jun 2008 10:27:18 +0000 (10:27 -0000)
* ThemeWin32Classic.cs: Managed window title bar layout now uses actual
widths of icon and buttons instead of hard coded values.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs

index 8eda1c3eee4f8e2b2bb0940b7289cd78c8451ae1..7dc14869965a87827e15cabf0a754b68f6e32c6e 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-11  George Giolfan  <georgegiolfan@yahoo.com>
+
+       * ThemeWin32Classic.cs: Managed window title bar layout now uses actual
+       widths of icon and buttons instead of hard coded values.
+
 2008-06-10  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * ListBox.cs: When SelectionMode is None, clicking an item should move focus
index 6b81ccd1ef35d45ea0cfa98d3381c47d5664b0b5..5889b145de6b4d944e5980d920192aa1687a595e 100644 (file)
@@ -6138,10 +6138,20 @@ namespace System.Windows.Forms
                                        tbheight + bdwidth - 1, form.Width - bdwidth - 1,
                                        tbheight + bdwidth - 1);
 
-                       if (!wm.IsToolWindow) {
-                               tb.X += 18; // Room for the icon and the buttons
-                               tb.Width = (form.Width - 62) - tb.X;
+                       if (wm.ShowIcon) {
+                               Rectangle icon = ManagedWindowGetTitleBarIconArea (wm);
+                               if (icon.IntersectsWith (clip))
+                                       dc.DrawIcon (form.Icon, icon);
+                               const int SpacingBetweenIconAndCaption = 2;
+                               tb.Width -= icon.Right + SpacingBetweenIconAndCaption - tb.X ;
+                               tb.X = icon.Right + SpacingBetweenIconAndCaption;
+                       }
+                       
+                       foreach (TitleButton button in wm.TitleButtons.AllButtons) {
+                               tb.Width -= Math.Max (0, tb.Right - DrawTitleButton (dc, button, clip));
                        }
+                       const int SpacingBetweenCaptionAndLeftMostButton = 3;
+                       tb.Width -= SpacingBetweenCaptionAndLeftMostButton;
 
                        string window_caption = form.Text;
                        window_caption = window_caption.Replace (Environment.NewLine, string.Empty);
@@ -6157,16 +6167,6 @@ namespace System.Windows.Forms
                                                ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
                                                tb, format);
                        }
-
-                       if (wm.ShowIcon) {
-                               Rectangle icon = ManagedWindowGetTitleBarIconArea (wm);
-                               if (icon.IntersectsWith (clip))
-                                       dc.DrawIcon (form.Icon, icon);
-                       }
-                       
-                       foreach (TitleButton button in wm.TitleButtons.AllButtons) {
-                               DrawTitleButton (dc, button, clip);
-                       }
                }
 
                public override Size ManagedWindowButtonSize (InternalWindowManager wm)
@@ -6185,19 +6185,19 @@ namespace System.Windows.Forms
                                        height - 5);
                }
 
-               private void DrawTitleButton (Graphics dc, TitleButton button, Rectangle clip)
+               private int DrawTitleButton (Graphics dc, TitleButton button, Rectangle clip)
                {
                        if (!button.Visible) {
-                               return;
+                               return int.MaxValue;
                        }
                        
-                       if (!button.Rectangle.IntersectsWith (clip))
-                               return;
+                       if (button.Rectangle.IntersectsWith (clip)) {
+                               dc.FillRectangle (SystemBrushes.Control, button.Rectangle);
 
-                       dc.FillRectangle (SystemBrushes.Control, button.Rectangle);
-
-                       ControlPaint.DrawCaptionButton (dc, button.Rectangle,
-                                       button.Caption, button.State);
+                               ControlPaint.DrawCaptionButton (dc, button.Rectangle,
+                                               button.Caption, button.State);
+                       }
+                       return button.Rectangle.Left;
                }
 
                public override Rectangle ManagedWindowGetTitleBarIconArea (InternalWindowManager wm)