Commit 2757532f authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

user: Menu drawing fixes.

Replace some #defined constants by values calculated from windows metrics.
parent 444a5471
...@@ -140,15 +140,6 @@ typedef struct ...@@ -140,15 +140,6 @@ typedef struct
#define TPM_BUTTONDOWN 0x40000000 /* menu was clicked before tracking */ #define TPM_BUTTONDOWN 0x40000000 /* menu was clicked before tracking */
#define TPM_POPUPMENU 0x20000000 /* menu is a popup menu */ #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 */ /* Space between 2 columns */
#define MENU_COL_SPACE 4 #define MENU_COL_SPACE 4
...@@ -960,18 +951,19 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner, ...@@ -960,18 +951,19 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner,
GetObjectW( get_arrow_bitmap(), sizeof(bm), &bm ); GetObjectW( get_arrow_bitmap(), sizeof(bm), &bm );
arrow_bitmap_width = bm.bmWidth; 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 ); SetRect( &lpitem->rect, orgX, orgY, orgX, orgY );
if (lpitem->fType & MF_OWNERDRAW) if (lpitem->fType & MF_OWNERDRAW)
{ {
MEASUREITEMSTRUCT mis; 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.CtlType = ODT_MENU;
mis.CtlID = 0; mis.CtlID = 0;
mis.itemID = lpitem->wID; mis.itemID = lpitem->wID;
...@@ -998,14 +990,16 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner, ...@@ -998,14 +990,16 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner,
if (lpitem->fType & MF_SEPARATOR) if (lpitem->fType & MF_SEPARATOR)
{ {
lpitem->rect.bottom += SEPARATOR_HEIGHT; lpitem->rect.bottom += GetSystemMetrics( SM_CYMENUSIZE)/2;
return; if( !menuBar)
lpitem->rect.right += arrow_bitmap_width + menucharsize.cx;
return;
} }
if (!menuBar) { if (!menuBar) {
if (lpitem->hbmpItem) { if (lpitem->hbmpItem) {
SIZE size; SIZE size;
MENU_GetBitmapItemSize(lpitem, &size, hwndOwner); MENU_GetBitmapItemSize(lpitem, &size, hwndOwner);
/* Keep the size of the bitmap in callback mode to be able /* Keep the size of the bitmap in callback mode to be able
* to draw it correctly */ * to draw it correctly */
...@@ -1046,19 +1040,19 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner, ...@@ -1046,19 +1040,19 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner,
if (menuBar) if (menuBar)
{ {
lpitem->rect.right += MENU_BAR_ITEMS_SPACE; lpitem->rect.right += 2 * menucharsize.cx;
} }
else if ((p = strchrW( lpitem->text, '\t' )) != NULL) else if ((p = strchrW( lpitem->text, '\t' )) != NULL)
{ {
/* Item contains a tab (only meaningful in popup menus) */ /* Item contains a tab (only meaningful in popup menus) */
GetTextExtentPoint32W(hdc, lpitem->text, (int)(p - lpitem->text) , &size); GetTextExtentPoint32W(hdc, lpitem->text, (int)(p - lpitem->text) , &size);
lpitem->xTab = check_bitmap_width + MENU_TAB_SPACE + size.cx; lpitem->xTab = check_bitmap_width + menucharsize.cx + size.cx;
lpitem->rect.right += MENU_TAB_SPACE; lpitem->rect.right += menucharsize.cx;
} }
else else
{ {
if (strchrW( lpitem->text, '\b' )) if (strchrW( lpitem->text, '\b' ))
lpitem->rect.right += MENU_TAB_SPACE; lpitem->rect.right += menucharsize.cx;
lpitem->xTab = lpitem->rect.right - check_bitmap_width lpitem->xTab = lpitem->rect.right - check_bitmap_width
- arrow_bitmap_width; - arrow_bitmap_width;
} }
...@@ -1456,7 +1450,7 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc, ...@@ -1456,7 +1450,7 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
rc.left++; rc.left++;
rc.right--; rc.right--;
rc.top += SEPARATOR_HEIGHT / 2; rc.top = ( rc.top + rc.bottom) / 2;
if (flat_menu) if (flat_menu)
{ {
oldPen = SelectObject( hdc, SYSCOLOR_GetPen(COLOR_BTNSHADOW) ); oldPen = SelectObject( hdc, SYSCOLOR_GetPen(COLOR_BTNSHADOW) );
...@@ -1585,10 +1579,12 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc, ...@@ -1585,10 +1579,12 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
hfontOld = SelectObject( hdc, get_menu_font(TRUE) ); hfontOld = SelectObject( hdc, get_menu_font(TRUE) );
} }
if (menuBar) if (menuBar) {
{ if( lpitem->hbmpItem)
rect.left += MENU_BAR_ITEMS_SPACE / 2; rect.left += lpitem->bmpsize.cx;
rect.right -= MENU_BAR_ITEMS_SPACE / 2; if( !(lpitem->hbmpItem == HBMMENU_CALLBACK))
rect.left += menucharsize.cx;
rect.right -= menucharsize.cx;
} }
for (i = 0; lpitem->text[i]; i++) for (i = 0; lpitem->text[i]; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment