home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ibmodf.zip
/
CNTNRPRT.ZIP
/
MENUBROT.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-03
|
10KB
|
241 lines
/*
* This file was generated by the SOM Compiler.
* Generated using:
* SOM incremental update: 2.38
*/
/*
* This file was generated by the SOM Compiler and Emitter Framework.
* Generated using:
* SOM Emitter emitxtm: 2.38
*/
#ifndef SOM_Module_menubrot_Source
#define SOM_Module_menubrot_Source
#endif
#define ODRootFrameMenuBar_Class_Source
#define VARIABLE_MACROS
#define INCL_ODFRAME
#define INCL_ODPART
#define INCL_WINMESSAGEMGR
#include "MenuBRot.xih"
#include <os2.h>
SOM_Scope void SOMLINK ODRootFrameMenuBarSetDependeeMenuBar(ODRootFrameMenuBar *somSelf,
Environment *ev,
ODMenuBar* menuBar)
{
ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarSetDependeeMenuBar");
if (_mbDependentUpon == menuBar) return;
if (_mbDependentUpon) {
_mbDependentUpon->DependentMenuBarRemoved( ev, somSelf);
} /* endif */
_mbDependentUpon = menuBar;
menuBar->DependentMenuBarAdded(ev, somSelf);
//_fSynchedChangeNumber = ancestor->fChangeNumber;
#if 0
// Recopy...
somSelf->ClearMenuBarTree(ev);
if (_mbDependentUpon) {
somSelf->AddMenuBLast( ev, _mbDependentUpon, ODMENUID_ROOT);
} /* endif */
#endif
}
SOM_Scope ODMenuBar* SOMLINK ODRootFrameMenuBarGetDependeeMenuBar(ODRootFrameMenuBar *somSelf,
Environment *ev)
{
ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarGetDependeeMenuBar");
return _mbDependentUpon;
}
SOM_Scope void SOMLINK ODRootFrameMenuBarSetOwner(ODRootFrameMenuBar *somSelf,
Environment *ev,
ODFrame* frame)
{
ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarSetOwner");
// This class only inherits menu items from one menu. If you need a menu to
// inherit menu items from multiple menus, then you'd probably want to
// create a new subclass of the ODMenuBar class that manages the
// dependencies as you like.
_fOwnerFrame = frame;
}
SOM_Scope void SOMLINK ODRootFrameMenuBarAdjustRootMenus(ODRootFrameMenuBar *somSelf,
Environment *ev,
ODMenuID menuID,
ODFrame* frame)
{
ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarAdjustRootMenus");
// This procedure could adjust the menus itself or it could call a method of the
// part or a part's extension. If calling the part, this class could be paired
// with a part, or a multiple inheritance could be used to add a generic method
// to the part which can be called. A final option is to have this routine use
// SOM techniques to confirm that the part has a method with the expected
// name and then call that method.
// Note: this method could be pure virtual too and parts could be required to
// subclass this class and method to provide its prefered technique to
// handle this as it likes.
// The approach chosen by the ODActiveFrameMenuBar class is to call
// the AdjustMenus method of the part. To keep this sample simple,
// I'll just make this method pure virtual, and allow a subclass to handle
// it how they prefer. That means, if a part uses an instance of this
// class (without subclassing it), they will not be able to adjust menu
// items contributed by the root frame.
}
SOM_Scope void SOMLINK ODRootFrameMenuBarsomInit(ODRootFrameMenuBar *somSelf)
{
ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarsomInit");
ODRootFrameMenuBar_parent_ODMenuBar_somInit(somSelf);
_mbDependentUpon = kODNULL;
_fInRecursion1 = kODFalse;
//_fSynchedChangeNumber = 0;
}
SOM_Scope ODBoolean SOMLINK ODRootFrameMenuBarHandleEvent(ODRootFrameMenuBar *somSelf,
Environment *ev,
ODEventData* event)
{
ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarHandleEvent");
switch (event->msg) {
case WM_COMMAND:
case WM_HELP:
case WM_DRAWITEM:
{
SHORT command = SHORT1FROMMP(event->mp1);
SHORT commandx = SHORT2FROMMP(event->mp1);
if ( (command>=ODMENUID_ROOTPART_FIRST) &&
(command< ODMENUID_ROOTPART_LAST)) {
if (_fOwnerFrame) {
return _fOwnerFrame->GetPart( ev)->HandleEvent( ev, event, _fOwnerFrame, (ODFacet*)kODNULL);
} else {
// We require that the owning frame to be set in this class.
// This could be rewritten to determine from which ODWindow's
// menu this was generated. Then figure out the root frame of
// that window and then the part of that frame. It seems much
// easier though to just have that frame set associate an owner
// frame with each of menu.
return kODFalse; // not processed. Someone forgot to set the
// owner of this menu.
} /* endif */
} else {
// The menuid's don't seem to be in the range of the root part, so
// we'll just pass this event on to our dependee menu. If this
// class supported multiple dependee's, this would be a bit
// more complicated.
if (_mbDependentUpon) {
#ifdef NOREMAPPING
return _mbDependentUpon->HandleEvent(ev, event );
#else
SHORT commandx = SHORT2FROMMP(event->mp1);
ODEventData oded = *event;
oded.mp1 = MPFROM2SHORT( somSelf->GetOldMenuID(ev, command), commandx );
return _mbDependentUpon->HandleEvent(ev, &oded );
#endif
} /* endif */
} /* endif */
}
break;
case WM_INITMENU:
{
ODMenuID menuID = SHORT1FROMMP(event->mp1);
somSelf->UpdateMenuDependencyChain( ev, menuID);
{
ODPlatformWindow hwndMenu = HWNDFROMMP(event->mp2);
if (hwndMenu) {
somSelf->UpdateMenuWindowTree( ev, hwndMenu, menuID);
return kODTrue;
} /* endif */
}
}
break;
default:
break;
} /* endswitch */
return kODFalse; // not processed
}
SOM_Scope void SOMLINK ODRootFrameMenuBarUpdateMenuDependencyChain(ODRootFrameMenuBar *somSelf,
Environment *ev,
ODMenuID menuID)
{
ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarUpdateMenuDependencyChain");
if (_fInRecursion1) {
// We're already in this procedure. There is probably some sort of recursion.
// We'll just return out to avoid infinite recursion. I do consider it to
// be ISV programmer error if we have recursion, but the issues are fairly
// complex here and the documentation is still weak, so I will not do anything
// so unsavory as throwing an exception. (jlc 10-94)
} else {
_fInRecursion1 = kODTrue;
try {
ODMenuBar * mb = _mbDependentUpon;
if (mb) {
// For some parts this code may need to be subclassed or
// rewritten. By calling UMDC() below with
// the same menuID value that this method received, this
// code is assuming that the menu id's haven't been
// renumbered and that menu items haven't been moved
// around. This is probably rarely occuring though.
//
#ifdef NOREMAPPING
mb->UpdateMenuDependencyChain( ev, menuID);
#else
mb->UpdateMenuDependencyChain( ev, somSelf->GetOldMenuID(ev, menuID) );
#endif
} else {
// this clause will be called if the owner has accidentally
// forgotten to call SetDependeeMenuBar() or this menu
// simply doesn't have a dependee menu bar. The later
// might occur if the root frame part has choosen to
// provide a totally original menu.
} /* endif */
somSelf->AdjustRootMenus( ev, menuID, _fOwnerFrame );
} /* end try */
catch ( ... ) {
_fInRecursion1 = kODFalse;
throw;
} /* end catch */
_fInRecursion1 = kODFalse;
} /* endif */
}
SOM_Scope void SOMLINK ODRootFrameMenuBarsomUninit(ODRootFrameMenuBar *somSelf)
{
ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarsomUninit");
Environment *ev = somGetGlobalEnvironment();
if (_mbDependentUpon) {
_mbDependentUpon->DependentMenuBarRemoved( ev, somSelf);
} /* endif */
ODRootFrameMenuBar_parent_ODMenuBar_somUninit(somSelf);
}