Commit 2bd0c872 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move GetMenuDefaultItem implementation from user32.

parent 4e39188c
......@@ -911,42 +911,9 @@ BOOL WINAPI SetMenuItemInfoW(HMENU hmenu, UINT item, BOOL bypos,
/**********************************************************************
* GetMenuDefaultItem (USER32.@)
*/
UINT WINAPI GetMenuDefaultItem(HMENU hmenu, UINT bypos, UINT flags)
UINT WINAPI GetMenuDefaultItem( HMENU menu, UINT bypos, UINT flags )
{
POPUPMENU *menu;
MENUITEM * item;
UINT i = 0;
TRACE("(%p,%d,%d)\n", hmenu, bypos, flags);
if (!(menu = MENU_GetMenu(hmenu))) return -1;
/* find default item */
item = menu->items;
/* empty menu */
if (! item) return -1;
while ( !( item->fState & MFS_DEFAULT ) )
{
i++; item++;
if (i >= menu->nItems ) return -1;
}
/* default: don't return disabled items */
if ( (!(GMDI_USEDISABLED & flags)) && (item->fState & MFS_DISABLED )) return -1;
/* search rekursiv when needed */
if ( (item->fType & MF_POPUP) && (flags & GMDI_GOINTOPOPUPS) )
{
UINT ret;
ret = GetMenuDefaultItem( item->hSubMenu, bypos, flags );
if ( -1 != ret ) return ret;
/* when item not found in submenu, return the popup item */
}
return ( bypos ) ? i : item->wID;
return NtUserThunkedMenuItemInfo( menu, bypos, flags, NtUserGetMenuDefaultItem, NULL, NULL );
}
......
......@@ -1170,6 +1170,45 @@ static HMENU get_sub_menu( HMENU handle, INT pos )
return submenu;
}
/* see GetMenuDefaultItem */
static UINT get_menu_default_item( HMENU handle, UINT bypos, UINT flags )
{
MENUITEM *item = NULL;
POPUPMENU *menu;
UINT i;
TRACE( "(%p,%d,%d)\n", handle, bypos, flags );
if (!(menu = grab_menu_ptr( handle ))) return -1;
for (i = 0; i < menu->nItems; i++)
{
if (!(menu->items[i].fState & MFS_DEFAULT)) continue;
item = &menu->items[i];
break;
}
/* default: don't return disabled items */
if (item && (!(GMDI_USEDISABLED & flags)) && (item->fState & MFS_DISABLED)) item = NULL;
/* search submenu when needed */
if (item && (item->fType & MF_POPUP) && (flags & GMDI_GOINTOPOPUPS))
{
UINT ret = get_menu_default_item( item->hSubMenu, bypos, flags );
if (ret != -1)
{
release_menu_ptr( menu );
return ret;
}
/* when item not found in submenu, return the popup item */
}
if (!item) i = -1;
else if (!bypos) i = item->wID;
release_menu_ptr( menu );
return i;
}
/**********************************************************************
* NtUserThunkedMenuItemInfo (win32u.@)
*/
......@@ -1185,6 +1224,9 @@ UINT WINAPI NtUserThunkedMenuItemInfo( HMENU handle, UINT pos, UINT flags, UINT
case NtUserCheckMenuRadioItem:
return check_menu_radio_item( handle, pos, info->cch, info->fMask, flags );
case NtUserGetMenuDefaultItem:
return get_menu_default_item( handle, pos, flags );
case NtUserGetMenuItemID:
if (!(menu = find_menu_item( handle, pos, flags, &i ))) return -1;
ret = menu->items[i].fType & MF_POPUP ? -1 : menu->items[i].wID;
......
......@@ -225,6 +225,7 @@ enum
NtUserInsertMenuItem,
/* Wine extensions */
NtUserCheckMenuRadioItem,
NtUserGetMenuDefaultItem,
NtUserGetMenuItemID,
NtUserGetMenuItemInfoA,
NtUserGetMenuItemInfoW,
......
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