Author: jordi
Date: 2005-03-11 16:20:14 -0500 (Fri, 11 Mar 2005)
New Revision: 41723

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs
Log:
2005-03-11  Jordi Mas i Hernandez <[EMAIL PROTECTED]>

        * Form.cs: fixes menu drawing on X11
        * MenuAPI.cs:  fixes menu drawing on X11



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-03-11 21:12:45 UTC (rev 41722)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-03-11 21:20:14 UTC (rev 41723)
@@ -1,3 +1,8 @@
+2005-03-11  Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
+       * Form.cs: fixes menu drawing on X11
+       * MenuAPI.cs:  fixes menu drawing on X11
+
 2005-03-11  Peter Bartok  <[EMAIL PROTECTED]>
 
        * Form.cs:

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-11 21:12:45 UTC (rev 41722)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2005-03-11 21:20:14 UTC (rev 41723)
@@ -1290,8 +1290,8 @@
 
                                case Msg.WM_NCPAINT: {
                                        if (this.menu != null) {
-Console.WriteLine("This should be the origin for the menu: {0}, and the 
width:{1}", XplatUI.GetMenuOrigin(window.Handle), ClientSize.Width);
-                                               MenuAPI.DrawMenuBar 
(menu.Handle);
+                                               Point pnt = 
XplatUI.GetMenuOrigin(window.Handle);
+                                               MenuAPI.DrawMenuBar 
(menu.Handle, new Rectangle (pnt.X, pnt.Y, ClientSize.Width, 0));
                                        }
 
                                        base.WndProc(ref m);

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs       
2005-03-11 21:12:45 UTC (rev 41722)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs       
2005-03-11 21:20:14 UTC (rev 41723)
@@ -44,6 +44,8 @@
                public class MENU
                {
                        public MF               Flags;          // Menu flags 
(MF_POPUP, MF_SYSMENU)
+                       public int              X;              // Used in 
MenuBar only
+                       public int              Y;              // Used in 
MenuBar only
                        public int              Width;          // Width of the 
whole menu
                        public int              Height;         // Height of 
the whole menu
                        public Control          Wnd;            // In a Popup 
menu is the PopupWindow and in a MenuBar the Form
@@ -61,7 +63,7 @@
                                hParent = IntPtr.Zero;
                                items = new ArrayList ();
                                Flags = MF.MF_INSERT;
-                               Width = Height = FocusedItem = 0;               
                
+                               Width = Height = FocusedItem = X = Y = 0;
                                bMenubar = false;
                                bTracking = false;
                                menu = menu_obj;
@@ -262,21 +264,19 @@
                        Menu handeling API
                */
                
-               static public Point ClientAreaPointToScreen (Control wnd, Point 
pnt)            
+               static public Point ClientAreaPointToScreen (MENU menu, Point 
pnt)              
                {
                        Point rslt;
-                       pnt.Y -= ThemeEngine.Current.CaptionHeight;
-                       pnt.Y -= 
ThemeEngine.Current.FixedFrameBorderSize.Height;
-                       rslt = wnd.PointToScreen (pnt);                 
+                       pnt.Y -= menu.Y;
+                       rslt = menu.Wnd.PointToScreen (pnt);                    
                        return rslt;
                }
                
-               static public Point ClientAreaPointToClient (Control wnd, Point 
pnt)            
+               static public Point ClientAreaPointToClient (MENU menu, Point 
pnt)              
                {
                        Point rslt;                     
-                       rslt = wnd.PointToClient (pnt);                 
-                       rslt.Y += ThemeEngine.Current.CaptionHeight;
-                       rslt.Y += 
ThemeEngine.Current.FixedFrameBorderSize.Height;
+                       rslt = menu.Wnd.PointToClient (pnt);                    
+                       rslt.Y += menu.Y;
                        return rslt;
                }       
 
@@ -311,15 +311,21 @@
                        return null;
                }
 
+               static internal void DrawMenuBar (IntPtr hMenu)                 
+               {
+                       MENU menu = GetMenuFromID (hMenu);
+                       DrawMenuBar (hMenu, new Rectangle (menu.X, menu.Y, 
menu.Width, menu.Height));                                   
+               }
+
                // Little helper
-               static internal void DrawMenuBar (IntPtr hMenu) 
+               static internal void DrawMenuBar (IntPtr hMenu, Rectangle rect)
                {
-                       Rectangle rect;
                        Graphics g;
                        MENU menu = GetMenuFromID (hMenu);
 
-                       rect = new Rectangle 
(ThemeEngine.Current.FixedFrameBorderSize.Width, 
ThemeEngine.Current.CaptionHeight + 
ThemeEngine.Current.FixedFrameBorderSize.Height, 
-                               menu.Width, menu.Height);
+                       menu.X = rect.X;
+                       menu.Y = rect.Y;
+                       rect.Height = menu.Height;
 
                        g = XplatUI.GetMenuDC(menu.Wnd.window.Handle, 
IntPtr.Zero);
                        ThemeEngine.Current.DrawMenuBar (g, hMenu, rect);
@@ -518,7 +524,7 @@
                {
                        MENU menu = GetMenuFromID (hMenu);
                        Point pnt = new Point (item.rect.X, item.rect.Y + 
item.rect.Height + 1);
-                       pnt = ClientAreaPointToScreen (menu.Wnd, pnt);
+                       pnt = ClientAreaPointToScreen (menu, pnt);
                        MenuAPI.SelectItem (hMenu, item, false, tracker);
                        HideSubPopups (tracker.hCurrentMenu);
                        tracker.hCurrentMenu = hMenu;
@@ -532,9 +538,8 @@
 
                        switch (eventype) {
                                case MenuMouseEvent.Down: {
-                                       
                                        Point pnt = new Point (e.X, e.Y);
-                                       pnt = ClientAreaPointToClient 
(menu.Wnd, pnt);
+                                       pnt = ClientAreaPointToClient (menu, 
pnt);
 
                                        MenuAPI.MENUITEM item = 
MenuAPI.FindItemByCoords (hMenu, pnt);
 
@@ -563,7 +568,7 @@
 
                                                Point pnt = new Point (e.X, 
e.Y);
                                                //pnt = menu.Wnd.PointToClient 
(pnt);
-                                               pnt = ClientAreaPointToClient 
(menu.Wnd, pnt);
+                                               pnt = ClientAreaPointToClient 
(menu, pnt);
 
                                                MenuAPI.MENUITEM item = 
MenuAPI.FindItemByCoords (hMenu, pnt);
 

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

Reply via email to