home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ibmodf.zip / CNTNRPRT.ZIP / MENUBROT.CPP < prev    next >
C/C++ Source or Header  |  1994-11-03  |  10KB  |  241 lines

  1.  
  2. /*
  3.  *  This file was generated by the SOM Compiler.
  4.  *  Generated using:
  5.  *     SOM incremental update: 2.38
  6.  */
  7.  
  8. /*
  9.  *  This file was generated by the SOM Compiler and Emitter Framework.
  10.  *  Generated using: 
  11.  *      SOM Emitter emitxtm: 2.38
  12.  */
  13.  
  14. #ifndef SOM_Module_menubrot_Source
  15. #define SOM_Module_menubrot_Source
  16. #endif
  17. #define ODRootFrameMenuBar_Class_Source
  18. #define VARIABLE_MACROS
  19. #define INCL_ODFRAME
  20. #define INCL_ODPART
  21. #define INCL_WINMESSAGEMGR
  22.  
  23. #include "MenuBRot.xih"
  24.  
  25. #include <os2.h>
  26.  
  27.  
  28. SOM_Scope void  SOMLINK ODRootFrameMenuBarSetDependeeMenuBar(ODRootFrameMenuBar *somSelf, 
  29.                                                               Environment *ev, 
  30.                                                              ODMenuBar* menuBar)
  31. {
  32.     ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
  33.     ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarSetDependeeMenuBar");
  34.  
  35.     if (_mbDependentUpon == menuBar) return;
  36.  
  37.     if (_mbDependentUpon) {
  38.        _mbDependentUpon->DependentMenuBarRemoved( ev, somSelf);
  39.     } /* endif */
  40.  
  41.     _mbDependentUpon = menuBar;
  42.     menuBar->DependentMenuBarAdded(ev, somSelf);
  43.     //_fSynchedChangeNumber = ancestor->fChangeNumber;
  44.  
  45.     #if 0
  46.        // Recopy...
  47.        somSelf->ClearMenuBarTree(ev);
  48.        if (_mbDependentUpon) {
  49.           somSelf->AddMenuBLast( ev, _mbDependentUpon, ODMENUID_ROOT);
  50.        } /* endif */
  51.     #endif
  52. }
  53.  
  54. SOM_Scope ODMenuBar*  SOMLINK ODRootFrameMenuBarGetDependeeMenuBar(ODRootFrameMenuBar *somSelf, 
  55.                                                                     Environment *ev)
  56. {
  57.     ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
  58.     ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarGetDependeeMenuBar");
  59.  
  60.     return _mbDependentUpon;
  61. }
  62.  
  63. SOM_Scope void  SOMLINK ODRootFrameMenuBarSetOwner(ODRootFrameMenuBar *somSelf, 
  64.                                                     Environment *ev, 
  65.                                                    ODFrame* frame)
  66. {
  67.     ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
  68.     ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarSetOwner");
  69.  
  70.     // This class only inherits menu items from one menu.  If you need a menu to
  71.     //   inherit menu items from multiple menus, then you'd probably want to 
  72.     //   create a new subclass of the ODMenuBar class that manages the 
  73.     //   dependencies as you like.
  74.     _fOwnerFrame = frame;
  75. }
  76.  
  77. SOM_Scope void  SOMLINK ODRootFrameMenuBarAdjustRootMenus(ODRootFrameMenuBar *somSelf, 
  78.                                                            Environment *ev, 
  79.                                                           ODMenuID menuID, 
  80.                                                           ODFrame* frame)
  81. {
  82.     ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
  83.     ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarAdjustRootMenus");
  84.  
  85.     // This procedure could adjust the menus itself or it could call a method of the
  86.     //   part or a part's extension.  If calling the part, this class could be paired
  87.     //   with a part, or a multiple inheritance could be used to add a generic method
  88.     //   to the part which can be called.  A final option is to have this routine use 
  89.     //   SOM techniques to confirm that the part has a method with the expected 
  90.     //   name and then call that method.
  91.     // Note: this method could be pure virtual too and parts could be required to
  92.     //   subclass this class and method to provide its prefered technique to 
  93.     //   handle this as it likes.
  94.     // The approach chosen by the ODActiveFrameMenuBar class is to call
  95.     //   the AdjustMenus method of the part.  To keep this sample simple, 
  96.     //   I'll just make this method pure virtual, and allow a subclass to handle
  97.     //   it how they prefer.  That means, if a part uses an instance of this 
  98.     //   class (without subclassing it), they will not be able to adjust menu
  99.     //   items contributed by the root frame.
  100. }
  101.  
  102. SOM_Scope void  SOMLINK ODRootFrameMenuBarsomInit(ODRootFrameMenuBar *somSelf)
  103. {
  104.     ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
  105.     ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarsomInit");
  106.  
  107.     ODRootFrameMenuBar_parent_ODMenuBar_somInit(somSelf);
  108.     _mbDependentUpon  = kODNULL;
  109.     _fInRecursion1 = kODFalse;
  110.     //_fSynchedChangeNumber = 0;
  111. }
  112.  
  113. SOM_Scope ODBoolean  SOMLINK ODRootFrameMenuBarHandleEvent(ODRootFrameMenuBar *somSelf, 
  114.                                                               Environment *ev, 
  115.                                                              ODEventData* event)
  116. {
  117.     ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
  118.     ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarHandleEvent");
  119.  
  120.     switch (event->msg) {
  121.     case WM_COMMAND:
  122.     case WM_HELP:
  123.     case WM_DRAWITEM:
  124.        {
  125.           SHORT command = SHORT1FROMMP(event->mp1);
  126.           SHORT commandx = SHORT2FROMMP(event->mp1);
  127.           if ( (command>=ODMENUID_ROOTPART_FIRST) &&
  128.                (command< ODMENUID_ROOTPART_LAST)) {
  129.              if (_fOwnerFrame) {
  130.                 return _fOwnerFrame->GetPart( ev)->HandleEvent( ev, event, _fOwnerFrame, (ODFacet*)kODNULL);
  131.              } else {
  132.                 // We require that the owning frame to be set in this class.
  133.                 //   This could be rewritten to determine from which ODWindow's
  134.                 //   menu this was generated.  Then figure out the root frame of
  135.                 //   that window and then the part of that frame.  It seems much
  136.                 //   easier though to just have that frame set associate an owner
  137.                 //   frame with each of menu.
  138.  
  139.                 return kODFalse;  // not processed.  Someone forgot to set the
  140.                                        //   owner of this menu.
  141.              } /* endif */
  142.           } else {
  143.              // The menuid's don't seem to be in the range of the root part, so
  144.              //   we'll just pass this event on to our dependee menu.  If this
  145.              //   class supported multiple dependee's, this would be a bit
  146.              //   more complicated.
  147.              if (_mbDependentUpon) {
  148.                 #ifdef NOREMAPPING
  149.                    return _mbDependentUpon->HandleEvent(ev, event );
  150.                 #else
  151.                    SHORT commandx = SHORT2FROMMP(event->mp1);
  152.                    ODEventData oded = *event;
  153.                    oded.mp1 = MPFROM2SHORT( somSelf->GetOldMenuID(ev, command), commandx );
  154.                    return _mbDependentUpon->HandleEvent(ev, &oded );
  155.                 #endif
  156.              } /* endif */
  157.           } /* endif */
  158.        }
  159.        break;
  160.     case WM_INITMENU:
  161.        {
  162.           ODMenuID menuID = SHORT1FROMMP(event->mp1);
  163.           somSelf->UpdateMenuDependencyChain( ev, menuID);
  164.  
  165.           {
  166.              ODPlatformWindow hwndMenu = HWNDFROMMP(event->mp2);
  167.              if (hwndMenu) {
  168.                 somSelf->UpdateMenuWindowTree( ev, hwndMenu, menuID);
  169.                 return kODTrue;
  170.              } /* endif */
  171.           }
  172.        }
  173.        break;
  174.     default:
  175.       break;
  176.     } /* endswitch */
  177.     return kODFalse;  // not processed
  178. }
  179.  
  180. SOM_Scope void  SOMLINK ODRootFrameMenuBarUpdateMenuDependencyChain(ODRootFrameMenuBar *somSelf, 
  181.                                                                      Environment *ev, 
  182.                                                                     ODMenuID menuID)
  183. {
  184.     ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
  185.     ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarUpdateMenuDependencyChain");
  186.  
  187.     if (_fInRecursion1) {
  188.        // We're already in this procedure.  There is probably some sort of recursion.
  189.        //   We'll just return out to avoid infinite recursion.  I do consider it to
  190.        //   be ISV programmer error if we have recursion, but the issues are fairly
  191.        //   complex here and the documentation is still weak, so I will not do anything
  192.        //   so unsavory as throwing an exception. (jlc 10-94)
  193.     } else {
  194.        _fInRecursion1 = kODTrue;
  195.        try {
  196.           ODMenuBar * mb = _mbDependentUpon;
  197.        
  198.           if (mb) {
  199.              // For some parts this code may need to be subclassed or
  200.              //    rewritten.  By calling UMDC() below with
  201.              //    the same menuID value that this method received, this
  202.              //    code is assuming that the menu id's haven't been
  203.              //    renumbered and that menu items haven't been moved
  204.              //    around.   This is probably rarely occuring though.
  205.              //    
  206.              #ifdef NOREMAPPING
  207.                 mb->UpdateMenuDependencyChain( ev, menuID);
  208.              #else
  209.                 mb->UpdateMenuDependencyChain( ev, somSelf->GetOldMenuID(ev, menuID) );
  210.              #endif
  211.           } else {
  212.              // this clause will be called if the owner has accidentally 
  213.              //   forgotten to call SetDependeeMenuBar() or this menu
  214.              //   simply doesn't have a dependee menu bar.  The later
  215.              //   might occur if the root frame part has choosen to 
  216.              //   provide a totally original menu.
  217.           } /* endif */
  218.        
  219.           somSelf->AdjustRootMenus( ev, menuID, _fOwnerFrame );
  220.        } /* end try */
  221.        catch ( ... ) {
  222.           _fInRecursion1 = kODFalse;
  223.           throw;
  224.        } /* end catch */
  225.        _fInRecursion1 = kODFalse;
  226.     } /* endif */
  227. }
  228.  
  229. SOM_Scope void  SOMLINK ODRootFrameMenuBarsomUninit(ODRootFrameMenuBar *somSelf)
  230. {
  231.     ODRootFrameMenuBarData *somThis = ODRootFrameMenuBarGetData(somSelf);
  232.     ODRootFrameMenuBarMethodDebug("ODRootFrameMenuBar","ODRootFrameMenuBarsomUninit");
  233.  
  234.     Environment *ev = somGetGlobalEnvironment();
  235.     if (_mbDependentUpon) {
  236.        _mbDependentUpon->DependentMenuBarRemoved( ev, somSelf);
  237.     } /* endif */
  238.     ODRootFrameMenuBar_parent_ODMenuBar_somUninit(somSelf);
  239. }
  240.  
  241.