home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ibmodf.zip / CNTNRPRT.ZIP / CNTNRRMB.CPP < prev    next >
C/C++ Source or Header  |  1994-12-09  |  4KB  |  123 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_cntnrrmb_Source
  15. #define SOM_Module_cntnrrmb_Source
  16. #endif
  17. #define ODContainerRootFrameMenuBar_Class_Source
  18. #define VARIABLE_MACROS
  19.  
  20. #define INCL_DOSMODULEMGR
  21. #define INCL_DOSRESOURCES
  22. #define INCL_ODFRAME
  23.  
  24. #include "CntnrRMB.xih"
  25.  
  26. #ifndef SOM_ContainerPart_xh
  27.    #include <CntnrPrt.xh>
  28. #endif
  29.  
  30. #include <os2.h>
  31. #include <stdio.h>
  32.  
  33. #ifndef _CNTNRRES_
  34.    #include "cntnrres.h"
  35. #endif
  36.  
  37. #include "debug.hpp"
  38. #define THISDLL "cntnrprt"
  39.  
  40. SOM_Scope void  SOMLINK ODContainerRootFrameMenuBarsomInit(ODContainerRootFrameMenuBar *somSelf)
  41. {
  42.     ODContainerRootFrameMenuBarData *somThis = ODContainerRootFrameMenuBarGetData(somSelf);
  43.     ODContainerRootFrameMenuBarMethodDebug("ODContainerRootFrameMenuBar","ODContainerRootFrameMenuBarsomInit");
  44.  
  45.     ODContainerRootFrameMenuBar_parent_ODRootFrameMenuBar_somInit(somSelf);
  46.  
  47.     _DemoOpenCount = 0;
  48. }
  49.  
  50.  
  51. SOM_Scope void  SOMLINK ODContainerRootFrameMenuBarAdjustRootMenus(ODContainerRootFrameMenuBar *somSelf, 
  52.                                                                     Environment *ev, 
  53.                                                                    ODMenuID menuID, 
  54.                                                                    ODFrame* frame)
  55. {
  56.     ODContainerRootFrameMenuBarData *somThis = ODContainerRootFrameMenuBarGetData(somSelf);
  57.     ODContainerRootFrameMenuBarMethodDebug("ODContainerRootFrameMenuBar","ODContainerRootFrameMenuBarAdjustRootMenus");
  58.  
  59.    ODMenuBar *dmb  = somSelf->GetDependeeMenuBar(ev );
  60.    //somSelf->ClearMenuBarTree( ev);
  61.    somSelf->RemoveMenu( ev, ODMENUID_ROOT);
  62.    somSelf->AddMenuBLast( ev, dmb, ODMENUID_ROOT );
  63.  
  64.    #ifdef REMAPPING
  65.       // if we do remapping, this is the place to do it against somSelf.
  66.    #endif
  67.  
  68.    HMODULE hmodDLL;
  69.    if (DosQueryModuleHandle( THISDLL, &hmodDLL)) {
  70.       beepprintf( "Isn't my DLL (%s) loaded?", THISDLL );   
  71.    } /* endif */
  72.    ODPlatformMenuBar   menuBar;
  73.  
  74.    DosGetResource2( hmodDLL
  75.                   , RT_MENU
  76.                   , RESID_ROOTMENU
  77.                   , (PPVOID)&menuBar
  78.                   );
  79.    int id = somSelf->GetFirstMenuID( ev, ODMENUID_ROOT );
  80.    if (id) {
  81.       id = somSelf->GetLastMenuID( ev, id );
  82.       if (id) somSelf->AddMenuAfter( ev, kODNULL, menuBar, frame->GetPart( ev), id );
  83.    } /* endif */
  84.    DosFreeResource( (PVOID)menuBar );
  85.  
  86.    #if 1
  87.       // for demo purposes, we'll do some wacky things here with
  88.       //   menu item text, check state, and enablement.
  89.  
  90.       if ((menuID==ODMENUID_ALL) || (menuID==IDMS_DOCUMENT)) {
  91.          // I've chosen only to update these menu items if
  92.          //    I their menu is opened or we're requested to
  93.          //    update the whole tree.  The intent of this
  94.          //    check is to improve efficiency.
  95.          // This type of check isn't possible in part::AdjustMenus
  96.          //    because that reference method does not have a way 
  97.          //    to know which menu is opening.  As a result, it must 
  98.          //    update all menus.  If one wants to be selective
  99.          //    in updating active part menu items, one will need
  100.          //    to create their own menu bar class, or subclass the
  101.          //    ODActiveFrameMenuBar class and particularly the
  102.          //    AdjustMenus method.
  103.          //
  104.  
  105.          _DemoOpenCount++;
  106.          {
  107.             char stagestring[40];
  108.             sprintf( stagestring, "Menu open count: %d", _DemoOpenCount);
  109.             somSelf->SetItemString( ev, IDMR_ROOTITEM2, stagestring);
  110.          }
  111.       
  112.          // please forgive the downcast.  It is expedient and can be
  113.          //   avoided if deemed necessary.
  114.          ContainerPart * cpart = (ContainerPart*)frame->GetPart( ev);
  115.       
  116.          long DemoState = cpart->GetDemoState( ev);
  117.          somSelf->CheckItem( ev, IDMR_ROOTITEM2, (DemoState & 1) );
  118.          somSelf->EnableItem( ev, IDMR_ROOTITEM2, (DemoState & 2) );
  119.       } /* endif */
  120.    #endif
  121. }
  122.  
  123.