mirror of
https://github.com/reactos/wine.git
synced 2025-02-13 16:59:37 +00:00
user32: Add support for right-to-left menus.
This commit is contained in:
parent
3f026cafa5
commit
5c6a1f776a
@ -727,7 +727,8 @@ static MENUITEM *MENU_FindItemByCoords( const POPUPMENU *menu,
|
||||
RECT rect;
|
||||
|
||||
if (!GetWindowRect(menu->hWnd, &rect)) return NULL;
|
||||
pt.x -= rect.left;
|
||||
if (GetWindowLongW( menu->hWnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) pt.x = rect.right - 1 - pt.x;
|
||||
else pt.x -= rect.left;
|
||||
pt.y -= rect.top;
|
||||
item = menu->items;
|
||||
for (i = 0; i < menu->nItems; i++, item++)
|
||||
@ -1834,6 +1835,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
|
||||
POINT pt;
|
||||
HMONITOR monitor;
|
||||
MONITORINFO info;
|
||||
DWORD ex_style = 0;
|
||||
|
||||
TRACE("owner=%p hmenu=%p id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n",
|
||||
hwndOwner, hmenu, id, x, y, xanchor, yanchor);
|
||||
@ -1863,6 +1865,12 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
|
||||
info.cbSize = sizeof(info);
|
||||
GetMonitorInfoW( monitor, &info );
|
||||
|
||||
if (flags & TPM_LAYOUTRTL)
|
||||
{
|
||||
ex_style = WS_EX_LAYOUTRTL;
|
||||
flags ^= TPM_RIGHTALIGN;
|
||||
}
|
||||
|
||||
if( flags & TPM_RIGHTALIGN ) x -= width;
|
||||
if( flags & TPM_CENTERALIGN ) x -= width / 2;
|
||||
|
||||
@ -1890,7 +1898,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
|
||||
if( y < info.rcWork.top ) y = info.rcWork.top;
|
||||
|
||||
/* NOTE: In Windows, top menu popup is not owned. */
|
||||
menu->hWnd = CreateWindowExW( 0, (LPCWSTR)POPUPMENU_CLASS_ATOM, NULL,
|
||||
menu->hWnd = CreateWindowExW( ex_style, (LPCWSTR)POPUPMENU_CLASS_ATOM, NULL,
|
||||
WS_POPUP, x, y, width, height,
|
||||
hwndOwner, 0, (HINSTANCE)GetWindowLongPtrW(hwndOwner, GWLP_HINSTANCE),
|
||||
(LPVOID)hmenu );
|
||||
@ -2339,6 +2347,7 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
|
||||
GetClassLongW( menu->hWnd, GCL_STYLE));
|
||||
|
||||
NC_GetSysPopupPos( menu->hWnd, &rect );
|
||||
if (wFlags & TPM_LAYOUTRTL) rect.left = rect.right;
|
||||
rect.top = rect.bottom;
|
||||
rect.right = GetSystemMetrics(SM_CXSIZE);
|
||||
rect.bottom = GetSystemMetrics(SM_CYSIZE);
|
||||
@ -2354,7 +2363,10 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
|
||||
|
||||
/* The first item in the popup menu has to be at the
|
||||
same y position as the focused menu item */
|
||||
rect.left += rc.right - GetSystemMetrics(SM_CXBORDER);
|
||||
if (wFlags & TPM_LAYOUTRTL)
|
||||
rect.left += GetSystemMetrics(SM_CXBORDER);
|
||||
else
|
||||
rect.left += rc.right - GetSystemMetrics(SM_CXBORDER);
|
||||
rect.top += rc.top - MENU_TOP_MARGIN;
|
||||
rect.right = rc.left - rc.right + GetSystemMetrics(SM_CXBORDER);
|
||||
rect.bottom = rc.top - rc.bottom - MENU_TOP_MARGIN
|
||||
@ -2362,14 +2374,17 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.left += item->rect.left;
|
||||
if (wFlags & TPM_LAYOUTRTL)
|
||||
rect.left = rect.right - item->rect.left;
|
||||
else
|
||||
rect.left += item->rect.left;
|
||||
rect.top += item->rect.bottom;
|
||||
rect.right = item->rect.right - item->rect.left;
|
||||
rect.bottom = item->rect.bottom - item->rect.top;
|
||||
}
|
||||
}
|
||||
|
||||
MENU_ShowPopup( hwndOwner, item->hSubMenu, menu->FocusedItem, 0,
|
||||
MENU_ShowPopup( hwndOwner, item->hSubMenu, menu->FocusedItem, wFlags,
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (selectFirst)
|
||||
MENU_MoveSelection( hwndOwner, item->hSubMenu, ITEM_NEXT );
|
||||
@ -3319,6 +3334,7 @@ void MENU_TrackMouseMenuBar( HWND hWnd, INT ht, POINT pt )
|
||||
|
||||
TRACE("wnd=%p ht=0x%04x %s\n", hWnd, ht, wine_dbgstr_point( &pt));
|
||||
|
||||
if (GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
|
||||
if (IsMenu(hMenu))
|
||||
{
|
||||
MENU_InitTracking( hWnd, hMenu, FALSE, wFlags );
|
||||
@ -3356,6 +3372,7 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar)
|
||||
uItem = 0;
|
||||
wParam |= HTSYSMENU; /* prevent item lookup */
|
||||
}
|
||||
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
|
||||
|
||||
if (!IsMenu( hTrackMenu )) return;
|
||||
|
||||
|
@ -1185,9 +1185,10 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
|
||||
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
|
||||
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
|
||||
|
||||
NC_GetInsideRect( hwnd, COORDS_SCREEN, rect, style, ex_style );
|
||||
NC_GetInsideRect( hwnd, COORDS_CLIENT, rect, style, ex_style );
|
||||
rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
|
||||
rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
|
||||
MapWindowPoints( hwnd, 0, (POINT *)rect, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user