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

  1. /*
  2.  *  This file was generated by the SOM Compiler and Emitter Framework.
  3.  *  Generated using: 
  4.  *      SOM Emitter emitxtm: 2.41
  5.  */
  6.  
  7. #ifndef SOM_Module_cntnrpum_Source
  8. #define SOM_Module_cntnrpum_Source
  9. #endif
  10. #define ODPopupContainerMenu_Class_Source
  11. #define VARIABLE_MACROS
  12. #define INCL_WINWINDOWMGR
  13. #define INCL_WINERRORS
  14. #define INCL_WINMENUS
  15. #define INCL_WINMESSAGEMGR
  16. #define INCL_ODFRAME
  17.  
  18. #include <os2.h>
  19. #include "CntnrPUM.xih"
  20.  
  21. #include "CntnrPrt.xh"
  22.  
  23. #include "debug.hpp"
  24.  
  25. SOM_Scope void  SOMLINK ODPopupContainerMenuInitPopupContainerMenu(ODPopupContainerMenu *somSelf, 
  26.                                                                     Environment *ev, 
  27.                                                                    ODSession* session, 
  28.                                                                    ODFrame* frame)
  29. {
  30.     ODPopupContainerMenuData *somThis = ODPopupContainerMenuGetData(somSelf);
  31.     ODPopupContainerMenuMethodDebug("ODPopupContainerMenu","ODPopupContainerMenuInitPopupContainerMenu");
  32.  
  33.     somSelf->InitMenuBar( ev, session, (ODPlatformMenuBar*)0);
  34.     _fOwnerFrame = frame;
  35.     somSelf->SetOwner( ev, frame);  // setting this will insure that AdjustMenu will actually
  36.                                     //    dispatch WM_COMMAND messages to the appropriate part.
  37. }
  38.  
  39. #if 0
  40.    SOM_Scope void  SOMLINK ODPopupContainerMenuUnDisplay(ODPopupContainerMenu *somSelf, 
  41.                                                           Environment *ev)
  42.    {
  43.        ODPopupContainerMenuData *somThis = ODPopupContainerMenuGetData(somSelf);
  44.        ODPopupContainerMenuMethodDebug("ODPopupContainerMenu","ODPopupContainerMenuUnDisplay");
  45.    
  46.        +++++++++++++
  47.    }
  48. #endif
  49.  
  50. SOM_Scope void  SOMLINK ODPopupContainerMenusomInit(ODPopupContainerMenu *somSelf)
  51. {
  52.     ODPopupContainerMenuData *somThis = ODPopupContainerMenuGetData(somSelf);
  53.     ODPopupContainerMenuMethodDebug("ODPopupContainerMenu","ODPopupContainerMenusomInit");
  54.  
  55.     ODPopupContainerMenu_parent_ODActiveFrameMenuBar_somInit(somSelf);
  56.  
  57.     _fOwnerFrame       = 0;
  58.     //_mbDependentUpon   = 0;
  59.     _fMenuHwnd         = 0;
  60.     _fObjectHwnd       = 0;
  61. }
  62.  
  63. SOM_Scope void  SOMLINK ODPopupContainerMenuUpdateMenuDependencyChain(ODPopupContainerMenu *somSelf, 
  64.                                                                      Environment *ev, 
  65.                                                                     ODMenuID menuID)
  66. {
  67.     ODPopupContainerMenuData *somThis = ODPopupContainerMenuGetData(somSelf);
  68.     ODPopupContainerMenuMethodDebug("ODPopupContainerMenu","ODPopupContainerMenuUpdateMenuDependencyChain");
  69.  
  70.     {
  71.        ContainerPart * cp = (ContainerPart*)_fOwnerFrame->GetPart( ev );
  72.        // gross! down casting!  Oh well.
  73.  
  74.        cp->AdjustPopupMenu( ev, _fOwnerFrame, somSelf, menuID );
  75.     }
  76. }
  77.  
  78. MRESULT EXPENTRY PopUpObjectProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  79. {
  80.    MRESULT mr;
  81.    switch (msg) {
  82.    case WM_COMMAND:
  83.    case WM_HELP:
  84.    case WM_INITMENU:
  85.    case WM_CONTROL:
  86.       {
  87.          ODEventData event;
  88.          event.msg  = msg;
  89.          event.hwnd = hwnd;
  90.          event.mp1  = mp1;
  91.          event.mp2  = mp2;
  92.          event.result  = 0;
  93.          event.mpExtra = 0;
  94.          ODMenuBar *mb = (ODMenuBar *)WinQueryWindowPtr( hwnd, 0 );
  95.          if (mb) mb->HandleEvent( somGetGlobalEnvironment(), &event);
  96.          return event.result;
  97.       }
  98.       break;
  99.    default:
  100.      break;
  101.    } /* endswitch */
  102.    mr = WinDefWindowProc( hwnd, msg, mp1, mp2);
  103.    return mr;
  104. }
  105.  
  106. SOM_Scope void  SOMLINK ODPopupContainerMenuDisplay(ODPopupContainerMenu *somSelf, 
  107.                                                      Environment *ev)
  108. {
  109.     ODPopupContainerMenuData *somThis = ODPopupContainerMenuGetData(somSelf);
  110.     ODPopupContainerMenuMethodDebug("ODPopupContainerMenu","ODPopupContainerMenuDisplay");
  111.  
  112.     ERRORID err;
  113.  
  114.     if ( !_fObjectHwnd ) {
  115.        CLASSINFO ci;
  116.  
  117.        #define OWNEROBJCLASSNAME "CntnrPUMObjectClass"
  118.        WinRegisterClass( (HAB)0
  119.                             , OWNEROBJCLASSNAME
  120.                             , PopUpObjectProc
  121.                             , /*flStyle:*/0
  122.                             , /*cbWindowData:*/4
  123.                             );
  124.        err = WinGetLastError( (HAB)0);
  125.        _fObjectHwnd =  WinCreateWindow( HWND_DESKTOP,
  126.                                              OWNEROBJCLASSNAME,
  127.                                              (PSZ)"OpenDocPopUpObject",
  128.                                              0 /*WS_VISIBLE*/,
  129.                                              0,0, 0, 0,
  130.                                              /*owner:*/NULL,
  131.                                              HWND_TOP,
  132.                                              /*id:*/1,
  133.                                              /*ctldata:*/NULL,
  134.                                              /*presparams:*/NULL);
  135.        err = WinGetLastError( (HAB)0);
  136.        if (!_fObjectHwnd) {
  137.           beepprintf( "Popup menu object window creation failed: errcode=0x%x", (ULONG)err);
  138.        } /* endif */
  139.     } /* endif */
  140.     if ( _fObjectHwnd && !_fMenuHwnd) {
  141.        err = WinGetLastError( (HAB)0);
  142.        _fMenuHwnd = WinCreateWindow( /*parent:*/HWND_OBJECT,
  143.                            WC_MENU,
  144.                            (PSZ)"OpenDocPopupMenu",
  145.                            0 /*WS_VISIBLE*/,
  146.                            0,0, 0, 0,
  147.                            /*owner:*/NULL,
  148.                            HWND_TOP,
  149.                            /*id:*/1,
  150.                            /*ctldata:*/NULL,
  151.                            /*presparam:*/NULL );
  152.        err = WinGetLastError( (HAB)0);
  153.        if ( _fMenuHwnd ) {
  154.           WinSetWindowPtr( _fObjectHwnd, 0, somSelf );
  155.        } else {
  156.           beepprintf( "Popup menu window creation failed: errcode=0x%x", (ULONG)err);
  157.        } /* endif */
  158.     } /* endif */
  159.     if ( _fMenuHwnd ) {
  160.        somSelf->UpdateMenuDependencyChain( ev, ODMENUID_ALL);
  161.        somSelf->UpdateMenuWindowTree( ev, _fMenuHwnd, ODMENUID_ROOT);
  162.        ODMenuID firstid = somSelf->GetFirstMenuID( ev, ODMENUID_ROOT);
  163.        err = WinGetLastError( (HAB)0);
  164.        POINTL ptl;
  165.        if (!WinQueryMsgPos( (HAB)0, &ptl)) {
  166.           ptl.x = ptl.y = 0;
  167.        } /* endif */
  168.        err = WinGetLastError( (HAB)0);
  169.  
  170.        // I have chosen not to use the PU_POSITIONITEM flag below because
  171.        //    that also *selects* the item.  In the case of a pull right
  172.        //    menu item, that means the menu appears with the cascade
  173.        //    menu open.  I don't like that.  Instead, I've adjusted
  174.        //    the x,y values a bit so that the pointer will probably be at
  175.        //    the bottom of the popup menu. (jlc 11/94)
  176.        if (!WinPopupMenu( /*parent:*/ HWND_DESKTOP,
  177.                      /*owner:*/  _fObjectHwnd,
  178.                      /*menu:*/   _fMenuHwnd,
  179.                      /*x,y:*/    ptl.x-30, ptl.y-5, 
  180.                      /*itemid:*/ firstid,
  181.                      /*options:*/ PU_HCONSTRAIN | PU_VCONSTRAIN | /* PU_POSITIONONITEM | */
  182.                                   PU_NONE | 
  183.                                   PU_MOUSEBUTTON1 | PU_KEYBOARD    
  184.                      )) {
  185.           err = WinGetLastError( (HAB)0);
  186.           beepprintf( "WinPopupMenu failed: errcode=0x%x", (ULONG)err);
  187.        } /* endif */
  188.     } /* endif */
  189. }
  190.  
  191. SOM_Scope void  SOMLINK ODPopupContainerMenusomUninit(ODPopupContainerMenu *somSelf)
  192. {
  193.     ODPopupContainerMenuData *somThis = ODPopupContainerMenuGetData(somSelf);
  194.     ODPopupContainerMenuMethodDebug("ODPopupContainerMenu","ODPopupContainerMenusomUninit");
  195.  
  196.     if (_fMenuHwnd) WinDestroyWindow( _fMenuHwnd );
  197.     if (_fObjectHwnd) WinDestroyWindow( _fObjectHwnd );
  198.  
  199.     // the super class also keeps a copy of _mbDependentUpon, so we
  200.     //    don't have to worry about informing that menu of our disappearance.
  201.  
  202.     ODPopupContainerMenu_parent_ODActiveFrameMenuBar_somUninit(somSelf);
  203. }
  204.  
  205.