fix text align when using HBMMENU_CALLBACK (patch by Brezenbak)
Modified: trunk/reactos/lib/user32/windows/menu.c
Modified: trunk/reactos/subsys/win32k/ntuser/menu.c

Modified: trunk/reactos/lib/user32/windows/menu.c
--- trunk/reactos/lib/user32/windows/menu.c	2006-01-16 23:00:38 UTC (rev 20924)
+++ trunk/reactos/lib/user32/windows/menu.c	2006-01-16 23:20:11 UTC (rev 20925)
@@ -63,6 +63,7 @@
 
 #define IS_MAGIC_ITEM(Bmp)   ((int) Bmp <12)
 
+#define MENU_ITEM_HBMP_SPACE (5)
 #define MENU_BAR_ITEMS_SPACE (12)
 #define SEPARATOR_HEIGHT (5)
 #define MENU_TAB_SPACE (8)
@@ -763,6 +764,11 @@
           Rect.left += MENU_BAR_ITEMS_SPACE / 2;
           Rect.right -= MENU_BAR_ITEMS_SPACE / 2;
         }
+      if (Item->hbmpItem == HBMMENU_CALLBACK || MenuInfo->maxBmpSize.cx != 0 )
+        {
+          Rect.left += MenuInfo->maxBmpSize.cx;
+          Rect.right -= MenuInfo->maxBmpSize.cx;
+        }
 
       Text = (PWCHAR) Item->dwTypeData;
       for (i = 0; L'\0' != Text[i]; i++)
@@ -784,7 +790,6 @@
 	    }
           SetTextColor(Dc, RGB(0x80, 0x80, 0x80));
         }
-
       DrawTextW(Dc, Text, i, &Rect, uFormat);
 
       /* paint the shortcut text */
@@ -1130,7 +1135,7 @@
  * Calculate the size of the menu item and store it in ItemInfo->rect.
  */
 static void FASTCALL
-MenuCalcItemSize(HDC Dc, PROSMENUITEMINFO ItemInfo, HWND WndOwner,
+MenuCalcItemSize(HDC Dc, PROSMENUITEMINFO ItemInfo, PROSMENUINFO MenuInfo, HWND WndOwner,
                  INT OrgX, INT OrgY, BOOL MenuBar)
 {
   PWCHAR p;
@@ -1203,7 +1208,14 @@
               measItem.itemData = ItemInfo->dwItemData;
               SendMessageW( WndOwner, WM_MEASUREITEM, ItemInfo->wID, (LPARAM)&measItem);
               ItemInfo->Rect.right = ItemInfo->Rect.left + measItem.itemWidth;
-          }
+              if (MenuInfo->maxBmpSize.cx < abs(measItem.itemWidth) +  MENU_ITEM_HBMP_SPACE || 
+                  MenuInfo->maxBmpSize.cy < abs(measItem.itemHeight))
+              {
+                  MenuInfo->maxBmpSize.cx = abs(measItem.itemWidth) + MENU_ITEM_HBMP_SPACE;
+                  MenuInfo->maxBmpSize.cy = abs(measItem.itemHeight);
+                  MenuSetRosMenuInfo(MenuInfo);
+              }
+           }
           else
           {
               SIZE Size;
@@ -1320,7 +1332,7 @@
               break;
             }
 
-          MenuCalcItemSize(Dc, &ItemInfo, WndOwner, OrgX, OrgY, FALSE);
+          MenuCalcItemSize(Dc, &ItemInfo, MenuInfo, WndOwner, OrgX, OrgY, FALSE);
           if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo))
             {
               MenuCleanupRosMenuItemInfo(&ItemInfo);
@@ -1426,7 +1438,7 @@
             }
 
           DPRINT("calling MENU_CalcItemSize org=(%d, %d)\n", OrgX, OrgY);
-          MenuCalcItemSize(Dc, &ItemInfo, WndOwner, OrgX, OrgY, TRUE);
+          MenuCalcItemSize(Dc, &ItemInfo, MenuInfo, WndOwner, OrgX, OrgY, TRUE);
           if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo))
             {
               MenuCleanupRosMenuItemInfo(&ItemInfo);

Modified: trunk/reactos/subsys/win32k/ntuser/menu.c
--- trunk/reactos/subsys/win32k/ntuser/menu.c	2006-01-16 23:00:38 UTC (rev 20924)
+++ trunk/reactos/subsys/win32k/ntuser/menu.c	2006-01-16 23:20:11 UTC (rev 20925)
@@ -486,7 +486,11 @@
                     (char *) &Menu->MenuInfo + sizeof(MENUINFO),
                     lpmi->cbSize - sizeof(MENUINFO));
    }
-
+   if (sizeof(ROSMENUINFO) == lpmi->cbSize)
+   {
+     lpmi->maxBmpSize.cx = Menu->MenuInfo.maxBmpSize.cx;
+     lpmi->maxBmpSize.cy = Menu->MenuInfo.maxBmpSize.cy;
+   }
    return TRUE;
 }
 
@@ -530,7 +534,11 @@
       Menu->MenuInfo.WndOwner = lpmi->WndOwner;
       Menu->MenuInfo.TimeToHide = lpmi->TimeToHide;
    }
-
+   if (sizeof(ROSMENUINFO) == lpmi->cbSize)
+   {
+     Menu->MenuInfo.maxBmpSize.cx = lpmi->maxBmpSize.cx;
+     Menu->MenuInfo.maxBmpSize.cy = lpmi->maxBmpSize.cy;
+   }
    return TRUE;
 }