user32: Store the item rects as relative to the items_rect.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6f3afc1a1c
commit
1bdd12f493
|
@ -76,7 +76,8 @@ typedef struct {
|
||||||
LPWSTR dwTypeData; /* depends on fMask */
|
LPWSTR dwTypeData; /* depends on fMask */
|
||||||
HBITMAP hbmpItem; /* bitmap */
|
HBITMAP hbmpItem; /* bitmap */
|
||||||
/* ----------- Wine stuff ----------- */
|
/* ----------- Wine stuff ----------- */
|
||||||
RECT rect; /* Item area (relative to menu window) */
|
RECT rect; /* Item area (relative to the items_rect).
|
||||||
|
* See MENU_AdjustMenuItemRect(). */
|
||||||
UINT xTab; /* X position of text after Tab */
|
UINT xTab; /* X position of text after Tab */
|
||||||
SIZE bmpsize; /* size needed for the HBMMENU_CALLBACK
|
SIZE bmpsize; /* size needed for the HBMMENU_CALLBACK
|
||||||
* bitmap */
|
* bitmap */
|
||||||
|
@ -706,13 +707,9 @@ static void MENU_FreeItemData( MENUITEM* item )
|
||||||
static void
|
static void
|
||||||
MENU_AdjustMenuItemRect(const POPUPMENU *menu, LPRECT rect)
|
MENU_AdjustMenuItemRect(const POPUPMENU *menu, LPRECT rect)
|
||||||
{
|
{
|
||||||
if (menu->bScrolling)
|
INT scroll_offset = menu->bScrolling ? menu->nScrollPos : 0;
|
||||||
{
|
|
||||||
UINT arrow_height;
|
|
||||||
|
|
||||||
arrow_height = get_scroll_arrow_height( menu );
|
OffsetRect( rect, menu->items_rect.left, menu->items_rect.top - scroll_offset );
|
||||||
OffsetRect( rect, 0, arrow_height - menu->nScrollPos );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1174,7 +1171,7 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
|
||||||
int orgX, orgY, maxTab, maxTabWidth, maxHeight;
|
int orgX, orgY, maxTab, maxTabWidth, maxHeight;
|
||||||
|
|
||||||
lppop->Width = lppop->Height = 0;
|
lppop->Width = lppop->Height = 0;
|
||||||
SetRect(&lppop->items_rect, MENU_MARGIN, MENU_MARGIN, MENU_MARGIN, MENU_MARGIN);
|
SetRectEmpty(&lppop->items_rect);
|
||||||
|
|
||||||
if (lppop->nItems == 0) return;
|
if (lppop->nItems == 0) return;
|
||||||
hdc = GetDC( 0 );
|
hdc = GetDC( 0 );
|
||||||
|
@ -1230,7 +1227,8 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
|
||||||
* of the bitmaps */
|
* of the bitmaps */
|
||||||
if( !textandbmp) lppop->textOffset = 0;
|
if( !textandbmp) lppop->textOffset = 0;
|
||||||
|
|
||||||
/* space for 3d border */
|
/* space for the border */
|
||||||
|
OffsetRect(&lppop->items_rect, MENU_MARGIN, MENU_MARGIN);
|
||||||
lppop->Height = lppop->items_rect.bottom + MENU_MARGIN;
|
lppop->Height = lppop->items_rect.bottom + MENU_MARGIN;
|
||||||
lppop->Width = lppop->items_rect.right + MENU_MARGIN;
|
lppop->Width = lppop->items_rect.right + MENU_MARGIN;
|
||||||
|
|
||||||
|
@ -1267,22 +1265,22 @@ static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect,
|
||||||
{
|
{
|
||||||
MENUITEM *lpitem;
|
MENUITEM *lpitem;
|
||||||
UINT start, i, helpPos;
|
UINT start, i, helpPos;
|
||||||
int orgX, orgY, maxY;
|
int orgX, orgY;
|
||||||
|
|
||||||
if ((lprect == NULL) || (lppop == NULL)) return;
|
if ((lprect == NULL) || (lppop == NULL)) return;
|
||||||
if (lppop->nItems == 0) return;
|
if (lppop->nItems == 0) return;
|
||||||
TRACE("lprect %p %s\n", lprect, wine_dbgstr_rect( lprect));
|
TRACE("lprect %p %s\n", lprect, wine_dbgstr_rect( lprect));
|
||||||
lppop->Width = lprect->right - lprect->left;
|
/* Start with a 1 pixel top border.
|
||||||
lppop->Height = 0;
|
This corresponds to the difference between SM_CYMENU and SM_CYMENUSIZE. */
|
||||||
maxY = lprect->top+1;
|
SetRect(&lppop->items_rect, 0, 0, lprect->right - lprect->left, 1);
|
||||||
start = 0;
|
start = 0;
|
||||||
helpPos = ~0U;
|
helpPos = ~0U;
|
||||||
lppop->textOffset = 0;
|
lppop->textOffset = 0;
|
||||||
while (start < lppop->nItems)
|
while (start < lppop->nItems)
|
||||||
{
|
{
|
||||||
lpitem = &lppop->items[start];
|
lpitem = &lppop->items[start];
|
||||||
orgX = lprect->left;
|
orgX = lppop->items_rect.left;
|
||||||
orgY = maxY;
|
orgY = lppop->items_rect.bottom;
|
||||||
|
|
||||||
/* Parse items until line break or end of menu */
|
/* Parse items until line break or end of menu */
|
||||||
for (i = start; i < lppop->nItems; i++, lpitem++)
|
for (i = start; i < lppop->nItems; i++, lpitem++)
|
||||||
|
@ -1295,29 +1293,30 @@ static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect,
|
||||||
debug_print_menuitem (" item: ", lpitem, "");
|
debug_print_menuitem (" item: ", lpitem, "");
|
||||||
MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, TRUE, lppop );
|
MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, TRUE, lppop );
|
||||||
|
|
||||||
if (lpitem->rect.right > lprect->right)
|
if (lpitem->rect.right > lppop->items_rect.right)
|
||||||
{
|
{
|
||||||
if (i != start) break;
|
if (i != start) break;
|
||||||
else lpitem->rect.right = lprect->right;
|
else lpitem->rect.right = lppop->items_rect.right;
|
||||||
}
|
}
|
||||||
maxY = max( maxY, lpitem->rect.bottom );
|
lppop->items_rect.bottom = max( lppop->items_rect.bottom, lpitem->rect.bottom );
|
||||||
orgX = lpitem->rect.right;
|
orgX = lpitem->rect.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finish the line (set all items to the largest height found) */
|
/* Finish the line (set all items to the largest height found) */
|
||||||
while (start < i) lppop->items[start++].rect.bottom = maxY;
|
while (start < i) lppop->items[start++].rect.bottom = lppop->items_rect.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
lprect->bottom = maxY;
|
OffsetRect(&lppop->items_rect, lprect->left, lprect->top);
|
||||||
lppop->Height = lprect->bottom - lprect->top;
|
lppop->Width = lppop->items_rect.right - lppop->items_rect.left;
|
||||||
lppop->items_rect = *lprect;
|
lppop->Height = lppop->items_rect.bottom - lppop->items_rect.top;
|
||||||
|
lprect->bottom = lppop->items_rect.bottom;
|
||||||
|
|
||||||
/* Flush right all items between the MF_RIGHTJUSTIFY and */
|
/* Flush right all items between the MF_RIGHTJUSTIFY and */
|
||||||
/* the last item (if several lines, only move the last line) */
|
/* the last item (if several lines, only move the last line) */
|
||||||
if (helpPos == ~0U) return;
|
if (helpPos == ~0U) return;
|
||||||
lpitem = &lppop->items[lppop->nItems-1];
|
lpitem = &lppop->items[lppop->nItems-1];
|
||||||
orgY = lpitem->rect.top;
|
orgY = lpitem->rect.top;
|
||||||
orgX = lprect->right;
|
orgX = lprect->right - lprect->left;
|
||||||
for (i = lppop->nItems - 1; i >= helpPos; i--, lpitem--) {
|
for (i = lppop->nItems - 1; i >= helpPos; i--, lpitem--) {
|
||||||
if (lpitem->rect.top != orgY) break; /* Other line */
|
if (lpitem->rect.top != orgY) break; /* Other line */
|
||||||
if (lpitem->rect.right >= orgX) break; /* Too far right already */
|
if (lpitem->rect.right >= orgX) break; /* Too far right already */
|
||||||
|
@ -1945,17 +1944,15 @@ MENU_EnsureMenuItemVisible(LPPOPUPMENU lppop, UINT wIndex, HDC hdc)
|
||||||
const RECT *rc = &lppop->items_rect;
|
const RECT *rc = &lppop->items_rect;
|
||||||
UINT scroll_height = rc->bottom - rc->top;
|
UINT scroll_height = rc->bottom - rc->top;
|
||||||
|
|
||||||
/* NB the item rects include the MENU_MARGIN offset (so the first rect has
|
if (item->rect.bottom > lppop->nScrollPos + scroll_height)
|
||||||
top == MENU_TOP_MARGIN) */
|
|
||||||
if (item->rect.bottom - MENU_MARGIN > lppop->nScrollPos + scroll_height)
|
|
||||||
{
|
{
|
||||||
lppop->nScrollPos = item->rect.bottom - MENU_MARGIN - scroll_height;
|
lppop->nScrollPos = item->rect.bottom - scroll_height;
|
||||||
ScrollWindow(lppop->hWnd, 0, nOldPos - lppop->nScrollPos, rc, rc);
|
ScrollWindow(lppop->hWnd, 0, nOldPos - lppop->nScrollPos, rc, rc);
|
||||||
MENU_DrawScrollArrows(lppop, hdc);
|
MENU_DrawScrollArrows(lppop, hdc);
|
||||||
}
|
}
|
||||||
else if (item->rect.top - MENU_MARGIN < lppop->nScrollPos)
|
else if (item->rect.top < lppop->nScrollPos)
|
||||||
{
|
{
|
||||||
lppop->nScrollPos = item->rect.top - MENU_MARGIN;
|
lppop->nScrollPos = item->rect.top;
|
||||||
ScrollWindow(lppop->hWnd, 0, nOldPos - lppop->nScrollPos, rc, rc);
|
ScrollWindow(lppop->hWnd, 0, nOldPos - lppop->nScrollPos, rc, rc);
|
||||||
MENU_DrawScrollArrows(lppop, hdc);
|
MENU_DrawScrollArrows(lppop, hdc);
|
||||||
}
|
}
|
||||||
|
@ -2360,32 +2357,32 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
RECT item_rect = item->rect;
|
||||||
|
|
||||||
|
MENU_AdjustMenuItemRect(menu, &item_rect);
|
||||||
GetWindowRect( menu->hWnd, &rect );
|
GetWindowRect( menu->hWnd, &rect );
|
||||||
|
|
||||||
if (menu->wFlags & MF_POPUP)
|
if (menu->wFlags & MF_POPUP)
|
||||||
{
|
{
|
||||||
RECT rc = item->rect;
|
|
||||||
|
|
||||||
MENU_AdjustMenuItemRect(menu, &rc);
|
|
||||||
|
|
||||||
/* The first item in the popup menu has to be at the
|
/* The first item in the popup menu has to be at the
|
||||||
same y position as the focused menu item */
|
same y position as the focused menu item */
|
||||||
if (wFlags & TPM_LAYOUTRTL)
|
if (wFlags & TPM_LAYOUTRTL)
|
||||||
rect.left += GetSystemMetrics(SM_CXBORDER);
|
rect.left += GetSystemMetrics(SM_CXBORDER);
|
||||||
else
|
else
|
||||||
rect.left += rc.right - GetSystemMetrics(SM_CXBORDER);
|
rect.left += item_rect.right - GetSystemMetrics(SM_CXBORDER);
|
||||||
rect.top += rc.top - MENU_MARGIN;
|
rect.top += item_rect.top - MENU_MARGIN;
|
||||||
rect.right = rc.left - rc.right + GetSystemMetrics(SM_CXBORDER);
|
rect.right = item_rect.left - item_rect.right + GetSystemMetrics(SM_CXBORDER);
|
||||||
rect.bottom = rc.top - rc.bottom - 2 * MENU_MARGIN;
|
rect.bottom = item_rect.top - item_rect.bottom - 2 * MENU_MARGIN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (wFlags & TPM_LAYOUTRTL)
|
if (wFlags & TPM_LAYOUTRTL)
|
||||||
rect.left = rect.right - item->rect.left;
|
rect.left = rect.right - item_rect.left;
|
||||||
else
|
else
|
||||||
rect.left += item->rect.left;
|
rect.left += item_rect.left;
|
||||||
rect.top += item->rect.bottom;
|
rect.top += item_rect.bottom;
|
||||||
rect.right = item->rect.right - item->rect.left;
|
rect.right = item_rect.right - item_rect.left;
|
||||||
rect.bottom = item->rect.bottom - item->rect.top;
|
rect.bottom = item_rect.bottom - item_rect.top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5118,6 +5115,7 @@ BOOL WINAPI GetMenuItemRect(HWND hwnd, HMENU hMenu, UINT uItem, RECT *rect)
|
||||||
|
|
||||||
*rect = item->rect;
|
*rect = item->rect;
|
||||||
|
|
||||||
|
OffsetRect(rect, menu->items_rect.left, menu->items_rect.top);
|
||||||
MapWindowPoints(hwnd, 0, (POINT *)rect, 2);
|
MapWindowPoints(hwnd, 0, (POINT *)rect, 2);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in New Issue