Commit 5c6a1f77 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Add support for right-to-left menus.

parent 3f026caf
...@@ -727,7 +727,8 @@ static MENUITEM *MENU_FindItemByCoords( const POPUPMENU *menu, ...@@ -727,7 +727,8 @@ static MENUITEM *MENU_FindItemByCoords( const POPUPMENU *menu,
RECT rect; RECT rect;
if (!GetWindowRect(menu->hWnd, &rect)) return NULL; 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; pt.y -= rect.top;
item = menu->items; item = menu->items;
for (i = 0; i < menu->nItems; i++, item++) for (i = 0; i < menu->nItems; i++, item++)
...@@ -1834,6 +1835,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags, ...@@ -1834,6 +1835,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
POINT pt; POINT pt;
HMONITOR monitor; HMONITOR monitor;
MONITORINFO info; 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", 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); hwndOwner, hmenu, id, x, y, xanchor, yanchor);
...@@ -1863,6 +1865,12 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags, ...@@ -1863,6 +1865,12 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
info.cbSize = sizeof(info); info.cbSize = sizeof(info);
GetMonitorInfoW( monitor, &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_RIGHTALIGN ) x -= width;
if( flags & TPM_CENTERALIGN ) x -= width / 2; if( flags & TPM_CENTERALIGN ) x -= width / 2;
...@@ -1890,7 +1898,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags, ...@@ -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; if( y < info.rcWork.top ) y = info.rcWork.top;
/* NOTE: In Windows, top menu popup is not owned. */ /* 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, WS_POPUP, x, y, width, height,
hwndOwner, 0, (HINSTANCE)GetWindowLongPtrW(hwndOwner, GWLP_HINSTANCE), hwndOwner, 0, (HINSTANCE)GetWindowLongPtrW(hwndOwner, GWLP_HINSTANCE),
(LPVOID)hmenu ); (LPVOID)hmenu );
...@@ -2339,6 +2347,7 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu, ...@@ -2339,6 +2347,7 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
GetClassLongW( menu->hWnd, GCL_STYLE)); GetClassLongW( menu->hWnd, GCL_STYLE));
NC_GetSysPopupPos( menu->hWnd, &rect ); NC_GetSysPopupPos( menu->hWnd, &rect );
if (wFlags & TPM_LAYOUTRTL) rect.left = rect.right;
rect.top = rect.bottom; rect.top = rect.bottom;
rect.right = GetSystemMetrics(SM_CXSIZE); rect.right = GetSystemMetrics(SM_CXSIZE);
rect.bottom = GetSystemMetrics(SM_CYSIZE); rect.bottom = GetSystemMetrics(SM_CYSIZE);
...@@ -2354,7 +2363,10 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu, ...@@ -2354,7 +2363,10 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
/* 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 */
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.top += rc.top - MENU_TOP_MARGIN;
rect.right = rc.left - rc.right + GetSystemMetrics(SM_CXBORDER); rect.right = rc.left - rc.right + GetSystemMetrics(SM_CXBORDER);
rect.bottom = rc.top - rc.bottom - MENU_TOP_MARGIN rect.bottom = rc.top - rc.bottom - MENU_TOP_MARGIN
...@@ -2362,14 +2374,17 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu, ...@@ -2362,14 +2374,17 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
} }
else 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.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;
} }
} }
MENU_ShowPopup( hwndOwner, item->hSubMenu, menu->FocusedItem, 0, MENU_ShowPopup( hwndOwner, item->hSubMenu, menu->FocusedItem, wFlags,
rect.left, rect.top, rect.right, rect.bottom ); rect.left, rect.top, rect.right, rect.bottom );
if (selectFirst) if (selectFirst)
MENU_MoveSelection( hwndOwner, item->hSubMenu, ITEM_NEXT ); MENU_MoveSelection( hwndOwner, item->hSubMenu, ITEM_NEXT );
...@@ -3319,6 +3334,7 @@ void MENU_TrackMouseMenuBar( HWND hWnd, INT ht, POINT pt ) ...@@ -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)); 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)) if (IsMenu(hMenu))
{ {
MENU_InitTracking( hWnd, hMenu, FALSE, wFlags ); MENU_InitTracking( hWnd, hMenu, FALSE, wFlags );
...@@ -3356,6 +3372,7 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar) ...@@ -3356,6 +3372,7 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar)
uItem = 0; uItem = 0;
wParam |= HTSYSMENU; /* prevent item lookup */ wParam |= HTSYSMENU; /* prevent item lookup */
} }
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
if (!IsMenu( hTrackMenu )) return; if (!IsMenu( hTrackMenu )) return;
......
...@@ -1185,9 +1185,10 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect ) ...@@ -1185,9 +1185,10 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
DWORD style = GetWindowLongW( hwnd, GWL_STYLE ); DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE ); 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->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1; rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
MapWindowPoints( hwnd, 0, (POINT *)rect, 2 );
} }
} }
......
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