/* @(#)Z 1.30 com/src/ui/Popup.cpp, odui, od96nt, odnt9712d 97/03/21 17:12:58 (96/10/23 15:18:27) */
//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odui
//
//   CLASSES: none
//
//   ORIGINS: 82,27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//
//  This file was generated by the SOM Compiler and Emitter Framework.
//  Generated using:
//      SOM Emitter emitxtm: 2.41
/*
     File:    popup.cpp

     Contains:  Class definition for ODPopup


     Copyright:  (c) 1994 by IBM Corp., all rights reserved.

     Change History (most recent first):

   Date      Body  Defect  Reason
   --------  ----  ------  -----------------------------------------------
   07/30/96   law   24258  Port to AIX
   07/02/96   brr   23672  Add override for InitMenuBarEx
			   Take out all references to saved_hWindow
			   Take out dead code at bottom #if 0 out
   06/25/96   brr   23492  Use GetWindowSystemData for OS/2 now supported
   06/19/96   brr   23331  Change tempobj.h to TempObj.h
   06/06/96   brr   22794  Take out use of GetWindowSystemData for OS/2 - not
			   supported yet on OS/2 platform
   06/05/96   brr   22722  Use GetWindowSystemData to get handle to resource
   05/14/96   brr          Added IsValid method
   05/08/96   brr   21758  Delete the following API's because not used:
			   SetNothingAvaulable
			   SetShowFrameOutline
			   CheckMenuBarID
			   AppendOLEMenuToODMenuBar
			   InitSelectedMenuBar
			   CopySelectedMenu
			   AddSelectedMenu
			   RestoreSelectedMenu
			   AddSelectedToAccelTable
			   AddSelAccels
   04/24/96   brr   21392  Take out references to VIEW_SHOWFRAMEOUTLINE
   04/24/96   brr   21374  Add subMenuIDarray on InitMenuBar
   04/19/96   brr   21263  Changes for InitMenuBar now passing menuID also
   04/19/96   brr          Get rid of EDIT_SIZE and EDIT_MOVE - not in
			   resource
   04/05/96   brr   20861  Changed _PLATFORM_WIN32 to _PLATFORM_WIN32_
   03/12/96   brr   20452  Added support for WIN32

       <19>   11/11/95 st   143420  use cmddefs.xh not odmenuid.h
       <18>    9/13/95 BLG 135340/135341  add support for prompt line to
					   popups
       <17>    8/12/95 st  132823  All items go above HELP menu item
       <16>    8/11/95 st  130322  let folks gray out popup menu items
       <15>    7/07/95 st  128305  fix regression additembefore/last
       <14>    6/20/95 st  125708  remove menuID param from
				    AddDefaultMenuItemXXX
       <13>    6/18/95 st  125705  fix regression from 124992
       <12>    6/18/95 st  125706  fix regression from 124992
       <11>    6/16/95 st  125296  restoreselectedmenu should return void
       <10>    6/10/95 st  124992  fix to AddMenuItemLast/Before
	<9>    6/03/95 st  124076  return length of string for
				    GetMenuItemText
	<8>    6/03/95 st  124076  add checking to AddSelectedMenu
	<7>    5/26/95 st  123260   addmenuitemlast fix for selected cascade
	<6>    5/26/95 st  123264   fix for adddefaultitem(before/last)
	<5>    5/22/95 st  123058   fixed popups re: selected menu
	<4>    5/18/95 st  122556   fix adddefaultitem(before/last)
	<3>    5/18/95 st  122565   popup traps when released
	<2>    5/15/95 ST  122322   added accelerator override methods
	<1>    3/25/95 ST           coded under new design
*/

#ifndef SOM_Module_popup_Source
#define SOM_Module_popup_Source
#endif
#define ODPopup_Class_Source

#define VARIABLE_MACROS

#include "Popup.xih"

#include <ODSessn.xh>
#include <Window.xh>
#include <WinStat.xh>

#include <ODUtils.h>
#include <odres.h>

#ifdef _PLATFORM_OS2_
#include <MenuAdO.xh>
#endif // PLATFORM_OS2

#ifdef _PLATFORM_WIN32_
#include <OrdColl.h>
#include <MenuAdW.xh>
#endif // PLATFORM_WIN32

#ifdef _PLATFORM_AIX_
#include <MenuAdX.xh>
#include <ODMessag.h>
#include <ODDebug.h>
#endif // PLATFORM_AIX_

#ifdef _PLATFORM_AIX_
string ODPopupGetMenuStringFromID(ODPopup* somSelf,
				  Environment* ev,
				  ODMenuItemID ulStringID);
#endif

//=====================================================================================
// COMMON METHODS FOR ALL PLATFORMS
//=====================================================================================

//-------------------------------------------------------------------------------------
// AddDefaultMenuItemBefore
//-------------------------------------------------------------------------------------
// Description: This method adds one of the predefined OpenDoc menu items
//		to the popup menu.
//
// Parameters: menuItemID - a predefined OpenDoc menu ID, such as EDIT_CUT
//             beforeID   - the menu item before which the new item
//			    is to be inserted.
//
// Return Value: kODTrue  - Successful completion
//               kODFalse - An error occurred
//
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupAddDefaultMenuItemBefore(ODPopup *somSelf, 
							      Environment *ev, 
							     ODMenuItemID menuItemID, 
							     ODMenuItemID beforeID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddDefaultMenuItemBefore");

    ODBoolean bResult = kODFalse;

    try {

	ODPlatformMenuItem mi;

    #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) 
	mi.iPosition   = 0;
	mi.afStyle     = 0;
	mi.afAttribute = 0;
	mi.id	       = menuItemID;
	mi.hwndSubMenu = NULL;
	mi.hItem       = NULL;
    #endif // PLATFORM_OS2, PLATFORM_WIN32

    #ifdef _PLATFORM_OS2_
	mi.afStyle = MIS_TEXT;
    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	mi.afStyle = MF_STRING;
    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	mi.id   = menuItemID;
	mi.text = kODNULL;
    #endif // PLATFORM_AIX_

	// Look up the string resource ID corresponding to the menu item ID.
	// -----------------------------------------------------------------
	ODULong ulStringID = somSelf->RetrieveMenuStringID(ev, menuItemID);

	if (ulStringID == -1)
	    THROW(kODErrUndefined);

	// If the string resource ID is valid, add a blank item to the popup menu.
	// -----------------------------------------------------------------------
	bResult = somSelf->AddMenuItemBefore(ev, ID_BASEPOPUP, menuItemID,
						 &mi, beforeID);

	if (! bResult)
	    THROW(kODErrUndefined);

	// If item added successfully, then get the string resource
	// and set the text for the newly added menu item.
	// -----------------------------------------------------------------------

	const ODULong MAX_STR_LEN = 256;
	char menuString[MAX_STR_LEN];

    #ifdef _PLATFORM_OS2_
	WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP),
			(HMODULE)_fHMOD, (ULONG)ulStringID,
			(LONG)MAX_STR_LEN,
			(PCSZ)menuString);
    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	LoadString((HMODULE)_fHMOD, ulStringID, menuString, MAX_STR_LEN);
    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	string theString = ODPopupGetMenuStringFromID(somSelf, ev, menuItemID);
        strcpy(menuString, theString);
    #endif // PLATFORM_AIX

	bResult = somSelf->SetMenuItemText(ev,  ID_BASEPOPUP, menuItemID,
						menuString);
    }
    catch (ODException _exception)
    {
	SetErrorCode(kODNoError);
	bResult = kODFalse;
    }

    return (bResult);

} /* end AddDefaultMenuItemBefore */

//-------------------------------------------------------------------------------------
// AddDefaultMenuItemLast
//-------------------------------------------------------------------------------------
// Description: This method adds one of the predefined OpenDoc menu items
//		to the end of the popup menu.
//
// Parameters: menuItemID - a predefined OpenDoc menu ID, such as EDIT_CUT
//
// Return Value: kODTrue  - Successful completion
//               kODFalse - An error occurred
//
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupAddDefaultMenuItemLast(ODPopup *somSelf, 
							    Environment *ev, 
							   ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddDefaultMenuItemLast");

    ODBoolean bResult = kODFalse;

    try {

	ODPlatformMenuItem mi;

    #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) 
	mi.iPosition   = 0;
	mi.afStyle     = 0;
	mi.afAttribute = 0;
	mi.id	       = menuItemID;
	mi.hwndSubMenu = NULL;
	mi.hItem       = NULL;
    #endif // PLATFORM_OS2, PLATFORM_WIN32

    #ifdef _PLATFORM_OS2_
	mi.afStyle = MIS_TEXT;
    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	mi.afStyle = MF_STRING;
    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	mi.id   = menuItemID;
	mi.text = kODNULL;
    #endif // PLATFORM_AIX_

	// Look up the string resource ID corresponding to the menu item ID.
	// -----------------------------------------------------------------
	ODULong ulStringID = somSelf->RetrieveMenuStringID(ev, menuItemID);

	if (ulStringID == -1)
	    THROW(kODErrUndefined);

	// If the string resource ID is valid, add a blank item to the popup menu.
	// -----------------------------------------------------------------------
	bResult = somSelf->AddMenuItemLast(ev, ID_BASEPOPUP, menuItemID, &mi);

	if (! bResult)
	    THROW(kODErrUndefined);

	// If item added successfully, then get the string resource
	// and set the text for the newly added menu item.
	// -----------------------------------------------------------------------

	const ODULong MAX_STR_LEN = 256;
	char menuString[MAX_STR_LEN];

    #ifdef _PLATFORM_OS2_
	WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP),
			(HMODULE)_fHMOD, (ULONG)ulStringID,
			(LONG)MAX_STR_LEN,
			(PCSZ)menuString);
    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	LoadString((HMODULE)_fHMOD, ulStringID, menuString, MAX_STR_LEN);
    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	string s = ODPopupGetMenuStringFromID(somSelf, ev, menuItemID);
        strcpy(menuString, s);
    #endif // PLATFORM_AIX

	bResult = somSelf->SetMenuItemText(ev, ID_BASEPOPUP, menuItemID,
							     menuString);
    }
    catch (ODException _exception)
    {
	SetErrorCode(kODNoError);
	bResult = kODFalse;
    }

    return (bResult);

} /* end AddDefaultMenuItemLast */

//-------------------------------------------------------------------------------------
// RetrieveMenuStringID [PRIVATE]
//-------------------------------------------------------------------------------------
// Description: Get the ID of the string resource that corresponds
//		to the menu item id passed in.
//
// Parameters: menuItemID - a predefined OpenDoc menu ID, such as EDIT_CUT
//
// Return Value: ID of a resource file string that matches the menu item ID
//
SOM_Scope ODULong  SOMLINK ODPopupRetrieveMenuStringID(ODPopup *somSelf, 
							Environment *ev, 
							ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupRetrieveMenuStringID");

    ODULong ulStringID = 0;

    switch (menuItemID) {

	case IDMS_DOCUMENT:
		ulStringID = IDS_DOCUMENT;	break;
	
	case DOC_NEW:
		ulStringID = IDS_DOCNEW;	break;
	
	case DOC_OPENAS:
		ulStringID = IDS_DOCOPENAS;	break;
	
	case DOC_INSERT:
		ulStringID = IDS_INSERT;	break;
	
	case DOC_SAVE:
		ulStringID = IDS_DOCSAVE;	break;
	
	case DOC_SAVECOPY:
		ulStringID = IDS_SAVECOPY;	break;
	
	case DOC_REVERTTOSAVED:
		ulStringID = IDS_REVERTTOSAVED;	break;
	
	case DOC_DRAFTS:
		ulStringID = IDS_DRAFTS;	break;
	
	case DOC_DRAFTCREATE:
		ulStringID = IDS_DRAFTCREATE;	break;
	
	case DOC_DRAFTHISTORY:
		ulStringID = IDS_DRAFTHISTORY;	break;
	
	case DOC_PROPERTIES:
		ulStringID = IDS_DOCPROPERTIES;	break;
	
	case DOC_SETUP:
		ulStringID = IDS_SETUP;		break;
	
	case DOC_PRINT:
		ulStringID = IDS_DOCPRINT;	break;
	
	case DOC_CLOSE:
		ulStringID = IDS_CLOSE;		break;
	
	case IDMS_EDIT:
		ulStringID = IDS_EDIT;		break;
	
	case EDIT_UNDO:
		ulStringID = IDS_UNDO;		break;
	
	case EDIT_REDO:
		ulStringID = IDS_REDO;		break;
	
	case EDIT_CREATE:
		ulStringID = IDS_CREATE;	break;
	
	case EDIT_CUT:
		ulStringID = IDS_CUT;		break;
	
	case EDIT_COPY:
		ulStringID = IDS_COPY;		break;
	
	case EDIT_PASTE:
		ulStringID = IDS_PASTE;		break;
	
	case EDIT_PASTEAS:
		ulStringID = IDS_PASTEAS;	break;
	
	case EDIT_LINK_MENU:
		ulStringID = IDS_LINK;		break;
	
	case EDIT_PASTELINK:
		ulStringID = IDS_PASTELINK;	break;
	
	case EDIT_BREAKLINK:
		ulStringID = IDS_BREAKLINK;	break;
	
	case EDIT_COPYLINKTO:
		ulStringID = IDS_COPYLINKTO;	break;
	
	case EDIT_PASTELINKFROM:
		ulStringID = IDS_PASTELINKFROM;	break;
	
	case EDIT_DELETE:
		ulStringID = IDS_DELETE;	break;
	
	case EDIT_SELECTALL:
		ulStringID = IDS_SELECTALL;	break;
	
	case EDIT_DESELECTALL:
		ulStringID = IDS_DESELECTALL;	break;
	
	case EDIT_OPENSEL:
		ulStringID = IDS_OPENSEL;	break;
	
	case EDIT_SELPROPERTIES:
		ulStringID = IDS_SELPROPERTIES;	break;
	
	case IDMS_HELP:
		ulStringID = IDS_HELP;		break;
	
	case HELP_INDEX_OD:
		ulStringID = IDS_HELPINDEX;	break;
	
	case HELP_GENERAL:
		ulStringID = IDS_HELPGENERAL;	break;
	
	case HELP_USING:
		ulStringID = IDS_HELPUSING;	break;
	
	case HELP_PRODUCTINFO:
		ulStringID = IDS_PRODUCTINFO;	break;
	
	default:
		ulStringID = -1L;		break;
    }

   return (ulStringID);

} /* end RetrieveMenuItemString */

//-------------------------------------------------------------------------------------
// InitPopup [PRIVATE]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupInitPopup(ODPopup *somSelf,
					  Environment *ev, 
					 ODSession* session, 
					 ODPlatformMenuBar popup)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupInitPopup");

    #ifdef _PLATFORM_WIN32_
	somSelf->InitPopupEx(ev, session, popup, 0, kODNULL);
	return;
    #endif // PLATFORM_WIN32

    try {

	somSelf->InitRefCntObject(ev);

	_fSession   = session;
	_fBasePopup = popup;

	#ifdef _PLATFORM_AIX_
	    if (popup)
	    {
		ODX11MenuAdapter* popupAd = (ODX11MenuAdapter*) popup;
		_fMenu = popupAd->Copy(ev);
	    }
	    else
	    {
		_fMenu = new ODX11MenuAdapter;
		_fMenu->Init(ev, ID_BASEPOPUP, _fSession);
	    }
	#endif // PLATFORM_AIX

	#ifdef _PLATFORM_OS2_

	    _fMenu = new ODOS2MenuAdapter;
	    _fMenu->Init(ev, ID_BASEPOPUP, kODNULL);
	    _fMenu->AddItemsFromPlatMenu(ev, (ODPlatformMenu)popup);
	    _fMenu->GetPlatMenu(ev, &(_fPlatPopup));

	    WindowSystemData* winSysData = kODNULL;

	    if (_fSession)
		winSysData = _fSession->GetWindowSystemData(ev);

	    if (winSysData)
		_fHMOD = (void*) winSysData->resInstance;

	#endif // PLATFORM_OS2

    }
    catch (ODException _exception)
    {
	SetErrorCode(kODNoError);
    }

} /* end InitPopup */

#ifdef _PLATFORM_WIN32_
//=====================================================================================
// WINDOWS-ONLY METHODS
//=====================================================================================
//-------------------------------------------------------------------------------------
// InitPopupEx [PRIVATE] [Windows only]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupInitPopupEx(ODPopup *somSelf,
					    Environment *ev, 
					   ODSession* session, 
					   ODPlatformMenuBar popup,
					   ODUShort      subMenuIDcount,
					   ODMenuIDInfo *subMenuIDinfo)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupInitPopupEx");

    try {

	somSelf->InitRefCntObject(ev);

	_fSession   = session;
	_fBasePopup = popup;

	_fMenu = new ODWinMenuAdapter;
	_fMenu->Init(ev, ID_BASEPOPUP, NULL);
	_fMenu->AddItemsFromPlatMenuEx(ev, (ODPlatformMenu) popup,
					   subMenuIDcount,
					   subMenuIDinfo);

	_fMenu->GetPlatMenu(ev, &(_fPlatPopup));

	WindowSystemData* winSysData = kODNULL;

	if (_fSession)
	    winSysData = _fSession->GetWindowSystemData(ev);

	if (winSysData)
	    _fHMOD = winSysData->resInstance;

    }
    catch (ODException _exception)
    {
	SetErrorCode(kODNoError);
    }

} /* end InitPopupEx */

#endif // PLATFORM_WIN32

//=====================================================================================
// OVERRIDDEN METHODS FOR ALL PLATFORMS
//=====================================================================================

//-------------------------------------------------------------------------------------
// somInit [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupsomInit(ODPopup *somSelf)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupsomInit");

    ODPopup_parent_ODMenuBar_somInit(somSelf);

    #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) 
	_fHMOD = kODNULL;
    #endif // PLATFORM_OS2, PLATFORM_WIN32

} /* end SomInit */

//-------------------------------------------------------------------------------------
// somUninit [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupsomUninit(ODPopup *somSelf)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupsomUninit");

    Environment *ev = somGetGlobalEnvironment();

    // warn window state if we are the current popup menu.
    // ---------------------------------------------------

    ODWindowState* winStat = kODNULL;
    ODPopup*       current = kODNULL;

    if (_fSession)
	winStat = _fSession->GetWindowState(ev);

    if (winStat)
	current = winStat->AcquireCurrentPopupMenu(ev);

    if (current == somSelf)
	winStat->SetCurrentPopUpMenu(ev,kODNULL);

    if (current)
	current->Release(ev);

    ODPopup_parent_ODMenuBar_somUninit(somSelf);

} /* end somUninit */

//-------------------------------------------------------------------------------------
// Display [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupDisplay(ODPopup *somSelf,  Environment *ev)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupDisplay");

    try {

	// Get the handle to the frame
	// ---------------------------
	ODWindowState* winStat = kODNULL;
	ODWindow*      window  = kODNULL;

	if (_fSession)
	    winStat = _fSession->GetWindowState(ev);

	if (winStat)
	    window = winStat->AcquireActiveWindow(ev);

	THROW_IF_NULL(window, kODErrUndefined);

	HWND hwndFrame = window->GetPlatformWindow(ev);

	window->Release(ev);

	// Get the coordinates of where the mouse was last clicked
	// -------------------------------------------------------

	#ifdef _PLATFORM_OS2_
	    POINTL    ptl;
	    WinQueryMsgPos(WinQueryAnchorBlock(HWND_DESKTOP), &ptl);
	#endif // PLATFORM_OS2

	#ifdef _PLATFORM_WIN32_
	    ODULong p   = GetMessagePos();
	    POINTS  ptl = MAKEPOINTS(p);
	#endif // PLATFORM_WIN32

	#ifdef _PLATFORM_AIX_
	    Widget mainWinWidget    = window->GetMainWindowWidget(ev);

	    Display* xdisp = XtDisplay(mainWinWidget);
	    Window   xwin  = XtWindow (mainWinWidget);
	    Window root_win;
	    Window child_win;
	    int root_x;
	    int root_y;
	    int win_x;
	    int win_y;
	    unsigned int keys_buttons;

	    XQueryPointer(xdisp, xwin, &root_win, &child_win,
				    &root_x, &root_y, &win_x, &win_y,
				    &keys_buttons);
	#endif // PLATFORM_AIX

	// Create a new popup menu at the mouse coordinates
	// ------------------------------------------------

	#ifdef _PLATFORM_OS2_

	    // try to copy style info from hwndFrame's menu...
	    // ---------------------------------------------------
	    HWND frameMenu = WinWindowFromID(hwndFrame, FID_MENU);

	    if (frameMenu)
	    {
		ULONG ulStyle = WinQueryWindowULong((HWND)frameMenu, QWL_STYLE);
		ulStyle |= MS_ACTIONBAR | WS_CLIPSIBLINGS;
		ulStyle &= ~WS_SAVEBITS;
		WinSetWindowULong((HWND)_fPlatPopup, QWL_STYLE, ulStyle);

		const ULONG nMaxPath = 288;
		char  szFontName[nMaxPath];

		USHORT usID = (USHORT)WinQueryWindowUShort(frameMenu,QWS_ID);
		WinSetWindowUShort(_fPlatPopup, QWS_ID, usID);
		WinQueryPresParam(frameMenu, PP_FONTNAMESIZE, 0L, NULL,
				  nMaxPath, (PPVOID)szFontName, 0);
		WinSetPresParam(_fPlatPopup, PP_FONTNAMESIZE,
				strlen(szFontName)+1, (PVOID)szFontName);
	    }

	    WinPopupMenu(HWND_DESKTOP,
			 WinWindowFromID(hwndFrame, FID_CLIENT), //129618
			 _fPlatPopup,
			 ptl.x, ptl.y, 0L,
			 PU_HCONSTRAIN | PU_VCONSTRAIN |
			 PU_NONE |PU_MOUSEBUTTON1 | PU_KEYBOARD);
	#endif // PLATFORM_OS2

	#ifdef _PLATFORM_WIN32_

	    DWORD err;
	    BOOL  res = TrackPopupMenu(_fPlatPopup,
					TPM_LEFTALIGN | TPM_LEFTBUTTON,
					ptl.x, ptl.y, 0L,
					hwndFrame, NULL);
	    if (res == FALSE)
		err = GetLastError();

	#endif // PLATFORM_WIN32

	#ifdef _PLATFORM_AIX_
	    _fMenu->DisplayAsPopup(ev, mainWinWidget, root_x, root_y);
	#endif // PLATFORM_AIX

	// Set this popup menu as the current one
	// --------------------------------------
	winStat->SetCurrentPopUpMenu(ev,somSelf);
    }
    catch (ODException _exception)
    {
	SetErrorCode(kODNoError);
    }

} /* end Display */

//-------------------------------------------------------------------------------------
// Copy [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODMenuBar*  SOMLINK ODPopupCopy(ODPopup *somSelf,  Environment *ev)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupCopy");

    ODPopup* newPopup = kODNULL;

    try {
	newPopup = new ODPopup;
	THROW_IF_NULL(newPopup, kODErrUndefined);

	// for AIX and OS/2, InitPopup can automatically copy
	// all the menu items and adapters, based upon the info
	// availabled in _fMenu or_fPlatPopup...
	// ----------------------------------------------------
	#ifdef _PLATFORM_AIX_
	    newPopup->InitPopup(ev, _fSession, _fMenu);
	#endif // PLATFORM_AIX

	#ifdef _PLATFORM_OS2_
	    newPopup->InitPopup(ev, _fSession, _fPlatPopup);
	#endif // PLATFORM_OS2

	// For NT, we have to retrieve the menu ID info stored
	// in our menu adapters, and then call InitPopupEx().
	// ----------------------------------------------------
	#ifdef _PLATFORM_WIN32_
	    OrderedCollection* subMenuIDcoll = new OrderedCollection;

	    ODUShort      nSubMenuIDs = 0;
	    ODMenuIDInfo* subMenuIDs  = kODNULL;

	    if (_fMenu->GetSubMenuIDInfo(ev, subMenuIDcoll))
	    {
		nSubMenuIDs = subMenuIDcoll->Count();
		subMenuIDs  = new ODMenuIDInfo[nSubMenuIDs];
		int index   = 0;

		while (subMenuIDcoll->Count())
		{
		    ODMenuIDInfo* nextID = (ODMenuIDInfo*)subMenuIDcoll->First();
		    subMenuIDcoll->Remove((ElementType)nextID);

		    subMenuIDs[index].hMenu = nextID->hMenu;
		    subMenuIDs[index].id    = nextID->id;
		    index++;

		    delete nextID;
		}

		delete subMenuIDcoll;
	    }

	    newPopup->InitPopupEx(ev, _fSession, _fPlatPopup,
				      nSubMenuIDs, subMenuIDs);
	    ODDeleteObject(subMenuIDs);

	#endif // PLATFORM_WIN32
    }
    catch (ODException _exception)
    {
	ODDeleteObject(newPopup);
	SetErrorCode(kODNoError);
    }

    return (ODMenuBar*) newPopup;

} /* end Copy */

//-------------------------------------------------------------------------------------
// AddMenuLast [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupAddMenuLast(ODPopup *somSelf, 
                                            Environment *ev, 
                                           ODMenuID menuID, ODPlatformMenu menu, 
                                           ODPart* part)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddMenuLast");

    somSelf->AddSubMenuLast(ev, ID_BASEPOPUP, menuID, menu);

} /* end AddMenuLast */

//-------------------------------------------------------------------------------------
// AddMenuBefore [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupAddMenuBefore(ODPopup *somSelf, 
                                              Environment *ev, 
                                             ODMenuID menuID, 
                                             ODPlatformMenu menu, 
                                             ODPart* part, ODMenuID beforeID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddMenuBefore");

    somSelf->AddSubMenuBefore(ev, ID_BASEPOPUP, menuID, menu, beforeID);

} /* end AddMenuBefore */

//-------------------------------------------------------------------------------------
// RemoveMenu [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupRemoveMenu(ODPopup *somSelf,  Environment *ev, 
                                          ODMenuID menu)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupRemoveMenu");

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd = kODNULL;
	ODOS2MenuAdapter* os2parentAd  = kODNULL;

	if (_fMenu->GetSubMenuAdapter(ev, menu, &os2subMenuAd))
	{
	    os2subMenuAd->GetParentAdapter(ev, &os2parentAd);

	    if (os2parentAd)
	    {
		// if this is a submenu, let the parent
		// menu adapter take care of it...
		// ------------------------------------
		os2parentAd->RemoveMenuItem(ev, menu);
	    }
	    else
	    {
		_fMenu->RemoveMenuItem(ev, menu);
	    }
	}
    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd = kODNULL;
	ODWinMenuAdapter* winParentAd  = kODNULL;

	if (_fMenu->GetSubMenuAdapter(ev, menu, &winSubMenuAd))
	{
	    winSubMenuAd->GetParentAdapter(ev, &winParentAd);

	    if (winParentAd)
	    {
		// if this is a submenu, let the parent
		// menu adapter take care of it...
		// ------------------------------------
		winParentAd->RemoveMenuItem(ev, menu);
	    }
	    else
	    {
		_fMenu->RemoveMenuItem(ev, menu);
	    }
	}
    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
       ODX11MenuAdapter* x11subMenuAd
                = (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menu);

	ODX11MenuAdapter* x11parentAd  = kODNULL;

	if (x11subMenuAd)
	{
	    x11subMenuAd->GetParentAdapter(ev, &x11parentAd);

	    if (x11parentAd)
	    {
		// if this is a submenu, let the parent
		// menu adapter take care of it...
		// ------------------------------------
		x11parentAd->RemoveMenuItem(ev, menu);
	    }
	    else
	    {
		_fMenu->RemoveMenuItem(ev, menu);
	    }
	}
    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	SetErrorCode(kODNoError);
    }

} /* end RemoveMenu */

//-------------------------------------------------------------------------------------
// GetMenu [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODPlatformMenu  SOMLINK ODPopupGetMenu(ODPopup *somSelf, 
                                                  Environment *ev, 
                                                 ODMenuID menu)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupGetMenu");

    ODPlatformMenu platMenu = kODNULL;

    #ifdef _PLATFORM_OS2_

	ODOS2MenuAdapter* os2subMenuAd = kODNULL;

	if (menu == ID_BASEPOPUP)
	{
	    platMenu = _fPlatPopup;
	}
	else if (_fMenu->GetSubMenuAdapter(ev, menu, &os2subMenuAd))
	{
	    os2subMenuAd->GetPlatMenu(ev, &platMenu);
	}

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_

	ODWinMenuAdapter* winSubMenuAd = kODNULL;

	if (menu == ID_BASEPOPUP)
	{
	    platMenu = _fPlatPopup;
	}
	else if (_fMenu->GetSubMenuAdapter(ev, menu, &winSubMenuAd))
	{
	    winSubMenuAd->GetPlatMenu(ev, &platMenu);
	}

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	// on AIX, the adapter IS the platform menu...
	// -------------------------------------------
	if (menu == ID_BASEPOPUP)
	{
	    platMenu = (ODPlatformMenu) _fMenu;
	}
	else
	{
	    platMenu = _fMenu->GetSubMenu(ev, menu);
	}

    #endif // PLATFORM_AIX

    return platMenu;

} /* end GetMenu */

//-------------------------------------------------------------------------------------
// IsValid [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupIsValid(ODPopup *somSelf, 
                                             Environment *ev)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupIsValid");

    return kODTrue;

} /* end IsValid */

//-------------------------------------------------------------------------------------
// GetMenuText [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODUShort  SOMLINK ODPopupGetMenuText(ODPopup *somSelf, 
                                                Environment *ev, 
                                               ODMenuID menuID, 
                                               string* menuString)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupGetMenuText");

    if (menuID == ID_BASEPOPUP)
	return 0;

    ODUShort sLength = 0;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    sLength = os2subMenuAd->GetMenuText(ev, menuString);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    sLength = winSubMenuAd->GetMenuText(ev, menuString);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    sLength = x11subMenuAd->GetMenuText(ev, menuString);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	sLength = 0;
	SetErrorCode(kODNoError);
    }

    return sLength;

} /* end GetMenuText */

//-------------------------------------------------------------------------------------
// SetMenuText [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupSetMenuText(ODPopup *somSelf, 
                                                 Environment *ev, 
                                                ODMenuID menuID, 
                                                string menuString)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupSetMenuText");

    if (menuID == ID_BASEPOPUP)
	return kODFalse;

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->SetMenuText(ev, menuString);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->SetMenuText(ev, menuString);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->SetMenuText(ev, menuString);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end SetMenuText */

//-------------------------------------------------------------------------------------
// GetMenuItemText [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODUShort  SOMLINK ODPopupGetMenuItemText(ODPopup *somSelf, 
                                                    Environment *ev, 
                                                   ODMenuID menuID, 
                                                   ODMenuItemID menuItemID, 
                                                   string* menuItemString)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupGetMenuItemText");

    ODUShort sLength = 0;

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->GetMenuItemText(ev, menuItemID, menuItemString));

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    sLength = os2subMenuAd->GetMenuItemText(ev, menuItemID, menuItemString);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    sLength = winSubMenuAd->GetMenuItemText(ev, menuItemID, menuItemString);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    sLength = x11subMenuAd->GetMenuItemText(ev, menuItemID, menuItemString);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	sLength = 0;
	SetErrorCode(kODNoError);
    }

    return sLength;

} /* end GetMenuItemText */

//-------------------------------------------------------------------------------------
// SetMenuItemText [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupSetMenuItemText(ODPopup *somSelf, 
                                                     Environment *ev, 
                                                    ODMenuID menuID, 
                                                    ODMenuItemID menuItemID, 
                                                    string menuItemString)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupSetMenuItemText");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->SetMenuItemText(ev, menuItemID, menuItemString));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->SetMenuItemText(ev, menuItemID, menuItemString);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->SetMenuItemText(ev, menuItemID, menuItemString);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->SetMenuItemText(ev, menuItemID, menuItemString);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end SetMenuItemText */

//-------------------------------------------------------------------------------------
// SetHideMenuItem [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupSetHideMenuItem(ODPopup *somSelf, 
                                                     Environment *ev, 
                                                    ODMenuID menuID, 
                                                    ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupSetHideMenuItem");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->SetHideMenuItem(ev, menuItemID));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->SetHideMenuItem(ev, menuItemID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->SetHideMenuItem(ev, menuItemID);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->SetHideMenuItem(ev, menuItemID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end SetHideMenuItem */

//-------------------------------------------------------------------------------------
// SetShowMenuItem [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupSetShowMenuItem(ODPopup *somSelf, 
                                                     Environment *ev, 
                                                    ODMenuID menuID, 
                                                    ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupSetShowMenuItem");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->SetShowMenuItem(ev, menuItemID));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->SetShowMenuItem(ev, menuItemID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->SetShowMenuItem(ev, menuItemID);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->SetShowMenuItem(ev, menuItemID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end SetShowMenuItem */

//-------------------------------------------------------------------------------------
// CheckMenuItem [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupCheckMenuItem(ODPopup *somSelf, 
                                                   Environment *ev, 
                                                  ODMenuID menuID, 
                                                  ODMenuItemID menuItemID, 
                                                  ODBoolean check)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupCheckMenuItem");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->CheckMenuItem(ev, menuItemID, check));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->CheckMenuItem(ev, menuItemID, check);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->CheckMenuItem(ev, menuItemID, check);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->CheckMenuItem(ev, menuItemID, check);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end CheckMenuItem */

//-------------------------------------------------------------------------------------
// EnableMenu [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupEnableMenu(ODPopup *somSelf, 
                                                Environment *ev, 
                                               ODMenuID menuID, 
                                               ODBoolean enable)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupEnableMenu");

    if (menuID == ID_BASEPOPUP)
    {
	if (enable)
	    _fMenu->EnableMenu(ev);
	else
	    _fMenu->DisableMenu(ev);

	return kODTrue;
    }

    ODBoolean bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	{
	    if (enable)
		os2subMenuAd->EnableMenu(ev);
	    else
		os2subMenuAd->DisableMenu(ev);
	}
    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	{
	    if (enable)
		winSubMenuAd->EnableMenu(ev);
	    else
		winSubMenuAd->DisableMenu(ev);
	}
    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd =
	    (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	{
	    if (enable)
		x11subMenuAd->EnableMenu(ev);
	    else
		x11subMenuAd->DisableMenu(ev);
	}
    #endif // PLATFORM_AIX

	bResult = kODTrue;

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end EnableMenu */

//-------------------------------------------------------------------------------------
// EnableMenuItem [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupEnableMenuItem(ODPopup *somSelf, 
                                                    Environment *ev, 
                                                   ODMenuID menuID, 
                                                   ODMenuItemID menuItemID, 
                                                   ODBoolean enable)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupEnableMenuItem");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->EnableMenuItem(ev, menuItemID, enable));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->EnableMenuItem(ev, menuItemID, enable);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->EnableMenuItem(ev, menuItemID, enable);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->EnableMenuItem(ev, menuItemID, enable);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end EnableMenuItem */

//-------------------------------------------------------------------------------------
// AddMenuItemBefore [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupAddMenuItemBefore(ODPopup *somSelf, 
                                                       Environment *ev, 
                                                      ODMenuID menuID, 
                                                      ODMenuItemID itemID, 
                                                      ODPlatformMenuItem* menuItem, 
                                                      ODMenuItemID beforeID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddMenuItemBefore");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->AddMenuItemBefore(ev, itemID, menuItem, beforeID));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->AddMenuItemBefore(ev, itemID, menuItem, beforeID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->AddMenuItemBefore(ev, itemID, menuItem, beforeID);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->AddMenuItemBefore(ev, itemID, menuItem, beforeID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end AddMenuItemBefore */

//-------------------------------------------------------------------------------------
// AddMenuItemLast [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupAddMenuItemLast(ODPopup *somSelf, 
                                                     Environment *ev, 
                                                    ODMenuID menuID, 
                                                    ODMenuItemID itemID, 
                                                    ODPlatformMenuItem* menuItem)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddMenuItemLast");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->AddMenuItemLast(ev, itemID, menuItem));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->AddMenuItemLast(ev, itemID, menuItem);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->AddMenuItemLast(ev, itemID, menuItem);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->AddMenuItemLast(ev, itemID, menuItem);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end AddMenuItemLast */

//-------------------------------------------------------------------------------------
// InsertSubmenu [OVERRIDE] [OBSOLETE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupInsertSubmenu(ODPopup *somSelf, 
                                                   Environment *ev, 
                                                  ODMenuID menuID, 
                                                  ODMenuItemID subMenuID, 
                                                  ODPlatformMenu newSubmenu)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupInsertSubmenu");

    return somSelf->AddSubMenuLast(ev, menuID, subMenuID, newSubmenu);

} /* end InsertSubmenu */

//-------------------------------------------------------------------------------------
// AddSubMenuBefore [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupAddSubMenuBefore(ODPopup *somSelf, 
                                                      Environment *ev, 
                                                     ODMenuID menuID, 
                                                     ODMenuItemID subMenuItemID, 
                                                     ODPlatformMenu newSubMenu, 
                                                     ODMenuItemID beforeID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddSubMenuBefore");

    #ifdef _PLATFORM_WIN32_
	return (somSelf->AddSubMenuBeforeEx(ev, menuID, subMenuItemID,
						newSubMenu, beforeID,
						0, NULL));
    #endif // PLATFORM_WIN32

    #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_AIX_)
	if (menuID == ID_BASEPOPUP)
	    return (_fMenu->AddSubMenuBefore(ev, subMenuItemID, newSubMenu,
						 beforeID));
    #endif // PLATFORM_OS2, PLATFORM_AIX

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->AddSubMenuBefore(ev, subMenuItemID, newSubMenu, beforeID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->AddSubMenuBefore(ev, subMenuItemID, newSubMenu, beforeID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end AddSubMenuBefore */

//-------------------------------------------------------------------------------------
// AddSubMenuLast [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupAddSubMenuLast(ODPopup *somSelf, 
                                                    Environment *ev, 
                                                   ODMenuID menuID, 
                                                   ODMenuItemID subMenuItemID, 
                                                   ODPlatformMenu newSubMenu)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddSubMenuLast");

    #ifdef _PLATFORM_WIN32_
	return (somSelf->AddSubMenuLastEx(ev, menuID, subMenuItemID,
					      newSubMenu, 0, NULL));
    #endif // PLATFORM_WIN32

    #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_AIX_)
	if (menuID == ID_BASEPOPUP)
	    return (_fMenu->AddSubMenuLast(ev, subMenuItemID, newSubMenu));
    #endif // PLATFORM_OS2, PLATFORM_AIX

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->AddSubMenuLast(ev, subMenuItemID, newSubMenu);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->AddSubMenuLast(ev, subMenuItemID, newSubMenu);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end AddSubMenuLast */

//-------------------------------------------------------------------------------------
// MenuExists [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupMenuExists(ODPopup *somSelf, 
                                                Environment *ev, 
                                               ODMenuID menuID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupMenuExists");

    if (menuID == ID_BASEPOPUP)
	return kODTrue;

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;
	bResult = (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd));
    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;
	bResult = (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd));
    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	bResult = (_fMenu->GetSubMenu(ev, menuID) != kODNULL);
    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end MenuExists */

//-------------------------------------------------------------------------------------
// IsMenuEnabled [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupIsMenuEnabled(ODPopup *somSelf, 
                                                   Environment *ev, 
                                                  ODMenuID menuID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupIsMenuEnabled");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->IsMenuEnabled(ev));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->IsMenuEnabled(ev);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->IsMenuEnabled(ev);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->IsMenuEnabled(ev);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end IsMenuEnabled */

//-------------------------------------------------------------------------------------
// MenuItemExists [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupMenuItemExists(ODPopup *somSelf, 
                                                    Environment *ev, 
                                                   ODMenuID menuID, 
                                                   ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupMenuItemExists");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->ItemExists(ev, menuItemID));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->ItemExists(ev, menuItemID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->ItemExists(ev, menuItemID);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->ItemExists(ev, menuItemID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end MenuItemExists */

//-------------------------------------------------------------------------------------
// Exists [OVERRIDE] [OBSOLETE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupExists(ODPopup *somSelf, 
                                            Environment *ev, 
                                           ODMenuID menuID, ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupExists");

    return (somSelf->MenuItemExists(ev, menuID, menuItemID));

} /* end Exists */

//-------------------------------------------------------------------------------------
// IsItemEnabled [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupIsItemEnabled(ODPopup *somSelf, 
                                                   Environment *ev, 
                                                  ODMenuID menuID, 
                                                  ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupIsItemEnabled");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->IsItemEnabled(ev, menuItemID));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->IsItemEnabled(ev, menuItemID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->IsItemEnabled(ev, menuItemID);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->IsItemEnabled(ev, menuItemID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end IsItemEnabled */

//-------------------------------------------------------------------------------------
// IsItemChecked [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupIsItemChecked(ODPopup *somSelf, 
                                                   Environment *ev, 
                                                  ODMenuID menuID, 
                                                  ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupIsItemChecked");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->IsItemChecked(ev, menuItemID));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->IsItemChecked(ev, menuItemID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->IsItemChecked(ev, menuItemID);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->IsItemChecked(ev, menuItemID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end IsItemChecked */

//-------------------------------------------------------------------------------------
// IsItemHidden [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupIsItemHidden(ODPopup *somSelf, 
                                                  Environment *ev, 
                                                 ODMenuID menuID, 
                                                 ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupIsItemHidden");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->IsItemHidden(ev, menuItemID));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->IsItemHidden(ev, menuItemID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->IsItemHidden(ev, menuItemID);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->IsItemHidden(ev, menuItemID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end IsItemHidden */

//-------------------------------------------------------------------------------------
// RemoveMenuItem [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupRemoveMenuItem(ODPopup *somSelf, 
                                                    Environment *ev, 
                                                   ODMenuID menuID, 
                                                   ODMenuItemID menuItemID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupRemoveMenuItem");

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->RemoveMenuItem(ev, menuItemID));

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter* os2subMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &os2subMenuAd))
	    bResult = os2subMenuAd->RemoveMenuItem(ev, menuItemID);

    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter* winSubMenuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &winSubMenuAd))
	    bResult = winSubMenuAd->RemoveMenuItem(ev, menuItemID);

    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* x11subMenuAd
		= (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (x11subMenuAd)
	    bResult = x11subMenuAd->RemoveMenuItem(ev, menuItemID);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end RemoveMenuItem */

//-------------------------------------------------------------------------------------
// GetMenuItem [OVERRIDE]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean  SOMLINK ODPopupGetMenuItem(ODPopup *somSelf, 
                                                 Environment *ev, 
                                                ODMenuID menuID, 
                                                ODMenuItemID menuItemID, 
                                                ODPlatformMenuItem* menuItem)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupGetMenuItem");

    ODUShort bResult = kODFalse;

    try {

    #ifdef _PLATFORM_OS2_
	ODOS2MenuAdapter*     menuAd = kODNULL;
	ODOS2MenuItemAdapter* itemAd = kODNULL;

	if (menuID == ID_BASEPOPUP)
	    menuAd = _fMenu;
	else
	    _fMenu->GetSubMenuAdapter(ev, menuID, &menuAd);

	if ((menuAd) && (menuAd->GetMenuItemAdapter(ev, menuItemID, &itemAd)))
	{
	    bResult = menuAd->GetPlatMenuItem(ev, itemAd, menuItem);

	    ODUShort pos;
	    menuAd->GetMenuItemPosition(ev, menuItemID, &pos);
	    menuItem->iPosition = pos;
	}
    #endif // PLATFORM_OS2

    #ifdef _PLATFORM_WIN32_
	ODWinMenuAdapter*     menuAd = kODNULL;
	ODWinMenuItemAdapter* itemAd = kODNULL;

	if (menuID == ID_BASEPOPUP)
	    menuAd = _fMenu;
	else
	    _fMenu->GetSubMenuAdapter(ev, menuID, &menuAd);

	if ((menuAd) && (menuAd->GetMenuItemAdapter(ev, menuItemID, &itemAd)))
	{
	    bResult = menuAd->GetPlatMenuItem(ev, itemAd, menuItem);

	    ODUShort pos;
	    menuAd->GetMenuItemPosition(ev, menuItemID, &pos);
	    menuItem->iPosition = pos;
	}
    #endif // PLATFORM_WIN32

    #ifdef _PLATFORM_AIX_
	ODX11MenuAdapter* menuAd;

	if (menuID == ID_BASEPOPUP)
	    menuAd = _fMenu;
	else
	    menuAd = (ODX11MenuAdapter*) _fMenu->GetSubMenu(ev, menuID);

	if (menuAd)
	    bResult = menuAd->GetMenuItem(ev, menuItemID, menuItem);

    #endif // PLATFORM_AIX

    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end GetMenuItem */

#ifdef _PLATFORM_WIN32_
//=====================================================================================
// OVERRIDDEN METHODS FOR WINDOWS ONLY
//=====================================================================================
//-------------------------------------------------------------------------------------
// AddMenuBeforeEx [WIN32 only]
//-------------------------------------------------------------------------------------
SOM_Scope void SOMLINK ODPopupAddMenuBeforeEx(ODPopup *somSelf,
						 Environment *ev,
						 ODMenuID menuID,
						 ODPlatformMenu menu,
						 ODPart* part,
						 ODMenuID beforeID,
						 ODUShort subMenuIDcount,
						 ODMenuIDInfo *subMenuIDinfo)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddMenuBeforeEx");

    somSelf->AddSubMenuBeforeEx(ev, ID_BASEPOPUP, menuID, menu, beforeID,
				    subMenuIDcount, subMenuIDinfo);

} /* end AddMenuBeforeEx */

//-------------------------------------------------------------------------------------
// AddMenuLastEx [WIN32 only]
//-------------------------------------------------------------------------------------
SOM_Scope void SOMLINK ODPopupAddMenuLastEx(ODPopup *somSelf,
						Environment *ev,
						ODMenuID menuID,
						ODPlatformMenu menu,
						ODPart* part,
						ODUShort subMenuIDcount,
						ODMenuIDInfo *subMenuIDinfo)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddMenuLastEx");

    somSelf->AddSubMenuLastEx(ev, ID_BASEPOPUP, menuID, menu,
				  subMenuIDcount, subMenuIDinfo);

} /* end AddMenuLastEx */

//-------------------------------------------------------------------------------------
// AddSubMenuBeforeEx [WIN32 only]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean SOMLINK ODPopupAddSubMenuBeforeEx(ODPopup *somSelf,
							 Environment *ev,
							ODMenuID menuID,
							ODMenuItemID subMenuItemID,
							ODPlatformMenu newSubMenu,
							ODMenuID beforeID,
							ODUShort subMenuIDcount,
							ODMenuIDInfo *subMenuIDinfo)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddSubMenuBeforeEx");

    ODBoolean bResult = kODFalse;

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->AddSubMenuBeforeEx(ev,  subMenuItemID, newSubMenu, beforeID,
						subMenuIDcount, subMenuIDinfo));
    try {

	ODWinMenuAdapter* menuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &menuAd))
	    bResult = menuAd->AddSubMenuBeforeEx (ev, subMenuItemID, newSubMenu, beforeID,
						      subMenuIDcount, subMenuIDinfo);
    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end AddSubMenuBeforeEx */

//-------------------------------------------------------------------------------------
// AddSubMenuLastEx [WIN32 only]
//-------------------------------------------------------------------------------------
SOM_Scope ODBoolean SOMLINK ODPopupAddSubMenuLastEx(ODPopup *somSelf,
							Environment *ev,
							ODMenuID menuID,
							ODMenuItemID subMenuItemID,
							ODPlatformMenu newSubMenu,
							ODUShort subMenuIDcount,
							ODMenuIDInfo *subMenuIDinfo)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupAddSubMenuLastEx");

    ODBoolean bResult = kODFalse;

    if (menuID == ID_BASEPOPUP)
	return (_fMenu->AddSubMenuLastEx(ev, subMenuItemID, newSubMenu,
					     subMenuIDcount, subMenuIDinfo));
    try {

	ODWinMenuAdapter* menuAd;

	if (_fMenu->GetSubMenuAdapter(ev, menuID, &menuAd))
	    bResult = menuAd->AddSubMenuLastEx(ev, subMenuItemID, newSubMenu,
						   subMenuIDcount, subMenuIDinfo);
    }
    catch (ODException _exception)
    {
	bResult = kODFalse;
	SetErrorCode(kODNoError);
    }

    return bResult;

} /* end AddSubMenuLastEx */

#endif // PLATFORM_WIN32

#ifdef _PLATFORM_AIX_
//=====================================================================================
// METHODS FOR AIX ONLY
//=====================================================================================
//-------------------------------------------------------------------------------------
// CreateX11PlatformMenu [AIX only]
//-------------------------------------------------------------------------------------
SOM_Scope ODPlatformMenu  SOMLINK ODPopupCreateX11PlatformMenu(ODPopup *somSelf,
								  Environment *ev,
								 ODMenuID menuID)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupCreateX11PlatformMenu");

    ODX11MenuAdapter* newMenuAd = kODNULL;

    try {
        newMenuAd = new ODX11MenuAdapter;
        newMenuAd->Init(ev, menuID, _fSession);
    }
    catch (ODException _exception)
    {
        ODDeleteObject(newMenuAd);
        newMenuAd = kODNULL;
        SetErrorCode(kODNoError);
    }

    return (ODPlatformMenu) newMenuAd;

} /* end CreateX11PlatformMenu */

//-------------------------------------------------------------------------------------
// DestroyX11PlatformMenu [AIX only]
//-------------------------------------------------------------------------------------
SOM_Scope void  SOMLINK ODPopupDestroyX11PlatformMenu(ODPopup *somSelf,
							 Environment *ev,
							ODPlatformMenu menu)
{
    ODPopupData *somThis = ODPopupGetData(somSelf);
    ODPopupMethodDebug("ODPopup","ODPopupDestroyX11PlatformMenu");

    ODX11MenuAdapter* killMenu = (ODX11MenuAdapter*) menu;

    ODDeleteObject(killMenu);

} /* end DestroyX11PlatformMenu */


//-------------------------------------------------------------------------------------
// GetMenuStringFromID [PRIVATE]
//-------------------------------------------------------------------------------------
// Description: Get the string resource that corresponds
//		to the menu item id passed in.
//
// Parameters: menuItemID - a predefined OpenDoc menu ID, such as EDIT_CUT
//
// Return Value: text of a resource file string that matches the menu item ID
//
string  ODPopupGetMenuStringFromID(ODPopup *somSelf, Environment *ev, 
				   ODMenuItemID menuItemID)
{
    string retVal  = kODNULL;

    switch (menuItemID) {

	case IDMS_DOCUMENT:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_29, "Document");
	    break;
	
	case DOC_NEW:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_30, "New Document");
	    break;
	
	case DOC_INSERT:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_57, "Insert");
	    break;
	
	case DOC_SAVE:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_32, "Save Document");
	    break;
	
	case DOC_SAVECOPY:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_33, "Save A Copy...");
	    break;
	
	case DOC_REVERTTOSAVED:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_34, "Revert to Saved...");
	    break;
	
	case DOC_DRAFTS:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_35, "Drafts");
	    break;
	
	case DOC_DRAFTCREATE:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_36, "Create Draft...");
	    break;
	
	case DOC_DRAFTHISTORY:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_37, "Draft History...");
	    break;
	
	case DOC_PROPERTIES:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_86, "Properties");
	    break;
	
	case DOC_SETUP:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_39, "Page Setup...");
	    break;
	
	case DOC_PRINT:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_40, "Print Document...");
	    break;
	
	case DOC_CLOSE:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_41, "Close Document...");
	    break;
	
	case IDMS_EDIT:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_42, "Edit");
	    break;
	
	case EDIT_UNDO:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_43, "Undo");
	    break;
	
	case EDIT_REDO:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_44, "Redo");
	    break;
	
	case EDIT_CREATE:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_45, "Create");
	    break;
	
	case EDIT_CUT:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_46, "Cut");
	    break;
	
	case EDIT_COPY:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_47, "Copy");
	    break;
	
	case EDIT_PASTE:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_48, "Paste");
	    break;
	
	case EDIT_PASTEAS:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_49, "Paste As...");
	    break;
	
	case EDIT_LINK_MENU:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_50, "Links");
	    break;
	
	case EDIT_PASTELINK:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_51, "Paste Link");
	    break;
	
	case EDIT_BREAKLINK:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_52, "Break Link");
	    break;
	
	case EDIT_DELETE:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_53, "Delete Selection");
	    break;
	
	case EDIT_SELECTALL:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_54, "Select All");
	    break;
	
	case EDIT_DESELECTALL:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_55, "Deselect All");
	    break;
	
	case EDIT_OPENSEL:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_56, "Open Selection");
	    break;
	
	case EDIT_SELPROPERTIES:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_58, "Selection Properties...");
	    break;
	
	case IDMS_HELP:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_59, "Help");
	    break;
	
	case HELP_INDEX_OD:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_60, "Help Index");
	    break;
	
	case HELP_GENERAL:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_61, "General Help");
	    break;
	
	case HELP_USING:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_62, "Using Help");
	    break;
	
	case HELP_PRODUCTINFO:
	    retVal = catgets(ODcat_handle, DOCSH_SET, DOCMSG_63, "OpenDoc Information");
	    break;
	
	default:
	    break;
    }

   return retVal;

} /* end RetrieveMenuItemString */

#endif // PLATFORM_AIX
//=====================================================================================
// END OF FILE Popup.cpp
//=====================================================================================
