home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / CALib & You… / Source / CALib / Implementation / UI / CAMenu.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-07  |  2.8 KB  |  139 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CAMenu.cpp
  3.  
  4.     Contains:    Container Application Library source - Menuing interface
  5.  
  6.     Written by:    Steve Foley, Greg Ames, David Nelson
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <5>     4/23/95    RB        Implemented CAAdjustMenus()
  13.          <4+>     2/28/95    SJF        Added debug stuff to API calls
  14.          <4>     2/13/95    SJF        Interim checkin to update project database
  15.          <3)    12/15/94    SJF        change somGetGlobalEnvironment to _gpProxyShell->GetGlobalEnvironment
  16.          <2>    12/12/94    SJF        Clean up compile after adding TCAProxyShell
  17.          <1>    10/30/94    GCA,DHN    All mods to make project compile with no
  18.                                      errors under OpenDoc b1 (with SOM).
  19.          <0>    10/16/94    SJF        first written
  20.          
  21.     To Do:
  22. */
  23.  
  24. #ifndef _CASESSN_
  25. #include "CASessn.h"
  26. #endif
  27.  
  28. #ifndef _CAERROR_
  29. #include "CAError.h"
  30. #endif
  31.  
  32. #ifndef SOM_ODWindowState_xh
  33. #include "WinStat.xh"
  34. #endif
  35.  
  36. #ifndef SOM_ODWindow_xh
  37. #include <Window.xh>
  38. #endif
  39.  
  40. #ifndef SOM_ODMenuBar_xh
  41. #include <MenuBar.xh>
  42. #endif
  43.  
  44. #ifndef SOM_ODDispatcher_xh
  45. #include <Disptch.xh>
  46. #endif
  47.  
  48. #ifndef SOM_ODFoci_xh
  49. #include <Foci.xh>
  50. #endif
  51. #ifndef _ODUTILS_
  52. #include <ODUtils.h>
  53. #endif
  54.  
  55. #ifndef _CADISPTCH_
  56. #include "CADisptch.h"
  57. #endif
  58.  
  59. #pragma segment CALib
  60.  
  61.  
  62. //-------------------------------------------------------------------------
  63. // Menu ***
  64. //-------------------------------------------------------------------------
  65.  
  66. //-------------------------------------------------------------------------
  67. // CASetBaseMenuBar - The CA calls CASetBaseMenuBar with the complete
  68. // application menubar.  We strip this of non-system menus before
  69. // setting the base menu bar of the window state.
  70. pascal    void        CASetBaseMenuBar( Handle hMenuBar )
  71. {
  72.     CA_TRY
  73.     
  74.         gCASession->InstallMenuBar( (ODPlatformMenuBar) hMenuBar );
  75.  
  76.     CA_CATCH_ALL
  77.     CA_ENDTRY
  78.     
  79. }
  80.  
  81.  
  82. //-------------------------------------------------------------------------
  83.  
  84. pascal    void        CAAdjustMenus()
  85. {
  86.     CA_TRY
  87.     
  88.         gCASession->UpdateMenus ();
  89.  
  90.     CA_CATCH_ALL
  91.     CA_ENDTRY
  92.     
  93. }
  94.  
  95.  
  96. //-------------------------------------------------------------------------
  97.  
  98. pascal    void        CARegisterCommand( CACommandID command, CAMenuID menu,
  99.                         CAMenuItemID menuItem )
  100. {
  101.  
  102.     CA_TRY
  103.  
  104.         gCASession->RegisterCommand( (ODCommandID)command, (ODMenuID)menu,
  105.                                      (ODMenuItemID)menuItem );
  106.     
  107.     CA_CATCH_ALL
  108.     CA_ENDTRY
  109.  
  110. }
  111.  
  112.  
  113. //-------------------------------------------------------------------------
  114.  
  115. pascal    Boolean        CADispatchMenuEvent( EventRecord* event, long menuSelection )
  116. {
  117.     Environment*        ev = gCASession->GetEV();
  118.     EventRecord            newEventRecord;
  119.     Boolean                result = false;
  120.     
  121.     if (event)
  122.         newEventRecord = *event;
  123.     
  124.     // Store the menuSelection in event->message for the OD dispatcher
  125.     newEventRecord.what = kODEvtMenu;
  126.     newEventRecord.message = menuSelection;
  127.     
  128.     CA_TRY
  129.     
  130.         result = gCASession->GetCADispatcher()->DispatchMenuEvent((ODEventData*) &newEventRecord);
  131.         
  132.     CA_CATCH_ALL
  133.     CA_ENDTRY
  134.             
  135.     return result;
  136. }
  137.  
  138.  
  139.