removed MENUITEMINFOW struct from MENU_ITEM

svn path=/trunk/; revision=5646
This commit is contained in:
Thomas Bluemel 2003-08-18 11:58:17 +00:00
parent f56db0bd84
commit b2b074bf8c
2 changed files with 102 additions and 87 deletions

View file

@ -17,11 +17,20 @@
#ifndef MIIM_STRING
#define MIIM_STRING (0x00000040)
#endif
typedef struct _MENU_ITEM
{
struct _MENU_ITEM *Next;
MENUITEMINFOW MenuItem;
UINT fType;
UINT fState;
UINT wID;
HMENU hSubMenu;
HBITMAP hbmpChecked;
HBITMAP hbmpUnchecked;
ULONG_PTR dwItemData;
LPWSTR dwTypeData;
UINT cch;
HBITMAP hbmpItem;
} MENU_ITEM, *PMENU_ITEM;
typedef struct _MENU_OBJECT

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: menu.c,v 1.14 2003/08/11 21:10:49 royce Exp $
/* $Id: menu.c,v 1.15 2003/08/18 11:58:17 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -79,12 +79,11 @@
#define FreeMenuText(MenuItem) \
{ \
if(((MenuItem).fMask & (MIIM_TYPE | MIIM_STRING)) && \
(MENU_ITEM_TYPE((MenuItem).fType) == MF_STRING) && \
(MenuItem).dwTypeData) { \
ExFreePool((MenuItem).dwTypeData); \
(MenuItem).dwTypeData = 0; \
(MenuItem).cch = 0; \
if((MENU_ITEM_TYPE((MenuItem)->fType) == MF_STRING) && \
(MenuItem)->dwTypeData) { \
ExFreePool((MenuItem)->dwTypeData); \
(MenuItem)->dwTypeData = 0; \
(MenuItem)->cch = 0; \
DbgPrint("FreeMenuText(): Deleted menu text\n"); \
} \
}
@ -108,29 +107,29 @@ DumpMenuItemList(PMENU_ITEM MenuItem)
UINT cnt = 0;
while(MenuItem)
{
if(MenuItem->MenuItem.dwTypeData)
DbgPrint(" %d. %ws\n", ++cnt, (LPWSTR)MenuItem->MenuItem.dwTypeData);
if(MenuItem->dwTypeData)
DbgPrint(" %d. %ws\n", ++cnt, (LPWSTR)MenuItem->dwTypeData);
else
DbgPrint(" %d. NO TEXT dwTypeData==%d\n", ++cnt, MenuItem->MenuItem.dwTypeData);
DbgPrint(" %d. NO TEXT dwTypeData==%d\n", ++cnt, MenuItem->dwTypeData);
DbgPrint(" fType=");
if(MFT_BITMAP & MenuItem->MenuItem.fType) DbgPrint("MFT_BITMAP ");
if(MFT_MENUBARBREAK & MenuItem->MenuItem.fType) DbgPrint("MFT_MENUBARBREAK ");
if(MFT_MENUBREAK & MenuItem->MenuItem.fType) DbgPrint("MFT_MENUBREAK ");
if(MFT_OWNERDRAW & MenuItem->MenuItem.fType) DbgPrint("MFT_OWNERDRAW ");
if(MFT_RADIOCHECK & MenuItem->MenuItem.fType) DbgPrint("MFT_RADIOCHECK ");
if(MFT_RIGHTJUSTIFY & MenuItem->MenuItem.fType) DbgPrint("MFT_RIGHTJUSTIFY ");
if(MFT_SEPARATOR & MenuItem->MenuItem.fType) DbgPrint("MFT_SEPARATOR ");
if(MFT_STRING & MenuItem->MenuItem.fType) DbgPrint("MFT_STRING ");
if(MFT_BITMAP & MenuItem->fType) DbgPrint("MFT_BITMAP ");
if(MFT_MENUBARBREAK & MenuItem->fType) DbgPrint("MFT_MENUBARBREAK ");
if(MFT_MENUBREAK & MenuItem->fType) DbgPrint("MFT_MENUBREAK ");
if(MFT_OWNERDRAW & MenuItem->fType) DbgPrint("MFT_OWNERDRAW ");
if(MFT_RADIOCHECK & MenuItem->fType) DbgPrint("MFT_RADIOCHECK ");
if(MFT_RIGHTJUSTIFY & MenuItem->fType) DbgPrint("MFT_RIGHTJUSTIFY ");
if(MFT_SEPARATOR & MenuItem->fType) DbgPrint("MFT_SEPARATOR ");
if(MFT_STRING & MenuItem->fType) DbgPrint("MFT_STRING ");
DbgPrint("\n fState=");
if(MFS_DISABLED & MenuItem->MenuItem.fState) DbgPrint("MFS_DISABLED ");
if(MFS_DISABLED & MenuItem->fState) DbgPrint("MFS_DISABLED ");
else DbgPrint("MFS_ENABLED ");
if(MFS_CHECKED & MenuItem->MenuItem.fState) DbgPrint("MFS_CHECKED ");
if(MFS_CHECKED & MenuItem->fState) DbgPrint("MFS_CHECKED ");
else DbgPrint("MFS_UNCHECKED ");
if(MFS_HILITE & MenuItem->MenuItem.fState) DbgPrint("MFS_HILITE ");
if(MFS_HILITE & MenuItem->fState) DbgPrint("MFS_HILITE ");
else DbgPrint("MFS_UNHILITE ");
if(MFS_DEFAULT & MenuItem->MenuItem.fState) DbgPrint("MFS_DEFAULT ");
if(MFS_GRAYED & MenuItem->MenuItem.fState) DbgPrint("MFS_GRAYED ");
DbgPrint("\n wId=%d\n", MenuItem->MenuItem.wID);
if(MFS_DEFAULT & MenuItem->fState) DbgPrint("MFS_DEFAULT ");
if(MFS_GRAYED & MenuItem->fState) DbgPrint("MFS_GRAYED ");
DbgPrint("\n wId=%d\n", MenuItem->wID);
MenuItem = MenuItem->Next;
}
DbgPrint("Entries: %d\n", cnt);
@ -162,17 +161,17 @@ BOOL FASTCALL
W32kFreeMenuItem(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem,
BOOL RemoveFromList, BOOL bRecurse)
{
FreeMenuText(MenuItem->MenuItem);
FreeMenuText(MenuItem);
if(RemoveFromList)
{
/* FIXME - Remove from List */
MenuObject->MenuItemCount--;
}
if(bRecurse && MenuItem->MenuItem.hSubMenu)
if(bRecurse && MenuItem->hSubMenu)
{
PMENU_OBJECT SubMenuObject;
SubMenuObject = (PMENU_OBJECT)W32kGetWindowObject(
MenuItem->MenuItem.hSubMenu );
MenuItem->hSubMenu );
if(SubMenuObject)
{
W32kDestroyMenuObject(SubMenuObject, bRecurse);
@ -376,7 +375,7 @@ W32kGetMenuItemByFlag(PMENU_OBJECT MenuObject, UINT uSearchBy, UINT fFlag,
p = 0;
while(CurItem)
{
if(CurItem->MenuItem.wID == uSearchBy)
if(CurItem->wID == uSearchBy)
{
if(MenuItem) *MenuItem = CurItem;
if(PrevMenuItem) *PrevMenuItem = PrevItem;
@ -462,64 +461,64 @@ W32kSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, LPCMENUITEMINF
return FALSE;
}
if((MenuItem->MenuItem.fMask & (MIIM_TYPE | MIIM_STRING)) &&
(MENU_ITEM_TYPE(MenuItem->MenuItem.fType) == MF_STRING) &&
MenuItem->MenuItem.dwTypeData)
/*if((MenuItem->fMask & (MIIM_TYPE | MIIM_STRING)) &&
(MENU_ITEM_TYPE(MenuItem->fType) == MF_STRING) &&
MenuItem->dwTypeData)
{
/* delete old string */
ExFreePool(MenuItem->MenuItem.dwTypeData);
MenuItem->MenuItem.dwTypeData = 0;
MenuItem->MenuItem.cch = 0;
}
// delete old string
ExFreePool(MenuItem->dwTypeData);
MenuItem->dwTypeData = 0;
MenuItem->cch = 0;
}*/
MenuItem->MenuItem.fType = lpmii->fType;
MenuItem->MenuItem.cch = lpmii->cch;
MenuItem->fType = lpmii->fType;
MenuItem->cch = lpmii->cch;
if(lpmii->fMask & MIIM_BITMAP)
{
MenuItem->MenuItem.hbmpItem = lpmii->hbmpItem;
MenuItem->hbmpItem = lpmii->hbmpItem;
}
if(lpmii->fMask & MIIM_CHECKMARKS)
{
MenuItem->MenuItem.hbmpChecked = lpmii->hbmpChecked;
MenuItem->MenuItem.hbmpUnchecked = lpmii->hbmpUnchecked;
MenuItem->hbmpChecked = lpmii->hbmpChecked;
MenuItem->hbmpUnchecked = lpmii->hbmpUnchecked;
}
if(lpmii->fMask & MIIM_DATA)
{
MenuItem->MenuItem.dwItemData = lpmii->dwItemData;
MenuItem->dwItemData = lpmii->dwItemData;
}
if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
{
MenuItem->MenuItem.fType = lpmii->fType;
MenuItem->fType = lpmii->fType;
}
if(lpmii->fMask & MIIM_ID)
{
MenuItem->MenuItem.wID = lpmii->wID;
MenuItem->wID = lpmii->wID;
}
if(lpmii->fMask & MIIM_STATE)
{
UpdateMenuItemState(MenuItem->MenuItem.fState, lpmii->fState);
UpdateMenuItemState(MenuItem->fState, lpmii->fState);
/* FIXME - only one item can have MFS_DEFAULT */
}
if(lpmii->fMask & MIIM_SUBMENU)
{
MenuItem->MenuItem.hSubMenu = lpmii->hSubMenu;
MenuItem->hSubMenu = lpmii->hSubMenu;
}
if((lpmii->fMask & (MIIM_TYPE | MIIM_STRING)) &&
(MENU_ITEM_TYPE(lpmii->fType) == MF_STRING) && lpmii->dwTypeData)
{
FreeMenuText(MenuItem->MenuItem);
MenuItem->MenuItem.dwTypeData = (LPWSTR)ExAllocatePool(PagedPool, (lpmii->cch + 1) * sizeof(WCHAR));
if(!MenuItem->MenuItem.dwTypeData)
FreeMenuText(MenuItem);
MenuItem->dwTypeData = (LPWSTR)ExAllocatePool(PagedPool, (lpmii->cch + 1) * sizeof(WCHAR));
if(!MenuItem->dwTypeData)
{
MenuItem->MenuItem.cch = 0;
MenuItem->cch = 0;
/* FIXME Set last error code? */
SetLastWin32Error(STATUS_NO_MEMORY);
return FALSE;
}
MenuItem->MenuItem.cch = lpmii->cch;
memcpy(MenuItem->MenuItem.dwTypeData, lpmii->dwTypeData, (lpmii->cch + 1) * sizeof(WCHAR));
MenuItem->cch = lpmii->cch;
memcpy(MenuItem->dwTypeData, lpmii->dwTypeData, (lpmii->cch + 1) * sizeof(WCHAR));
}
return TRUE;
@ -559,8 +558,15 @@ W32kInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, WINBOOL fByPosition,
return FALSE;
}
RtlZeroMemory(&MenuItem->MenuItem, sizeof(MENUITEMINFOW));
MenuItem->MenuItem.cbSize = sizeof(MENUITEMINFOW);
MenuItem->fType = MFT_STRING;
MenuItem->fState = MFS_ENABLED | MFS_UNCHECKED;
MenuItem->wID = 0;
MenuItem->hSubMenu = (HMENU)0;
MenuItem->hbmpChecked = (HBITMAP)0;
MenuItem->hbmpUnchecked = (HBITMAP)0;
MenuItem->dwItemData = (ULONG_PTR)NULL;
MenuItem->cch = 0;
MenuItem->hbmpItem = (HBITMAP)0;
if(!W32kSetMenuItemInfo(MenuObject, MenuItem, lpmii))
{
@ -583,33 +589,33 @@ W32kEnableMenuItem(PMENU_OBJECT MenuObject, UINT uIDEnableItem, UINT uEnable)
return (UINT)-1;
}
res = MenuItem->MenuItem.fState & (MF_GRAYED | MF_DISABLED);
res = MenuItem->fState & (MF_GRAYED | MF_DISABLED);
if(uEnable & MF_DISABLED)
{
if(!(MenuItem->MenuItem.fState & MF_DISABLED))
MenuItem->MenuItem.fState |= MF_DISABLED;
if(!(MenuItem->fState & MF_DISABLED))
MenuItem->fState |= MF_DISABLED;
if(uEnable & MF_GRAYED)
{
if(!(MenuItem->MenuItem.fState & MF_GRAYED))
MenuItem->MenuItem.fState |= MF_GRAYED;
if(!(MenuItem->fState & MF_GRAYED))
MenuItem->fState |= MF_GRAYED;
}
}
else
{
if(uEnable & MF_GRAYED)
{
if(!(MenuItem->MenuItem.fState & MF_GRAYED))
MenuItem->MenuItem.fState |= MF_GRAYED;
if(!(MenuItem->MenuItem.fState & MF_DISABLED))
MenuItem->MenuItem.fState |= MF_DISABLED;
if(!(MenuItem->fState & MF_GRAYED))
MenuItem->fState |= MF_GRAYED;
if(!(MenuItem->fState & MF_DISABLED))
MenuItem->fState |= MF_DISABLED;
}
else
{
if(MenuItem->MenuItem.fState & MF_DISABLED)
MenuItem->MenuItem.fState ^= MF_DISABLED;
if(MenuItem->MenuItem.fState & MF_GRAYED)
MenuItem->MenuItem.fState ^= MF_GRAYED;
if(MenuItem->fState & MF_DISABLED)
MenuItem->fState ^= MF_DISABLED;
if(MenuItem->fState & MF_GRAYED)
MenuItem->fState ^= MF_GRAYED;
}
}
@ -644,16 +650,16 @@ W32kCheckMenuItem(PMENU_OBJECT MenuObject, UINT uIDCheckItem, UINT uCheck)
return -1;
}
res = (DWORD)(MenuItem->MenuItem.fState & MF_CHECKED);
res = (DWORD)(MenuItem->fState & MF_CHECKED);
if(uCheck & MF_CHECKED)
{
if(!(MenuItem->MenuItem.fState & MF_CHECKED))
MenuItem->MenuItem.fState |= MF_CHECKED;
if(!(MenuItem->fState & MF_CHECKED))
MenuItem->fState |= MF_CHECKED;
}
else
{
if(MenuItem->MenuItem.fState & MF_CHECKED)
MenuItem->MenuItem.fState ^= MF_CHECKED;
if(MenuItem->fState & MF_CHECKED)
MenuItem->fState ^= MF_CHECKED;
}
return (DWORD)res;
@ -672,13 +678,13 @@ W32kHiliteMenuItem(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject,
if(uHilite & MF_HILITE)
{
if(!(MenuItem->MenuItem.fState & MF_HILITE))
MenuItem->MenuItem.fState |= MF_HILITE;
if(!(MenuItem->fState & MF_HILITE))
MenuItem->fState |= MF_HILITE;
}
else
{
if(MenuItem->MenuItem.fState & MF_HILITE)
MenuItem->MenuItem.fState ^= MF_HILITE;
if(MenuItem->fState & MF_HILITE)
MenuItem->fState ^= MF_HILITE;
}
/* FIXME - update the window's menu */
@ -698,14 +704,14 @@ W32kSetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT uItem, UINT fByPos)
{
if(pos == uItem)
{
if(!(MenuItem->MenuItem.fState & MFS_DEFAULT))
MenuItem->MenuItem.fState |= MFS_DEFAULT;
if(!(MenuItem->fState & MFS_DEFAULT))
MenuItem->fState |= MFS_DEFAULT;
ret = TRUE;
}
else
{
if(MenuItem->MenuItem.fState & MFS_DEFAULT)
MenuItem->MenuItem.fState ^= MFS_DEFAULT;
if(MenuItem->fState & MFS_DEFAULT)
MenuItem->fState ^= MFS_DEFAULT;
}
pos++;
MenuItem = MenuItem->Next;
@ -715,16 +721,16 @@ W32kSetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT uItem, UINT fByPos)
{
while(MenuItem)
{
if(!ret && (MenuItem->MenuItem.wID == uItem))
if(!ret && (MenuItem->wID == uItem))
{
if(!(MenuItem->MenuItem.fState & MFS_DEFAULT))
MenuItem->MenuItem.fState |= MFS_DEFAULT;
if(!(MenuItem->fState & MFS_DEFAULT))
MenuItem->fState |= MFS_DEFAULT;
ret = TRUE;
}
else
{
if(MenuItem->MenuItem.fState & MFS_DEFAULT)
MenuItem->MenuItem.fState ^= MFS_DEFAULT;
if(MenuItem->fState & MFS_DEFAULT)
MenuItem->fState ^= MFS_DEFAULT;
}
MenuItem = MenuItem->Next;
}