home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Developer University / DUProjects / Mnu / Sources / Part.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  3.2 KB  |  141 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 1 $
  2. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //================================================================================
  5. #ifndef PART_H
  6. #include "Part.h"
  7. #endif
  8.  
  9. #ifndef DEFINES_K
  10. #include "Defines.k"
  11. #endif
  12.  
  13. #ifndef BINDING_K
  14. #include "Binding.k"
  15. #endif
  16.  
  17. #ifndef FRAME_H
  18. #include "Frame.h"
  19. #endif
  20.  
  21. // ----- Framework Layer -----
  22. #ifndef FWPRESEN_H
  23. #include "FWPresen.h"        // FW_CPresentation
  24. #endif
  25.  
  26. #ifndef FWUTIL_H
  27. #include "FWUtil.h"            // FW_Beep()
  28. #endif
  29.  
  30. #ifndef FWABOUT_H
  31. #include "FWAbout.h"        //::FW_About()
  32. #endif
  33.  
  34. // ----- OS Layer -----
  35. #ifndef   FWRESFIL_H
  36. #include "FWResFil.h"        // FW_CResourceFile
  37. #endif
  38.  
  39. #ifndef FWMENU_H
  40. #include "FWMenu.h"            // FW_CMenuBar, FW_CPullDownMenu
  41. #endif
  42.  
  43. #ifndef FWCFMRES_H
  44. #include "FWCFMRes.h"        // FW_CSharedLibraryResourceFile
  45. #endif
  46.  
  47. #ifndef FWEVENT_H
  48. #include "FWEvent.h"        // FW_CMenuEvent
  49. #endif
  50.  
  51. //==============================================================================
  52. #ifdef FW_BUILD_WIN16
  53.     extern HANDLE far gWinInstance;        // Initialized by LibMain
  54. #endif
  55.  
  56. #ifdef FW_BUILD_MAC
  57. #pragma segment Mnu
  58. #endif
  59.  
  60. FW_DEFINE_AUTO(CMnuPart)
  61. //==============================================================================
  62. CMnuPart::CMnuPart(ODPart* odPart)
  63.   :    FW_CPart(odPart, FW_gInstance, kPartInfoID),
  64.     fPresentation(NULL)
  65. {
  66. }
  67.  
  68. //--------------------------------------------------------------------------------
  69. CMnuPart::~CMnuPart()
  70. {
  71. }
  72.  
  73. //--------------------------------------------------------------------------------
  74. void 
  75. CMnuPart::Initialize(Environment* ev)    // Override
  76. {
  77.     FW_CPart::Initialize(ev);
  78.     const ODType kMainPresentation = "Apple:Presentation:Mnu";
  79.     fPresentation = RegisterPresentation(ev, kMainPresentation, true, NULL);
  80.     FW_CSharedLibraryResourceFile resFile(ev);
  81.     GetMenuBar(ev)->InitializeFromResource(ev, kMenuBarID);
  82. }
  83.  
  84. //--------------------------------------------------------------------------------
  85. FW_Boolean 
  86. CMnuPart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, 
  87.                                      FW_Boolean hasMenuFocus,
  88.                                      FW_Boolean isRoot)    // Override
  89. {
  90.     if (hasMenuFocus) {    
  91.         menuBar->EnableCommand(ev, cItemOneCommand, true);
  92.         menuBar->EnableCommand(ev, cItemTwoCommand, true);
  93.     }
  94.     return FALSE;
  95. }
  96.  
  97. //--------------------------------------------------------------------------------
  98. FW_Boolean 
  99. CMnuPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)    // Override
  100. {
  101.     FW_Boolean menuHandled = true;
  102.     ODCommandID commandID = theMenuEvent.GetCommandID(ev);
  103.     
  104.     switch (commandID)
  105.     {
  106.         case kODCommandAbout:
  107.             ::FW_About(ev, this, kAbout);
  108.             break;
  109.  
  110.         case cItemOneCommand:
  111.             fPresentation->Invalidate(ev);
  112.             break;
  113.  
  114.         case cItemTwoCommand:
  115.             fPresentation->Invalidate(ev);
  116.             break;
  117.  
  118.         default:
  119.             menuHandled = false;
  120.     }
  121.     return menuHandled;
  122. }
  123.  
  124. //--------------------------------------------------------------------------------
  125. FW_CFrame* 
  126. CMnuPart::NewFrame(Environment* ev, ODFrame* odFrame,
  127.                         FW_CPresentation* presentation, FW_Boolean fromStorage)    // Override
  128. {
  129.     FW_UNUSED(presentation);
  130.     FW_UNUSED(fromStorage);
  131.     return FW_NEW(CMnuFrame, (ev, odFrame, presentation, this) );
  132. }
  133.  
  134. //------------------------------------------------------------------------------
  135. FW_CContent* 
  136. CMnuPart::NewPartContent(Environment* ev)
  137. {
  138.     return NULL;
  139. }
  140.  
  141.