Rein Klazes : user: Menu drawing fixes.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Feb 20 05:41:08 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 2757532fee1e8bc48e6d4131e7e9b2fa71f9fb50
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=2757532fee1e8bc48e6d4131e7e9b2fa71f9fb50

Author: Rein Klazes <wijn at wanadoo.nl>
Date:   Mon Feb 20 11:57:07 2006 +0100

user: Menu drawing fixes.
Replace some #defined constants by values calculated from windows
metrics.

---

 dlls/user/menu.c |   52 ++++++++++++++++++++++++----------------------------
 1 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/dlls/user/menu.c b/dlls/user/menu.c
index cf76884..26bcff5 100644
--- a/dlls/user/menu.c
+++ b/dlls/user/menu.c
@@ -140,15 +140,6 @@ typedef struct
 #define TPM_BUTTONDOWN		0x40000000		/* menu was clicked before tracking */
 #define TPM_POPUPMENU           0x20000000              /* menu is a popup menu */
 
-  /* Space between 2 menu bar items */
-#define MENU_BAR_ITEMS_SPACE 12
-
-  /* Minimum width of a tab character */
-#define MENU_TAB_SPACE 8
-
-  /* Height of a separator item */
-#define SEPARATOR_HEIGHT 5
-
   /* Space between 2 columns */
 #define MENU_COL_SPACE 4
 
@@ -960,18 +951,19 @@ static void MENU_CalcItemSize( HDC hdc, 
     GetObjectW( get_arrow_bitmap(), sizeof(bm), &bm );
     arrow_bitmap_width = bm.bmWidth;
 
+    /* not done in Menu_Init: GetDialogBaseUnits() breaks there */
+    if( !menucharsize.cx ) {
+        menucharsize.cx = GdiGetCharDimensions( hdc, NULL, &menucharsize.cy );
+        /* Win95/98/ME will use menucharsize.cy here. Testing is possible
+         * but it is unlikely an application will depend on that */
+        ODitemheight = HIWORD( GetDialogBaseUnits());
+    }
+
     SetRect( &lpitem->rect, orgX, orgY, orgX, orgY );
 
     if (lpitem->fType & MF_OWNERDRAW)
     {
         MEASUREITEMSTRUCT mis;
-        /* not done in Menu_Init: GetDialogBaseUnits() breaks there */
-        if( !menucharsize.cx ) {
-            menucharsize.cx = GdiGetCharDimensions( hdc, NULL, &menucharsize.cy );
-            /* Win95/98/ME will use menucharsize.cy here. Testing is possible
-             * but it is unlikely an application will depend on that */
-            ODitemheight = HIWORD( GetDialogBaseUnits());
-        }
         mis.CtlType    = ODT_MENU;
         mis.CtlID      = 0;
         mis.itemID     = lpitem->wID;
@@ -998,14 +990,16 @@ static void MENU_CalcItemSize( HDC hdc, 
 
     if (lpitem->fType & MF_SEPARATOR)
     {
-	lpitem->rect.bottom += SEPARATOR_HEIGHT;
-	return;
+        lpitem->rect.bottom += GetSystemMetrics( SM_CYMENUSIZE)/2;
+        if( !menuBar)
+            lpitem->rect.right += arrow_bitmap_width + menucharsize.cx;
+        return;
     }
 
     if (!menuBar) {
         if (lpitem->hbmpItem) {
             SIZE size;
-            
+
             MENU_GetBitmapItemSize(lpitem, &size, hwndOwner);
             /* Keep the size of the bitmap in callback mode to be able
              * to draw it correctly */
@@ -1046,19 +1040,19 @@ static void MENU_CalcItemSize( HDC hdc, 
 
 	if (menuBar)
 	{
-	     lpitem->rect.right += MENU_BAR_ITEMS_SPACE;
+            lpitem->rect.right +=  2 * menucharsize.cx;
 	}
 	else if ((p = strchrW( lpitem->text, '\t' )) != NULL)
 	{
 	    /* Item contains a tab (only meaningful in popup menus) */
 	    GetTextExtentPoint32W(hdc, lpitem->text, (int)(p - lpitem->text) , &size);
-	    lpitem->xTab = check_bitmap_width + MENU_TAB_SPACE + size.cx;
-	    lpitem->rect.right += MENU_TAB_SPACE;
+	    lpitem->xTab = check_bitmap_width + menucharsize.cx + size.cx;
+	    lpitem->rect.right += menucharsize.cx;
 	}
 	else
 	{
 	    if (strchrW( lpitem->text, '\b' ))
-	        lpitem->rect.right += MENU_TAB_SPACE;
+                lpitem->rect.right += menucharsize.cx;
 	    lpitem->xTab = lpitem->rect.right - check_bitmap_width
 	                   - arrow_bitmap_width;
 	}
@@ -1456,7 +1450,7 @@ static void MENU_DrawMenuItem( HWND hwnd
 
         rc.left++;
         rc.right--;
-        rc.top += SEPARATOR_HEIGHT / 2;
+        rc.top = ( rc.top + rc.bottom) / 2;
         if (flat_menu)
         {
             oldPen = SelectObject( hdc, SYSCOLOR_GetPen(COLOR_BTNSHADOW) );
@@ -1585,10 +1579,12 @@ static void MENU_DrawMenuItem( HWND hwnd
 	     hfontOld = SelectObject( hdc, get_menu_font(TRUE) );
 	}
 
-	if (menuBar)
-	{
-	    rect.left += MENU_BAR_ITEMS_SPACE / 2;
-	    rect.right -= MENU_BAR_ITEMS_SPACE / 2;
+	if (menuBar) {
+            if( lpitem->hbmpItem)
+                rect.left += lpitem->bmpsize.cx;
+            if( !(lpitem->hbmpItem == HBMMENU_CALLBACK))
+                rect.left += menucharsize.cx;
+            rect.right -= menucharsize.cx;
 	}
 
 	for (i = 0; lpitem->text[i]; i++)




More information about the wine-cvs mailing list