Skip to content
Snippets Groups Projects
menu.c 53.2 KiB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
static char RCSId[] = "$Id$";
static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
Alexandre Julliard's avatar
Alexandre Julliard committed
static char Copyright2[] = "Copyright  Martin Ayotte, 1993";
Alexandre Julliard's avatar
Alexandre Julliard committed

Alexandre Julliard's avatar
Alexandre Julliard committed
/*
Alexandre Julliard's avatar
Alexandre Julliard committed
#define DEBUG_MENU
Alexandre Julliard's avatar
Alexandre Julliard committed
*/
#define USE_POPUPMENU
Alexandre Julliard's avatar
Alexandre Julliard committed

Alexandre Julliard's avatar
Alexandre Julliard committed
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/SmeLine.h>
#include <X11/Xaw/SimpleMenu.h>
#include "WinMenuButto.h"
#include "SmeMenuButto.h"
#include "windows.h"
#include "menu.h"
#include "heap.h"
#include "win.h"
#include "bitmaps/check_bitmap"
#include "bitmaps/nocheck_bitmap"

Alexandre Julliard's avatar
Alexandre Julliard committed
HBITMAP hStdCheck = 0;
HBITMAP hStdMnArrow = 0;

Alexandre Julliard's avatar
Alexandre Julliard committed
static LPMENUBAR firstMenu = NULL;
static MENUITEM *parentItem;
static MENUITEM *siblingItem;
static int       lastLevel;
static int       menuId = 0;
static Pixmap    checkBitmap = XtUnspecifiedPixmap;
static Pixmap    nocheckBitmap = XtUnspecifiedPixmap;
Alexandre Julliard's avatar
Alexandre Julliard committed

LPPOPUPMENU PopupMenuGetStorageHeader(HWND hwnd);
LPPOPUPMENU PopupMenuGetWindowAndStorage(HWND hwnd, WND **wndPtr);
Alexandre Julliard's avatar
Alexandre Julliard committed
void StdDrawMenuBar(HWND hwnd);
Alexandre Julliard's avatar
Alexandre Julliard committed
void StdDrawPopupMenu(HWND hwnd);
Alexandre Julliard's avatar
Alexandre Julliard committed
LPMENUITEM MenuFindItem(HWND hwnd, int x, int y, WORD *lpRet);
LPMENUITEM MenuFindItemBySelKey(HWND hwnd, WORD key, WORD *lpRet);
void PopupMenuCalcSize(HWND hwnd);
void MenuBarCalcSize(HWND hwnd);
Alexandre Julliard's avatar
Alexandre Julliard committed
LPMENUITEM GetMenuItemPtr(LPPOPUPMENU menu, WORD nPos);
Alexandre Julliard's avatar
Alexandre Julliard committed
WORD GetSelectionKey(LPSTR str);
LPSTR GetShortCutString(LPSTR str);
WORD GetShortCutPos(LPSTR str);
BOOL HideAllSubPopupMenu(LPPOPUPMENU menu);
WORD * ParseMenuResource(WORD *first_item, int level, HMENU hMenu);
void SetMenuLogicalParent(HMENU hMenu, HWND hWnd);
Alexandre Julliard's avatar
Alexandre Julliard committed

/***********************************************************************
 *           PopupMenuWndProc
 */
LONG PopupMenuWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
{    
    CREATESTRUCT *createStruct;
    WORD	wRet;
    short	x, y;
    WND  	*wndPtr;
Alexandre Julliard's avatar
Alexandre Julliard committed
    LPPOPUPMENU lppop, lppop2;
Alexandre Julliard's avatar
Alexandre Julliard committed
    LPMENUITEM	lpitem, lpitem2;
    HMENU	hSubMenu;
    RECT	rect;
    HDC		hDC;
    switch(message) 
    {
    case WM_CREATE:
#ifdef DEBUG_MENU
        printf("PopupMenu WM_CREATE lParam=%08X !\n", lParam);
#endif
	createStruct = (CREATESTRUCT *)lParam;
     	lppop = (LPPOPUPMENU)createStruct->lpCreateParams;
Alexandre Julliard's avatar
Alexandre Julliard committed
     	if (lppop == NULL) break;
Alexandre Julliard's avatar
Alexandre Julliard committed
	wndPtr = WIN_FindWndPtr(hwnd);
	*((LPPOPUPMENU *)&wndPtr->wExtra[1]) = lppop;
#ifdef DEBUG_MENU
        printf("PopupMenu WM_CREATE lppop=%08X !\n", lppop);
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
/*
	if (lppop->BarFlags == 0) {
	    PopupMenuCalcSize(hwnd);
	    printf("PopupMenu WM_CREATE Width=%d Height=%d !\n", 
			lppop->Width, lppop->Height);
	    SetWindowPos(hwnd, 0, 0, 0, lppop->Width + 2, lppop->Height, 
		SWP_NOZORDER | SWP_NOMOVE);
	    }
	else {
	    MenuBarCalcSize(hwnd);
	    SetWindowPos(hwnd, 0, 0, -16, lppop->Width, lppop->Height, 
		SWP_NOZORDER);
	    }
*/
	if (hStdCheck == (HBITMAP)NULL) 
	    hStdCheck = LoadBitmap((HANDLE)NULL, (LPSTR)OBM_CHECK);
	if (hStdMnArrow == (HBITMAP)NULL) 
	    hStdMnArrow = LoadBitmap((HANDLE)NULL, (LPSTR)OBM_MNARROW);
Alexandre Julliard's avatar
Alexandre Julliard committed
	return 0;
    case WM_DESTROY:
	lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
#ifdef DEBUG_MENU
        printf("PopupMenu WM_DESTROY %lX !\n", lppop);
#endif
	return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
    case WM_COMMAND:
	lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
#ifdef DEBUG_MENU
    	printf("PopupMenu // push to lower parent WM_COMMAND !\n");
#endif
	if (lppop->hWndParent != (HWND)NULL)
	    SendMessage(lppop->hWndParent, WM_COMMAND, wParam, lParam);
	else 
	    SendMessage(lppop->ownerWnd, WM_COMMAND, wParam, lParam);
	if (lppop->BarFlags == 0) ShowWindow(hwnd, SW_HIDE);
    	break;
    case WM_SHOWWINDOW:
	lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
    	if (wParam == 0) {
	    HideAllSubPopupMenu(lppop);
#ifdef DEBUG_MENU
    	printf("PopupMenu WM_SHOWWINDOW -> HIDE!\n");
#endif
	    break;
	    }
	lppop->FocusedItem = (WORD)-1;
	if (lppop->BarFlags == 0) {
	    PopupMenuCalcSize(hwnd);
#ifdef DEBUG_MENU
	    printf("PopupMenu WM_SHOWWINDOW Width=%d Height=%d !\n", 
			lppop->Width, lppop->Height);
#endif
	    SetWindowPos(hwnd, 0, 0, 0, lppop->Width + 2, lppop->Height, 
		SWP_NOZORDER | SWP_NOMOVE);
	    }
	else {
	    MenuBarCalcSize(hwnd);
#ifdef DEBUG_MENU
	    printf("MenuBarMenu WM_SHOWWINDOW Width=%d Height=%d !\n", 
			lppop->Width, lppop->Height);
#endif
	    SetWindowPos(hwnd, 0, 0, -16, lppop->Width, lppop->Height, 
		SWP_NOZORDER);
	    }
    	break;
Alexandre Julliard's avatar
Alexandre Julliard committed
    case WM_LBUTTONDOWN:
	lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
	SetCapture(hwnd);
Alexandre Julliard's avatar
Alexandre Julliard committed
	lpitem = MenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet);
#ifdef DEBUG_MENU
Alexandre Julliard's avatar
Alexandre Julliard committed
	printf("PopupMenu WM_LBUTTONDOWN wRet=%d lpitem=%08X !\n", wRet, lpitem);
Alexandre Julliard's avatar
Alexandre Julliard committed
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
	if (lpitem != NULL) {
Alexandre Julliard's avatar
Alexandre Julliard committed
	    if (lppop->FocusedItem != (WORD)-1) {
		HideAllSubPopupMenu(lppop);
		lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if (((lpitem2->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
		    ((lpitem2->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
	            hDC = GetDC(hwnd);
	            InvertRect(hDC, &lpitem2->rect);
		    ReleaseDC(hwnd, hDC);
		    }
		}
Alexandre Julliard's avatar
Alexandre Julliard committed
	    lppop->FocusedItem = wRet;
	    if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
		((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
	        hDC = GetDC(hwnd);
	        InvertRect(hDC, &lpitem->rect);
		ReleaseDC(hwnd, hDC);
		}
Alexandre Julliard's avatar
Alexandre Julliard committed
	    if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) {
		hSubMenu = (HMENU)lpitem->item_id;
		lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu);
		if (lppop2 == NULL) break;
		lppop2->hWndParent = hwnd;
		GetClientRect(hwnd, &rect);
		if (lppop->BarFlags != 0) {
		    y = rect.bottom - rect.top;
		    TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, 
			lpitem->rect.left, 0, 
			0, lppop->ownerWnd, (LPRECT)NULL);
		    }
		else {
		    x = rect.right;
		    GetWindowRect(hwnd, &rect);
		    x += rect.left;
		    TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, 
			x, lpitem->rect.top,
			0, lppop->ownerWnd, (LPRECT)NULL);
		    }
		break;
		}
Alexandre Julliard's avatar
Alexandre Julliard committed
	    }
	break;
    case WM_LBUTTONUP:
	lppop = PopupMenuGetStorageHeader(hwnd);
	ReleaseCapture();
Alexandre Julliard's avatar
Alexandre Julliard committed
	lpitem = MenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet);
#ifdef DEBUG_MENU
Alexandre Julliard's avatar
Alexandre Julliard committed
	printf("PopupMenu WM_LBUTTONUP wRet=%d lpitem=%08X !\n", wRet, lpitem);
Alexandre Julliard's avatar
Alexandre Julliard committed
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
	if (lpitem != NULL) {
	    if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) {
		break;
		}
	    if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
		((lpitem->item_flags & MF_POPUP) != MF_POPUP)) {
Alexandre Julliard's avatar
Alexandre Julliard committed
	    	ShowWindow(lppop->hWnd, SW_HIDE);
		if (lppop->hWndParent != (HWND)NULL)
		    SendMessage(lppop->hWndParent, WM_COMMAND, 
					lpitem->item_id, 0L);
		else 
		    SendMessage(lppop->ownerWnd, WM_COMMAND, 
					lpitem->item_id, 0L);
#ifdef DEBUG_MENU
Alexandre Julliard's avatar
Alexandre Julliard committed
		printf("PopupMenu // SendMessage WM_COMMAND wParam=%d !\n", 
			lpitem->item_id);
Alexandre Julliard's avatar
Alexandre Julliard committed
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
	    	break;
		}
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
	if (lppop->FocusedItem != (WORD)-1) {
	    HideAllSubPopupMenu(lppop);
	    lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem);
	    if (((lpitem2->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
		((lpitem2->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
	        hDC = GetDC(hwnd);
	        InvertRect(hDC, &lpitem2->rect);
		ReleaseDC(hwnd, hDC);
		}
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
	break;
    case WM_MOUSEMOVE:
        if ((wParam & MK_LBUTTON) != 0) {
	    lppop = PopupMenuGetStorageHeader(hwnd);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    lpitem = MenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    if ((lpitem != NULL) && (lppop->FocusedItem != wRet)) {
		lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem);
		hDC = GetDC(hwnd);
		if (((lpitem2->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem2->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem2->rect);
		    }
Alexandre Julliard's avatar
Alexandre Julliard committed
		if ((lpitem2->item_flags & MF_POPUP) == MF_POPUP) {
		    HideAllSubPopupMenu(lppop);
		    }
Alexandre Julliard's avatar
Alexandre Julliard committed
		lppop->FocusedItem = wRet;
Alexandre Julliard's avatar
Alexandre Julliard committed
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) {
		    hSubMenu = (HMENU)lpitem->item_id;
		    lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu);
		    if (lppop2 == NULL) break;
		    if (lppop->BarFlags != 0) {
			lppop2->hWndParent = hwnd;
			GetClientRect(hwnd, &rect);
			y = rect.bottom - rect.top;
			TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, 
				lpitem->rect.left, 0, 
				0, lppop->ownerWnd, (LPRECT)NULL);
			}
		    }
Alexandre Julliard's avatar
Alexandre Julliard committed
		ReleaseDC(hwnd, hDC);
		}
            }
	break;

    case WM_KEYDOWN:
    case WM_KEYUP:
Alexandre Julliard's avatar
Alexandre Julliard committed
	if (lParam < 0L) break;
	lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
	if (lppop->FocusedItem == (WORD)-1) {
	    if (wParam == VK_UP || wParam == VK_DOWN || 
		wParam == VK_LEFT || wParam == VK_RIGHT) {
		hDC = GetDC(hwnd);
		lppop->FocusedItem = 0;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		ReleaseDC(hwnd, hDC);
		}
	    break;
	    }
	switch(wParam) {
	    case VK_UP:
		if (lppop->BarFlags != 0) break;
		if (lppop->FocusedItem < 1) break;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if ((lpitem->item_flags & MF_POPUP) == MF_POPUP)
		    HideAllSubPopupMenu(lppop);
		hDC = GetDC(hwnd);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		lppop->FocusedItem--;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		ReleaseDC(hwnd, hDC);
		break;
	    case VK_DOWN:
		if (lppop->BarFlags != 0) goto ProceedSPACE;
		if (lppop->FocusedItem >= lppop->nItems - 1) break;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if ((lpitem->item_flags & MF_POPUP) == MF_POPUP)
		    HideAllSubPopupMenu(lppop);
		hDC = GetDC(hwnd);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		lppop->FocusedItem++;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		ReleaseDC(hwnd, hDC);
		break;
	    case VK_LEFT:
		if (lppop->BarFlags == 0) {
		    if (lppop->hWndParent != 0) 
			SendMessage(lppop->hWndParent, WM_KEYDOWN, wParam, lParam);
		    break;
		    }
		if (lppop->FocusedItem < 1) break;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if ((lpitem->item_flags & MF_POPUP) == MF_POPUP)
		    HideAllSubPopupMenu(lppop);
		hDC = GetDC(hwnd);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		lppop->FocusedItem--;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		ReleaseDC(hwnd, hDC);
		break;
	    case VK_RIGHT:
		if (lppop->BarFlags == 0) {
		    if (lppop->hWndParent != 0) 
			SendMessage(lppop->hWndParent, WM_KEYDOWN, wParam, lParam);
		    break;
		    }
		if (lppop->FocusedItem >= lppop->nItems - 1) break;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if ((lpitem->item_flags & MF_POPUP) == MF_POPUP)
		    HideAllSubPopupMenu(lppop);
		hDC = GetDC(hwnd);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		lppop->FocusedItem++;
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if (((lpitem->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem->rect);
		    }
		ReleaseDC(hwnd, hDC);
		break;
	    case VK_RETURN:
	    case VK_SPACE:
ProceedSPACE:
		printf("PopupMenu VK_SPACE !\n");
		lpitem = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) {
		    hSubMenu = (HMENU)lpitem->item_id;
		    lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu);
		    if (lppop2 == NULL) break;
		    lppop2->hWndParent = hwnd;
		    GetClientRect(hwnd, &rect);
		    if (lppop->BarFlags != 0) {
			y = rect.bottom - rect.top;
			TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, 
				lpitem->rect.left, 0, 
				0, lppop->ownerWnd, (LPRECT)NULL);
			}
		    else {
			x = rect.right;
			GetWindowRect(hwnd, &rect);
			x += rect.left;
			TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, 
				x, lpitem->rect.top,
				0, lppop->ownerWnd, (LPRECT)NULL);
			}
		    break;
		    }
		if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
		    ((lpitem->item_flags & MF_POPUP) != MF_POPUP)) {
		    ShowWindow(lppop->hWnd, SW_HIDE);
		    if (lppop->hWndParent != (HWND)NULL)
			SendMessage(lppop->hWndParent, WM_COMMAND, 
					lpitem->item_id, 0L);
		    else 
			SendMessage(lppop->ownerWnd, WM_COMMAND, 
					lpitem->item_id, 0L);
#ifdef DEBUG_MENU
		    printf("PopupMenu // SendMessage WM_COMMAND wParam=%d !\n", 
				lpitem->item_id);
#endif
		   }
		break;
	    }
	break;
Alexandre Julliard's avatar
Alexandre Julliard committed
    case WM_CHAR:
Alexandre Julliard's avatar
Alexandre Julliard committed
	if (lParam < 0L) break;
Alexandre Julliard's avatar
Alexandre Julliard committed
	lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
Alexandre Julliard's avatar
Alexandre Julliard committed
	if (wParam == VK_ESCAPE) {
	    if (lppop->hWndParent != 0) {
		lppop2 = PopupMenuGetWindowAndStorage(
			lppop->hWndParent, &wndPtr);
		HideAllSubPopupMenu(lppop2);
		break;
		}
	    if (lppop->FocusedItem != (WORD)-1) {
		lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem);
		hDC = GetDC(hwnd);
		if (((lpitem2->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem2->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem2->rect);
		    }
		ReleaseDC(hwnd, hDC);
		lppop->FocusedItem = (WORD)-1;
		}
	    }
	if (wParam >= 'a' && wParam <= 'z') wParam -= 'a' - 'A';
	lpitem = MenuFindItemBySelKey(hwnd, wParam, &wRet);
	if (lpitem != NULL) {
	    printf("Found  wRet=%d !\n", wRet);
	    if (lppop->FocusedItem != (WORD)-1) {
		lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem);
		if ((lpitem2->item_flags & MF_POPUP) == MF_POPUP)
		    HideAllSubPopupMenu(lppop);
		hDC = GetDC(hwnd);
		if (((lpitem2->item_flags & MF_POPUP) == MF_POPUP) ||
		    ((lpitem2->item_flags & MF_STRING) == MF_STRING)) {
		    InvertRect(hDC, &lpitem2->rect);
		    }
		ReleaseDC(hwnd, hDC);
		}
	    lppop->FocusedItem = wRet;
	    goto ProceedSPACE;
	    }
	break;
Alexandre Julliard's avatar
Alexandre Julliard committed
    case WM_PAINT:
Alexandre Julliard's avatar
Alexandre Julliard committed
	lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
	if (lppop->BarFlags != 0) {
	    MenuBarCalcSize(hwnd);
	    printf("PopupMenu WM_PAINT Width=%d Height=%d !\n", 
			lppop->Width, lppop->Height);
	    StdDrawMenuBar(hwnd);
	    }
	else{
	    PopupMenuCalcSize(hwnd);
	    StdDrawPopupMenu(hwnd);
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
	break;
    default:
	return DefWindowProc( hwnd, message, wParam, lParam );
    }
return(0);
}



LPPOPUPMENU PopupMenuGetWindowAndStorage(HWND hwnd, WND **wndPtr)
{
    WND  *Ptr;
    LPPOPUPMENU lppop;
    *(wndPtr) = Ptr = WIN_FindWndPtr(hwnd);
    if (Ptr == 0) {
    	printf("Bad Window handle on PopupMenu !\n");
    	return 0;
    	}
    lppop = *((LPPOPUPMENU *)&Ptr->wExtra[1]);
    return lppop;
}


LPPOPUPMENU PopupMenuGetStorageHeader(HWND hwnd)
{
    WND  *Ptr;
    LPPOPUPMENU lppop;
    Ptr = WIN_FindWndPtr(hwnd);
    if (Ptr == 0) {
    	printf("Bad Window handle on PopupMenu !\n");
    	return 0;
    	}
    lppop = *((LPPOPUPMENU *)&Ptr->wExtra[1]);
    return lppop;
}


Alexandre Julliard's avatar
Alexandre Julliard committed
void SetMenuLogicalParent(HMENU hMenu, HWND hWnd)
{
    LPPOPUPMENU lppop;
    lppop = (LPPOPUPMENU)GlobalLock(hMenu);
    lppop->hWndParent = hWnd;
}


Alexandre Julliard's avatar
Alexandre Julliard committed
void StdDrawPopupMenu(HWND hwnd)
{
    WND 	*wndPtr;
    LPPOPUPMENU lppop;
    LPMENUITEM 	lpitem;
    PAINTSTRUCT ps;
    HBRUSH 	hBrush;
    HPEN	hOldPen;
    HWND	hWndParent;
    HDC 	hDC, hMemDC;
    RECT 	rect, rect2, rect3;
Alexandre Julliard's avatar
Alexandre Julliard committed
    DWORD	OldTextColor;
    HFONT	hOldFont;
Alexandre Julliard's avatar
Alexandre Julliard committed
    HBITMAP	hBitMap;
    BITMAP	bm;
Alexandre Julliard's avatar
Alexandre Julliard committed
    UINT  	i, x;
Alexandre Julliard's avatar
Alexandre Julliard committed
    hDC = BeginPaint( hwnd, &ps );
    if (!IsWindowVisible(hwnd)) {
	EndPaint( hwnd, &ps );
	return;
	}
    lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
    if (lppop == NULL) goto EndOfPaint;
Alexandre Julliard's avatar
Alexandre Julliard committed
    hBrush = GetStockObject(WHITE_BRUSH);
Alexandre Julliard's avatar
Alexandre Julliard committed
    GetClientRect(hwnd, &rect);
    GetClientRect(hwnd, &rect2);
    FillRect(hDC, &rect, hBrush);
Alexandre Julliard's avatar
Alexandre Julliard committed
    FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
Alexandre Julliard's avatar
Alexandre Julliard committed
    if (lppop->nItems == 0) goto EndOfPaint;
Alexandre Julliard's avatar
Alexandre Julliard committed
    lpitem = lppop->firstItem;
Alexandre Julliard's avatar
Alexandre Julliard committed
    if (lpitem == NULL) goto EndOfPaint;
    for(i = 0; i < lppop->nItems; i++) {
	if ((lpitem->item_flags & MF_SEPARATOR) == MF_SEPARATOR) {
Alexandre Julliard's avatar
Alexandre Julliard committed
	    CopyRect(&rect2, &lpitem->rect);
    	    hOldPen = SelectObject(hDC, GetStockObject(BLACK_PEN));
Alexandre Julliard's avatar
Alexandre Julliard committed
	    MoveTo(hDC, rect2.left, rect2.top + 1);
	    LineTo(hDC, rect2.right, rect2.top + 1);
	    SelectObject(hDC, hOldPen);
	    }
	if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) {
Alexandre Julliard's avatar
Alexandre Julliard committed
	    hBitMap = (HBITMAP)LOWORD((LONG)lpitem->item_text);
	    CopyRect(&rect2, &lpitem->rect);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    hMemDC = CreateCompatibleDC(hDC);
	    SelectObject(hMemDC, hBitMap);
	    GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
	    BitBlt(hDC, rect2.left, rect2.top,
		bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
	    DeleteDC(hMemDC);
	    }
	if (((lpitem->item_flags & MF_BITMAP) != MF_BITMAP) &&
	    ((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
	    ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
Alexandre Julliard's avatar
Alexandre Julliard committed
	    hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT));
	    if ((lpitem->item_flags & MF_DISABLED) == MF_DISABLED)
		OldTextColor = SetTextColor(hDC, 0x00C0C0C0L);
	    else
		OldTextColor = SetTextColor(hDC, 0x00000000L);
	    CopyRect(&rect3, &lpitem->rect);
	    InflateRect(&rect3, 0, -2);
	    if ((x = GetShortCutPos(lpitem->item_text)) != (WORD)-1) {
		DrawText(hDC, lpitem->item_text, x, &rect3, 
		    DT_LEFT | DT_VCENTER | DT_SINGLELINE);
		DrawText(hDC, &lpitem->item_text[x], -1, &rect3, 
		    DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
		} 
	    else
		DrawText(hDC, lpitem->item_text, -1, &rect3, 
		    DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	    SetTextColor(hDC, OldTextColor);
	    SelectObject(hDC, hOldFont);
	    CopyRect(&rect2, &lpitem->rect);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    }
	if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) {
	    CopyRect(&rect3, &rect2);
	    rect3.left = rect3.right - rect3.bottom + rect3.top;
Alexandre Julliard's avatar
Alexandre Julliard committed
	    hMemDC = CreateCompatibleDC(hDC);
	    if (lpitem->hCheckBit == 0)
		SelectObject(hMemDC, hStdCheck);
	    else
		SelectObject(hMemDC, lpitem->hCheckBit);
	    GetObject(hStdCheck, sizeof(BITMAP), (LPSTR)&bm);
	    BitBlt(hDC, rect3.left, rect3.top,
		bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
	    DeleteDC(hMemDC);
	    printf("StdDrawPopupMenu // MF_CHECKED hStdCheck=%04X !\n", hStdCheck);
	    }
	else {
	    if (lpitem->hUnCheckBit != 0)
		SelectObject(hMemDC, lpitem->hUnCheckBit);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    }
	if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) {
	    CopyRect(&rect3, &rect2);
	    rect3.left = rect3.right - rect3.bottom + rect3.top;
Alexandre Julliard's avatar
Alexandre Julliard committed
	    hMemDC = CreateCompatibleDC(hDC);
	    SelectObject(hMemDC, hStdMnArrow);
	    GetObject(hStdMnArrow, sizeof(BITMAP), (LPSTR)&bm);
	    BitBlt(hDC, rect3.left, rect3.top,
		bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
	    DeleteDC(hMemDC);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    }
	if (lpitem->next == NULL) goto EndOfPaint;
	lpitem = (LPMENUITEM)lpitem->next;
    }
EndOfPaint:
    EndPaint( hwnd, &ps );
}



Alexandre Julliard's avatar
Alexandre Julliard committed
void StdDrawMenuBar(HWND hwnd)
Alexandre Julliard's avatar
Alexandre Julliard committed
{
    WND 	*wndPtr;
    LPPOPUPMENU lppop;
    LPMENUITEM 	lpitem;
Alexandre Julliard's avatar
Alexandre Julliard committed
    PAINTSTRUCT ps;
    HBRUSH 	hBrush;
    HPEN	hOldPen;
    HWND	hWndParent;
    HDC 	hDC, hMemDC;
    RECT 	rect, rect2, rect3;
    HFONT	hOldFont;
Alexandre Julliard's avatar
Alexandre Julliard committed
    HBITMAP	hBitMap;
    BITMAP	bm;
Alexandre Julliard's avatar
Alexandre Julliard committed
    UINT  	i, textwidth;
    hDC = BeginPaint( hwnd, &ps );
    if (!IsWindowVisible(hwnd)) {
	EndPaint( hwnd, &ps );
	return;
	}
    hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT));
Alexandre Julliard's avatar
Alexandre Julliard committed
    lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
Alexandre Julliard's avatar
Alexandre Julliard committed
    if (lppop == NULL) goto EndOfPaint;
    hBrush = GetStockObject(WHITE_BRUSH);
Alexandre Julliard's avatar
Alexandre Julliard committed
    GetClientRect(hwnd, &rect);
Alexandre Julliard's avatar
Alexandre Julliard committed
    FillRect(hDC, &rect, hBrush);
    FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
    if (lppop->nItems == 0) goto EndOfPaint;
    lpitem = lppop->firstItem;
    if (lpitem == NULL) goto EndOfPaint;
Alexandre Julliard's avatar
Alexandre Julliard committed
    for(i = 0; i < lppop->nItems; i++) {
	if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) {
Alexandre Julliard's avatar
Alexandre Julliard committed
	    hBitMap = (HBITMAP)LOWORD((LONG)lpitem->item_text);
	    CopyRect(&rect2, &lpitem->rect);
	    hMemDC = CreateCompatibleDC(hDC);
	    SelectObject(hMemDC, hBitMap);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    BitBlt(hDC, rect2.left, rect2.top,
		bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
	    DeleteDC(hMemDC);
Alexandre Julliard's avatar
Alexandre Julliard committed
	    }
	if (((lpitem->item_flags & MF_BITMAP) != MF_BITMAP) &&
	    ((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
	    ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
Alexandre Julliard's avatar
Alexandre Julliard committed
	    CopyRect(&rect2, &lpitem->rect);
	    DrawText(hDC, lpitem->item_text, -1, &rect2, 
	    	DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	    }
	if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) {
	    CopyRect(&rect3, &rect2);
	    rect3.left = rect3.right - rect3.bottom + rect3.top;
	    hMemDC = CreateCompatibleDC(hDC);
	    SelectObject(hMemDC, hStdCheck);
	    GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
	    BitBlt(hDC, rect3.left, rect3.top,
		bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
	    DeleteDC(hMemDC);
	    }
	if (lpitem->next == NULL) goto EndOfPaint;
	lpitem = (LPMENUITEM)lpitem->next;
    }
EndOfPaint:
    SelectObject(hDC, hOldFont);
    EndPaint( hwnd, &ps );
}



LPMENUITEM MenuFindItem(HWND hwnd, int x, int y, WORD *lpRet)
{
    WND 	*wndPtr;
    LPPOPUPMENU lppop;
    LPMENUITEM 	lpitem;
    UINT  	i;
    lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
    if (lppop == NULL) return NULL;
    if (lppop->nItems == 0) return NULL;
    lpitem = lppop->firstItem;
    for(i = 0; i < lppop->nItems; i++) {
	if (lpitem == NULL) return NULL;
#ifdef DEBUG_MENUFINDITEM
	printf("FindItem // left=%d top=%d right=%d bottom=%d\n",
		lpitem->rect.left, lpitem->rect.top, 
		lpitem->rect.right, lpitem->rect.bottom);
#endif
	if (x > lpitem->rect.left && x < lpitem->rect.right && 
	    y > lpitem->rect.top && y < lpitem->rect.bottom) {
	    if (lpRet != NULL) *lpRet = i;
	    return lpitem;
Alexandre Julliard's avatar
Alexandre Julliard committed
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
	lpitem = (LPMENUITEM)lpitem->next;
    }
    return NULL;
}


LPMENUITEM MenuFindItemBySelKey(HWND hwnd, WORD key, WORD *lpRet)
{
    WND 	*wndPtr;
    LPPOPUPMENU lppop;
    LPMENUITEM 	lpitem;
    UINT  	i;
    lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
    if (lppop == NULL) return NULL;
    if (lppop->nItems == 0) return NULL;
    lpitem = lppop->firstItem;
    for(i = 0; i < lppop->nItems; i++) {
	if (lpitem == NULL) return NULL;
#ifdef DEBUG_MENUFINDITEM
	printf("FindItemBySelKey // key=%d lpitem->sel_key=%d\n",
		key, lpitem->sel_key);
#endif
	if (key == lpitem->sel_key) {
Alexandre Julliard's avatar
Alexandre Julliard committed
	    if (lpRet != NULL) *lpRet = i;
	    return lpitem;
	    }
	lpitem = (LPMENUITEM)lpitem->next;
    }
    return NULL;
}


Alexandre Julliard's avatar
Alexandre Julliard committed
void PopupMenuCalcSize(HWND hwnd)
{
    WND 	*wndPtr;
    LPPOPUPMENU lppop;
    LPMENUITEM 	lpitem;
    HDC		hDC;
    RECT 	rect;
    HBITMAP	hBitMap;
    BITMAP	bm;
    HFONT	hOldFont;
    UINT  	i, OldWidth, TempWidth;
    DWORD	dwRet;
    lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
    if (lppop == NULL) return;
    if (lppop->nItems == 0) return;
    hDC = GetDC(hwnd);
    lppop->Width = 20;
    hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT));
CalcAGAIN:
    OldWidth = lppop->Width;
    SetRect(&rect, 1, 1, OldWidth, 0);
    lpitem = lppop->firstItem;
    for(i = 0; i < lppop->nItems; i++) {
	if (lpitem == NULL) break;
	rect.right = rect.left + lppop->Width;
	if ((lpitem->item_flags & MF_SEPARATOR) == MF_SEPARATOR) {
	    rect.bottom = rect.top + 3;
	    }
	if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) {
	    hBitMap = (HBITMAP)LOWORD((LONG)lpitem->item_text);
	    GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
	    rect.bottom = rect.top + bm.bmHeight;
	    lppop->Width = max(lppop->Width, bm.bmWidth);
	    }
	if (((lpitem->item_flags & MF_BITMAP) != MF_BITMAP) &&
	    ((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
	    ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
	    dwRet = GetTextExtent(hDC, (char *)lpitem->item_text, 
		strlen((char *)lpitem->item_text));
	    rect.bottom = rect.top + HIWORD(dwRet);
	    InflateRect(&rect, 0, 2);
	    TempWidth = LOWORD(dwRet);
	    if (GetShortCutPos(lpitem->item_text) != (WORD)-1)
	        TempWidth += 15;
	    lppop->Width = max(lppop->Width, TempWidth);
	    }
	CopyRect(&lpitem->rect, &rect);
	rect.top = rect.bottom;
	lpitem = (LPMENUITEM)lpitem->next;
	}
    if (OldWidth < lppop->Width) goto CalcAGAIN;
    lppop->Height = rect.bottom;
#ifdef DEBUG_MENUCALC
    printf("PopupMenuCalcSize w=%d h=%d !\n", 
    	lppop->Width, lppop->Height);
#endif
    SelectObject(hDC, hOldFont);
    ReleaseDC(0, hDC);
}



void MenuBarCalcSize(HWND hwnd)
{
    WND 	*wndPtr;
    LPPOPUPMENU lppop;
    LPMENUITEM 	lpitem;
    HDC		hDC;
    RECT 	rect;
    HBITMAP	hBitMap;
    BITMAP	bm;
    HFONT	hOldFont;
    UINT  	i, OldHeight;
    DWORD	dwRet;
    lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
    if (lppop == NULL) return;
    if (lppop->nItems == 0) return;
    hDC = GetDC(hwnd);
    hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT));
    lppop->Height = 10;
CalcAGAIN:
    OldHeight = lppop->Height;
    SetRect(&rect, 1, 1, 0, OldHeight);
    lpitem = lppop->firstItem;
    for(i = 0; i < lppop->nItems; i++) {
	if (lpitem == NULL) break;
	rect.bottom = rect.top + lppop->Height;
	if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) {
	    hBitMap = (HBITMAP)LOWORD((LONG)lpitem->item_text);
	    GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
	    rect.right = rect.left + bm.bmWidth;
	    lppop->Height = max(lppop->Height, bm.bmHeight);
	    }
	if (((lpitem->item_flags & MF_BITMAP) != MF_BITMAP) &&
	    ((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
	    ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
	    dwRet = GetTextExtent(hDC, (char *)lpitem->item_text, 
		strlen((char *)lpitem->item_text));
	    rect.right = rect.left + LOWORD(dwRet) + 10;
	    lppop->Height = max(lppop->Height, HIWORD(dwRet) + 10);
	    }
	CopyRect(&lpitem->rect, &rect);
	rect.left = rect.right;
	lpitem = (LPMENUITEM)lpitem->next;
	}
    if (OldHeight < lppop->Height) goto CalcAGAIN;
    lppop->Width = rect.right;
#ifdef DEBUG_MENUCALC
    printf("MenuBarCalcSize w=%d h=%d !\n", 
    	lppop->Width, lppop->Height);
#endif
    SelectObject(hDC, hOldFont);
    ReleaseDC(hwnd, hDC);
}


Alexandre Julliard's avatar
Alexandre Julliard committed

LPMENUITEM GetMenuItemPtr(LPPOPUPMENU menu, WORD nPos)
{
    LPMENUITEM 	lpitem;
    int		i;
    if (menu == NULL) return NULL;
    lpitem = menu->firstItem;
    for (i = 0; i < menu->nItems; i++) {
Alexandre Julliard's avatar
Alexandre Julliard committed
    	if (lpitem == NULL) return NULL;
Alexandre Julliard's avatar
Alexandre Julliard committed
    	if (i == nPos) return(lpitem);
Alexandre Julliard's avatar
Alexandre Julliard committed
    	lpitem = (LPMENUITEM)lpitem->next;
Alexandre Julliard's avatar
Alexandre Julliard committed
    	}
    return NULL;
}


Alexandre Julliard's avatar
Alexandre Julliard committed
WORD GetSelectionKey(LPSTR str)
{
    int		i;
    WORD	sel_key;
    for (i = 0; i < strlen(str); i++) {
	if (str[i] == '&' && str[i + 1] != '&') 
	    {
	    sel_key = str[i + 1];
	    if (sel_key >= 'a' && sel_key <= 'z') sel_key -= 'a' - 'A';
#ifdef DEBUG_MENU
	    printf("GetSelectionKey // %04X\n", sel_key);
#endif
	    return sel_key;
	    }
	}
#ifdef DEBUG_MENU
    printf("GetSelectionKey NULL \n");
#endif
    return 0;
}



LPSTR GetShortCutString(LPSTR str)
{
    int		i;
    LPSTR	str2;
    for (i = 0; i < strlen(str); i++) {
	if (str[i] == '\t' && str[i + 1] != '\t') 
	    {
	    str2 = &str[i + 1];
#ifdef DEBUG_MENU
	    printf("GetShortCutString // '%s' \n", str2);
#endif
	    return str2;
	    }
	}
#ifdef DEBUG_MENU
    printf("GetShortCutString NULL \n");
#endif
    return NULL;
}



WORD GetShortCutPos(LPSTR str)
{
    int		i;
    for (i = 0; i < strlen(str); i++) {
	if (str[i] == '\t' && str[i + 1] != '\t') 
	    {
#ifdef DEBUG_MENU
	    printf("GetShortCutPos = %d \n", i);
#endif
	    return i;
	    }
	}
#ifdef DEBUG_MENU
    printf("GetShortCutString NULL \n");
#endif
    return -1;
}



BOOL HideAllSubPopupMenu(LPPOPUPMENU menu)
{
    LPPOPUPMENU submenu;
    LPMENUITEM 	lpitem;
    BOOL	someClosed = FALSE;
    int		i;
    if (menu == NULL) return;
    lpitem = menu->firstItem;
    for (i = 0; i < menu->nItems; i++) {
    	if (lpitem == NULL) return;
    	if (lpitem->item_flags & MF_POPUP) {
	    submenu = (LPPOPUPMENU) GlobalLock((HMENU)lpitem->item_id);
	    if (submenu != NULL) {
		if (IsWindowVisible(submenu->hWnd)) {
		    ShowWindow(submenu->hWnd, SW_HIDE);
		    someClosed = TRUE;
		    }
	    	}
    	    }
    	lpitem = (LPMENUITEM)lpitem->next;
    	}
    return someClosed;
}


#ifdef USE_XTMENU

Alexandre Julliard's avatar
Alexandre Julliard committed
/**********************************************************************
 *					MENU_CheckWidget
 */
void
MENU_CheckWidget(Widget w, Boolean check)
{
    if (checkBitmap == XtUnspecifiedPixmap)
    {
	Display *display = XtDisplayOfObject(w);
	    
	checkBitmap = XCreateBitmapFromData(display,
					    DefaultRootWindow(display),
					    check_bitmap_bits,
					    check_bitmap_width,
					    check_bitmap_height);
	nocheckBitmap = XCreateBitmapFromData(display,
					    DefaultRootWindow(display),
					    nocheck_bitmap_bits,
					    nocheck_bitmap_width,
					    nocheck_bitmap_height);
    }
	    
    if (check)
	XtVaSetValues(w, XtNleftBitmap, checkBitmap, NULL);
    else
	XtVaSetValues(w, XtNleftBitmap, nocheckBitmap, NULL);
}

/**********************************************************************
 *					MENU_ParseMenu
 */
WORD *
MENU_ParseMenu(WORD *first_item, 
	       int level,