Hi all (after a long absence...) and here's a patch for the menu and the caption buttons

William Poetra Yoga H williampoetra at yahoo.com
Fri Apr 15 00:05:07 CDT 2005


Hi guys (and gals), sorry for the long absence but my time got taken up in
something else (a problem with my isp, see
http://sourceforge.net/projects/drcom-client) and I couldn't spend my time
here...

Anyway, here are patches for the menu (it fixes some menu sizes, and also the
shift-down-by-1-pixel bug in winemine), and the caption (fixes the size and
position of the caption buttons).

Comments?

William Poetra Yoga Hadisoeseno

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
Index: dlls/user/menu.c
===================================================================
RCS file: /home/wine/wine/dlls/user/menu.c,v
retrieving revision 1.25
diff -u -p -r1.25 menu.c
--- dlls/user/menu.c	14 Apr 2005 13:56:29 -0000	1.25
+++ dlls/user/menu.c	15 Apr 2005 04:37:27 -0000
@@ -1090,7 +1090,7 @@ static void MENU_MenuBarCalcSize( HDC hd
           lprect->left, lprect->top, lprect->right, lprect->bottom);
     lppop->Width  = lprect->right - lprect->left;
     lppop->Height = 0;
-    maxY = lprect->top+1;
+    maxY = lprect->top;
     start = 0;
     helpPos = -1;
     lppop->maxBmpSize.cx = 0;
@@ -1126,7 +1126,7 @@ static void MENU_MenuBarCalcSize( HDC hd
 	while (start < i) lppop->items[start++].rect.bottom = maxY;
     }
 
-    lprect->bottom = maxY;
+    lprect->bottom = maxY + 1;
     lppop->Height = lprect->bottom - lprect->top;
 
     /* Flush right all items between the MF_RIGHTJUSTIFY and */
@@ -1514,7 +1514,7 @@ UINT MENU_DrawMenuBar( HDC hDC, LPRECT l
     lppop = MENU_GetMenu( hMenu );
     if (lppop == NULL || lprect == NULL)
     {
-        return GetSystemMetrics(SM_CYMENU);
+        return GetSystemMetrics(SM_CYMENU) + 1;
     }
 
     if (suppress_draw)
@@ -3857,7 +3857,7 @@ DWORD WINAPI DrawMenuBarTemp(HWND hwnd, 
     lppop = MENU_GetMenu( hMenu );
     if (lppop == NULL || lprect == NULL)
     {
-        retvalue = GetSystemMetrics(SM_CYMENU);
+        retvalue = GetSystemMetrics(SM_CYMENU) + 1;
         goto END;
     }
 
@@ -3878,7 +3878,7 @@ DWORD WINAPI DrawMenuBarTemp(HWND hwnd, 
 
     if (lppop->nItems == 0)
     {
-        retvalue = GetSystemMetrics(SM_CYMENU);
+        retvalue = GetSystemMetrics(SM_CYMENU) + 1;
         goto END;
     }
 
Index: windows/nonclient.c
===================================================================
RCS file: /home/wine/wine/windows/nonclient.c,v
retrieving revision 1.141
diff -u -p -r1.141 nonclient.c
--- windows/nonclient.c	13 Apr 2005 16:13:45 -0000	1.141
+++ windows/nonclient.c	15 Apr 2005 04:37:28 -0000
@@ -398,7 +398,7 @@ LONG NC_HandleNCCalcSize( HWND hwnd, REC
 	    winRect->top +=
 		MENU_GetMenuBarHeight( hwnd,
 				       winRect->right - winRect->left,
-				       -tmpRect.left, -tmpRect.top ) + 1;
+				       -tmpRect.left, -tmpRect.top );
 	}
 
         if( exStyle & WS_EX_CLIENTEDGE)
-------------- next part --------------
Index: windows/nonclient.c
===================================================================
RCS file: /home/wine/wine/windows/nonclient.c,v
retrieving revision 1.141
diff -u -p -r1.141 nonclient.c
--- windows/nonclient.c	13 Apr 2005 16:13:45 -0000	1.141
+++ windows/nonclient.c	15 Apr 2005 04:37:28 -0000
@@ -691,21 +691,21 @@ static void NC_DrawCloseButton (HWND hwn
     /* A tool window has a smaller Close button */
     if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW)
     {
-        INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE   */
-        INT iBmpWidth = 11;  /* it uses 11x11 for  the close button in tool window */
-        INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
+        INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION) - 1;
+        INT iBmpHeight = iCaptionHeight - 4;
+        INT iBmpWidth = iCaptionHeight - 5;
 
-        rect.top = rect.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
-        rect.left = rect.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
+        rect.top += 2;
+        rect.right -= 2;
         rect.bottom = rect.top + iBmpHeight;
-        rect.right = rect.left + iBmpWidth;
+        rect.left = rect.right - iBmpWidth;
     }
     else
     {
-        rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) - 1;
-        rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
         rect.top += 2;
         rect.right -= 2;
+        rect.bottom = rect.top + (GetSystemMetrics(SM_CYSIZE) - 4);
+        rect.left = rect.right - (GetSystemMetrics(SM_CXSIZE) - 2);
     }
     DrawFrameControl( hdc, &rect, DFC_CAPTION,
                       (DFCS_CAPTIONCLOSE |
@@ -731,12 +731,12 @@ static void NC_DrawMaxButton(HWND hwnd,H
     flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
 
     NC_GetInsideRect( hwnd, &rect );
-    if (GetWindowLongW( hwnd, GWL_STYLE) & WS_SYSMENU)
-        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
-    rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
-    rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
     rect.top += 2;
+    if (GetWindowLongA( hwnd, GWL_STYLE) & WS_SYSMENU)
+        rect.right -= (GetSystemMetrics(SM_CXSIZE) - 2) + 2;
     rect.right -= 2;
+    rect.bottom = rect.top + (GetSystemMetrics(SM_CYSIZE) - 4);
+    rect.left = rect.right - (GetSystemMetrics(SM_CXSIZE) - 2);
     if (down) flags |= DFCS_PUSHED;
     if (bGrayed) flags |= DFCS_INACTIVE;
     DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
@@ -759,14 +759,14 @@ static void  NC_DrawMinButton(HWND hwnd,
         return;
 
     NC_GetInsideRect( hwnd, &rect );
+    rect.top += 2;
     if (style & WS_SYSMENU)
-        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
+        rect.right -= (GetSystemMetrics(SM_CXSIZE) - 2) + 2;
+    rect.right -= 2;
     if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
         rect.right -= GetSystemMetrics(SM_CXSIZE) - 2;
-    rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
-    rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
-    rect.top += 2;
-    rect.right -= 2;
+    rect.left = rect.right - (GetSystemMetrics(SM_CXSIZE) - 2);
+    rect.bottom = rect.top + (GetSystemMetrics(SM_CYSIZE) - 4);
     if (down) flags |= DFCS_PUSHED;
     if (bGrayed) flags |= DFCS_INACTIVE;
     DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
@@ -893,19 +893,23 @@ static void  NC_DrawCaption( HDC  hdc, R
 
 	/* Draw a grayed close button if disabled or if SC_CLOSE is not there */
 	NC_DrawCloseButton (hwnd, hdc, FALSE,
-			    (state & (MF_DISABLED | MF_GRAYED)) || (state == 0xFFFFFFFF));
-	r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
+			    ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
+	r.right -= (GetSystemMetrics(SM_CXSIZE) - 2) + 2;
 
 	if ((style & WS_MAXIMIZEBOX) || (style & WS_MINIMIZEBOX))
 	{
+            /* There's a 2-pixel space between Maximize and Close buttons */
+
+            r.right -= 2;
+
 	    /* In win95 the two buttons are always there */
 	    /* But if the menu item is not in the menu they're disabled*/
 
 	    NC_DrawMaxButton( hwnd, hdc, FALSE, (!(style & WS_MAXIMIZEBOX)));
-	    r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
+	    r.right -= GetSystemMetrics(SM_CXSIZE) - 2;
 
 	    NC_DrawMinButton( hwnd, hdc, FALSE,  (!(style & WS_MINIMIZEBOX)));
-	    r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
+	    r.right -= GetSystemMetrics(SM_CXSIZE) - 2;
 	}
     }
 
@@ -924,6 +928,7 @@ static void  NC_DrawCaption( HDC  hdc, R
 	else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
 	SetBkMode( hdc, TRANSPARENT );
 	r.left += 2;
+        r.right -= 2;
 	DrawTextW( hdc, buffer, -1, &r,
 		     DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
 	DeleteObject (SelectObject (hdc, hOldFont));
@@ -1025,7 +1030,7 @@ static void  NC_DoNCPaint( HWND  hwnd, H
 	TRACE("Calling DrawMenuBar with rect (%ld, %ld)-(%ld, %ld)\n",
               r.left, r.top, r.right, r.bottom);
 
-	rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
+	rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
     }
 
     TRACE("After MenuBar, rect is (%ld, %ld)-(%ld, %ld).\n",


More information about the wine-devel mailing list