home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / visbuild / rapsheet / cnrpopmh.cpp next >
Encoding:
C/C++ Source or Header  |  1996-02-16  |  4.6 KB  |  91 lines

  1. /******************************************************************************
  2. * .FILE:        cnrpopmh.cpp                                                  *
  3. *                                                                             *
  4. * .DESCRIPTION: Handler that customizes the popup menu for a container.       *
  5. *               When the mouse is clicked over a container object, the        *
  6. *               menu items identified in the aCnrMenuItemList parm are        *
  7. *               deleted from the popup menu.  When the mouse is clicked       *
  8. *               over the background of the container itself, the menu         *
  9. *               items identified in the aCnrObjMenuItemList parm are          *
  10. *               deleted from the popup menu.  All changes to the popup        *
  11. *               menu are undone when the menu terminates.                     *
  12. *                                                                             *
  13. * .CLASSES:     CnrPopupMenuHandler                                           *
  14. *                                                                             *
  15. * .COPYRIGHT:                                                                 *
  16. *    Licensed Material - Program-Property of IBM                              *
  17. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  18. *                                                                             *
  19. * .DISCLAIMER:                                                                *
  20. *   The following [enclosed] code is sample code created by IBM               *
  21. *   Corporation.  This sample code is not part of any standard IBM product    *
  22. *   and is provided to you solely for the purpose of assisting you in the     *
  23. *   development of your applications.  The code is provided 'AS IS',          *
  24. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  25. *   arising out of your use of the sample code, even if they have been        *
  26. *   advised of the possibility of such damages.                               *
  27. *                                                                             *
  28. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  29. *                                                                             *
  30. ******************************************************************************/
  31. #include <itrace.hpp>
  32. #include <ivseq.h>
  33. #include <isubmenu.hpp>
  34. #include "cnrpopmh.hpp"            //CnrPopupMenuHandler
  35.  
  36. //*******************************************************************
  37. // Constructor
  38. //*******************************************************************
  39. CnrPopupMenuHandler :: CnrPopupMenuHandler(
  40.                              IVSequence<unsigned long>* aCnrObjMenuItemList,
  41.                              IVSequence<unsigned long>* aCnrMenuItemList) :
  42.      ICnrMenuHandler(),
  43.      iCnrObjMenuItemList(aCnrObjMenuItemList),
  44.      iCnrMenuItemList(aCnrMenuItemList)
  45. {
  46. }
  47.  
  48. //*******************************************************************
  49. // Destructor
  50. //*******************************************************************
  51. CnrPopupMenuHandler :: ~CnrPopupMenuHandler()
  52. {
  53. }
  54.  
  55. //*******************************************************************
  56. // menuShowing()
  57. //*******************************************************************
  58. Boolean CnrPopupMenuHandler::menuShowing(IMenuEvent& menuEvent,
  59.                                          ISubmenu& popupAboutToShow)
  60. {
  61.      IContainerObject* popupObject = popupMenuObject();
  62.      unsigned long menuItemId;
  63.  
  64.      IFUNCTRACE_DEVELOP();
  65.  
  66.      if (popupObject)     //a popup menu was requested for a container object
  67.      {
  68.          /* delete all the menu items that apply to the container */
  69.          IVSequence<unsigned long>::Cursor aCursor(*iCnrMenuItemList);
  70.          forCursor(aCursor)
  71.          {
  72.             menuItemId = iCnrMenuItemList->elementAt(aCursor);
  73.             popupAboutToShow.deleteItem(menuItemId);
  74.          }
  75.      }
  76.      else               //a popup menu was requested for the container itself
  77.      {
  78.          /* delete all the menu items that apply to a container object */
  79.          IVSequence<unsigned long>::Cursor aCursor(*iCnrObjMenuItemList);
  80.          forCursor(aCursor)
  81.          {
  82.             menuItemId = iCnrObjMenuItemList->elementAt(aCursor);
  83.             popupAboutToShow.deleteItem(menuItemId);
  84.          }
  85.      }
  86.  
  87.      return true;   //undo changes to popupAboutToShow when
  88.                     //IMenuHandler::menuEnded is called after the
  89.                     //menu terminates.
  90. }
  91.