Author: jmorlan
Date: Fri Aug 1 12:40:56 2008
New Revision: 35015
URL:
http://svn.reactos.org/svn/reactos?rev=35015&view=rev
Log:
- IntRemoveMenuItem: Fix bug involving deleting item from submenu. (Bug 3292)
- IntFreeMenuItem: Remove code for removing item from list - the only caller that
"used" this was IntRemoveMenuItem, which actually removes the item itself.
- IntInsertMenuItemToList, IntEnableMenuItem, IntCheckMenuItem, IntHiliteMenuItem:
Simplify some more redundant code.
Modified:
trunk/reactos/subsystems/win32/win32k/include/menu.h
trunk/reactos/subsystems/win32/win32k/ntuser/menu.c
Modified: trunk/reactos/subsystems/win32/win32k/include/menu.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/menu.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/menu.h [iso-8859-1] Fri Aug 1 12:40:56
2008
@@ -50,8 +50,7 @@
UserDereferenceObject(MenuObj)
BOOL FASTCALL
-IntFreeMenuItem(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem,
- BOOL RemoveFromList, BOOL bRecurse);
+IntFreeMenuItem(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, BOOL bRecurse);
BOOL FASTCALL
IntRemoveMenuItem(PMENU_OBJECT MenuObject, UINT uPosition, UINT uFlags,
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/menu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/menu.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/menu.c [iso-8859-1] Fri Aug 1 12:40:56
2008
@@ -206,27 +206,9 @@
}
BOOL FASTCALL
-IntFreeMenuItem(PMENU_OBJECT Menu, PMENU_ITEM MenuItem,
- BOOL RemoveFromList, BOOL bRecurse)
+IntFreeMenuItem(PMENU_OBJECT Menu, PMENU_ITEM MenuItem, BOOL bRecurse)
{
FreeMenuText(MenuItem);
- if(RemoveFromList)
- {
- PMENU_ITEM CurItem = Menu->MenuItemList;
- while(CurItem)
- {
- if (CurItem->Next == MenuItem)
- {
- CurItem->Next = MenuItem->Next;
- break;
- }
- else
- {
- CurItem = CurItem->Next;
- }
- }
- Menu->MenuInfo.MenuItemCount--;
- }
if(bRecurse && MenuItem->hSubMenu)
{
PMENU_OBJECT SubMenu;
@@ -249,7 +231,7 @@
BOOL bRecurse)
{
PMENU_ITEM PrevMenuItem, MenuItem;
- if(IntGetMenuItemByFlag(Menu, uPosition, uFlags, NULL, &MenuItem,
+ if(IntGetMenuItemByFlag(Menu, uPosition, uFlags, &Menu, &MenuItem,
&PrevMenuItem) > -1)
{
if(MenuItem)
@@ -260,7 +242,8 @@
{
Menu->MenuItemList = MenuItem->Next;
}
- return IntFreeMenuItem(Menu, MenuItem, TRUE, bRecurse);
+ Menu->MenuInfo.MenuItemCount--;
+ return IntFreeMenuItem(Menu, MenuItem, bRecurse);
}
}
return FALSE;
@@ -275,7 +258,7 @@
while(CurItem)
{
NextItem = CurItem->Next;
- IntFreeMenuItem(Menu, CurItem, FALSE, bRecurse);
+ IntFreeMenuItem(Menu, CurItem, bRecurse);
CurItem = NextItem;
res++;
}
@@ -651,56 +634,25 @@
UINT npos = 0;
CurItem = Menu->MenuItemList;
- if(pos <= -1)
- {
- while(CurItem)
- {
- LastItem = CurItem;
- CurItem = CurItem->Next;
- npos++;
- }
+ while(CurItem && (pos != 0))
+ {
+ LastItem = CurItem;
+ CurItem = CurItem->Next;
+ pos--;
+ npos++;
+ }
+
+ if(LastItem)
+ {
+ /* insert the item after LastItem */
+ LastItem->Next = MenuItem;
}
else
{
- while(CurItem && (pos > 0))
- {
- LastItem = CurItem;
- CurItem = CurItem->Next;
- pos--;
- npos++;
- }
- }
-
- if(CurItem)
- {
- if(LastItem)
- {
- /* insert the item before CurItem */
- MenuItem->Next = LastItem->Next;
- LastItem->Next = MenuItem;
- }
- else
- {
- /* insert at the beginning */
- Menu->MenuItemList = MenuItem;
- MenuItem->Next = CurItem;
- }
- }
- else
- {
- if(LastItem)
- {
- /* append item */
- LastItem->Next = MenuItem;
- MenuItem->Next = NULL;
- }
- else
- {
- /* insert first item */
- Menu->MenuItemList = MenuItem;
- MenuItem->Next = NULL;
- }
- }
+ /* insert at the beginning */
+ Menu->MenuItemList = MenuItem;
+ }
+ MenuItem->Next = CurItem;
Menu->MenuInfo.MenuItemCount++;
return npos;
@@ -1011,29 +963,18 @@
if(uEnable & MF_DISABLED)
{
- if(!(MenuItem->fState & MF_DISABLED))
- MenuItem->fState |= MF_DISABLED;
+ MenuItem->fState |= MF_DISABLED;
+ MenuItem->fState |= uEnable & MF_GRAYED;
+ }
+ else
+ {
if(uEnable & MF_GRAYED)
{
- if(!(MenuItem->fState & MF_GRAYED))
- MenuItem->fState |= MF_GRAYED;
- }
- }
- else
- {
- if(uEnable & MF_GRAYED)
- {
- if(!(MenuItem->fState & MF_GRAYED))
- MenuItem->fState |= MF_GRAYED;
- if(!(MenuItem->fState & MF_DISABLED))
- MenuItem->fState |= MF_DISABLED;
+ MenuItem->fState |= (MF_GRAYED | MF_DISABLED);
}
else
{
- if(MenuItem->fState & MF_DISABLED)
- MenuItem->fState ^= MF_DISABLED;
- if(MenuItem->fState & MF_GRAYED)
- MenuItem->fState ^= MF_GRAYED;
+ MenuItem->fState &= ~(MF_DISABLED | MF_GRAYED);
}
}
@@ -1155,13 +1096,11 @@
res = (DWORD)(MenuItem->fState & MF_CHECKED);
if(uCheck & MF_CHECKED)
{
- if(!(MenuItem->fState & MF_CHECKED))
- MenuItem->fState |= MF_CHECKED;
+ MenuItem->fState |= MF_CHECKED;
}
else
{
- if(MenuItem->fState & MF_CHECKED)
- MenuItem->fState ^= MF_CHECKED;
+ MenuItem->fState &= ~MF_CHECKED;
}
return (DWORD)res;
@@ -1180,13 +1119,11 @@
if(uHilite & MF_HILITE)
{
- if(!(MenuItem->fState & MF_HILITE))
- MenuItem->fState |= MF_HILITE;
+ MenuItem->fState |= MF_HILITE;
}
else
{
- if(MenuItem->fState & MF_HILITE)
- MenuItem->fState ^= MF_HILITE;
+ MenuItem->fState &= ~MF_HILITE;
}
/* FIXME - update the window's menu */
@@ -1204,8 +1141,7 @@
{
while(MenuItem)
{
- if(MenuItem->fState & MFS_DEFAULT)
- MenuItem->fState ^= MFS_DEFAULT;
+ MenuItem->fState &= ~MFS_DEFAULT;
MenuItem = MenuItem->Next;
}
return TRUE;
@@ -1218,14 +1154,12 @@
{
if(pos == uItem)
{
- if(!(MenuItem->fState & MFS_DEFAULT))
- MenuItem->fState |= MFS_DEFAULT;
+ MenuItem->fState |= MFS_DEFAULT;
ret = TRUE;
}
else
{
- if(MenuItem->fState & MFS_DEFAULT)
- MenuItem->fState ^= MFS_DEFAULT;
+ MenuItem->fState &= ~MFS_DEFAULT;
}
pos++;
MenuItem = MenuItem->Next;
@@ -1237,14 +1171,12 @@
{
if(!ret && (MenuItem->wID == uItem))
{
- if(!(MenuItem->fState & MFS_DEFAULT))
- MenuItem->fState |= MFS_DEFAULT;
+ MenuItem->fState |= MFS_DEFAULT;
ret = TRUE;
}
else
{
- if(MenuItem->fState & MFS_DEFAULT)
- MenuItem->fState ^= MFS_DEFAULT;
+ MenuItem->fState &= ~MFS_DEFAULT;
}
MenuItem = MenuItem->Next;
}