home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / VISBUILD / RAPSHEET / SUSCNRMH.CPP < prev    next >
Text File  |  1995-05-12  |  5KB  |  132 lines

  1. //****************************************************************************
  2. // Additional Member Functions for ISuspectCnrView - (suscnrmh.cpp)          *
  3. //                                                                           *
  4. // COPYRIGHT: Copyright (C) International Business Machines Corp., 1994,1995 *
  5. //                                                                           *
  6. // DISCLAIMER OF WARRANTIES:                                                 *
  7. //   The following [enclosed] code is sample code created by IBM             *
  8. //   Corporation.  This sample code is not part of any standard IBM product  *
  9. //   and is provided to you solely for the purpose of assisting you in the   *
  10. //   development of your applications.  The code is provided "AS IS",        *
  11. //   without warranty of any kind.  IBM shall not be liable for any damages  *
  12. //   arising out of your use of the sample code, even if they have been      *
  13. //   advised of the possibility of such damages.                             *
  14. //****************************************************************************
  15. //NOTE: WE RECOMMEND USING A FIXED-SPACE FONT TO LOOK AT THE SOURCE.
  16. //
  17.  
  18. #ifndef _ITRACE_
  19. #include <itrace.hpp>
  20. #endif
  21.  
  22. #include <istring.hpp>
  23.  
  24. #ifndef _IVSEQ_
  25. #include <ivseq.h>
  26. #endif
  27.  
  28. #ifndef _IPOPMENU_
  29. #include <ipopmenu.hpp>
  30. #endif
  31.  
  32. #ifndef _ISUSPECTCNRVIEW_
  33. #include <sspctcnr.hpp>
  34. #endif
  35.  
  36. #ifndef _ISUSPECT_
  37. #include <isuspect.hpp>
  38. #endif
  39.  
  40. #include "suscnrmh.hpp"            //ISuspectCnrMenuHandler
  41.  
  42. //***************************************************************************
  43. // Class:   ISuspectCnrMenuHandler
  44. //
  45. // Purpose: Provides popup menu support for the suspect container view,
  46. //          ISuspectCnrView, which supports extended selection.
  47. //
  48. //***************************************************************************
  49.  
  50. //*******************************************************************
  51. // Manager Member Functions (Not Part Actions)
  52. //*******************************************************************
  53. ISuspectCnrMenuHandler :: ISuspectCnrMenuHandler(
  54.    IVBContainerControl< ISuspect *, 
  55.                         IVSequence<ISuspect *>,
  56.                         ISuspectCnrViewSuspectCnrCnrObj > * aVBCnr,
  57.    IPopUpMenu * aSuspectCnrMenu,
  58.    IVSequence<ISuspect *> *aSuspectCollection) : ICnrMenuHandler(),
  59.      iCurrentMenu (none)
  60. {
  61.    iCnr = aVBCnr;
  62.    iPopupMenu = aSuspectCnrMenu;
  63.    iTargetCollection = aSuspectCollection;
  64. }
  65.  
  66. ISuspectCnrMenuHandler :: ~ISuspectCnrMenuHandler()
  67. {
  68. }
  69.  
  70. Boolean ISuspectCnrMenuHandler::makePopUpMenu(IMenuEvent& menuEvent)
  71. {
  72.      IFUNCTRACE_DEVELOP();
  73.  
  74.      ISuspectCnrViewSuspectCnrCnrObj *pPopupObject = (ISuspectCnrViewSuspectCnrCnrObj *)popupMenuObject();
  75.      if (pPopupObject)     //a popup menu was requested for a container object
  76.      {
  77.          if (iCurrentMenu != element) 
  78.          {
  79.             iPopupMenu->deleteItem(WND_ISuspectCnrView_NewMenuItem);
  80.             iPopupMenu->deleteItem(WND_ISuspectCnrView_FindMenuItem);
  81.  
  82.             if (iCurrentMenu == cnr) 
  83.             {
  84.                iPopupMenu->addText(WND_ISuspectCnrView_OpenMenuItem, VBSTRINGRC(STRRC_ISuspectCnrView_OpenMenuItem_text));
  85.                iPopupMenu->addText(WND_ISuspectCnrView_DeleteMenuItem, VBSTRINGRC(STRRC_ISuspectCnrView_DeleteMenuItem_text));
  86.             }
  87.  
  88.             iCurrentMenu = element;
  89.          } /* endif */
  90.  
  91.          /**************************************************************************
  92.           *  Determine if the popup menu object was selected.  If it isn't, then
  93.           *  the real element that maps to it is the only target element.  If it is, 
  94.           *  prime the collection with the list of selected elements.
  95.           **************************************************************************/
  96.           try
  97.           {
  98.              if (iCnr->isSelected(pPopupObject))
  99.              {
  100.                  iCnr->selectedElements(*iTargetCollection);
  101.                  ITRACE_DEVELOP("Number of elements the popup menu applies to: " +
  102.                                 IString(iTargetCollection->numberOfElements()));
  103.              }
  104.              else
  105.              {
  106.                  if (!iTargetCollection->isEmpty())
  107.                     iTargetCollection->removeAll();
  108.                  iTargetCollection->add(((ISuspectCnrViewSuspectCnrCnrObj *)(pPopupObject))->realObject());
  109.                  ITRACE_DEVELOP("Number of elements the popup menu applies to: 1");
  110.              }
  111.           }
  112.           catch (IException& exc) {};
  113.      }
  114.      else               //a popup menu was requested for the container itself
  115.      {
  116.          if (iCurrentMenu != cnr)
  117.          {
  118.             iPopupMenu->deleteItem(WND_ISuspectCnrView_OpenMenuItem);
  119.             iPopupMenu->deleteItem(WND_ISuspectCnrView_DeleteMenuItem);
  120.  
  121.             if (iCurrentMenu == element)
  122.             {
  123.                iPopupMenu->addText(WND_ISuspectCnrView_NewMenuItem, VBSTRINGRC(STRRC_ISuspectCnrView_NewMenuItem_text));
  124.                iPopupMenu->addText(WND_ISuspectCnrView_FindMenuItem, VBSTRINGRC(STRRC_ISuspectCnrView_FindMenuItem_text));
  125.             }
  126.  
  127.             iCurrentMenu = cnr;
  128.          } /* endif */
  129.      }
  130.      return false;   //call VB handler (to show the menu at the mouse position)
  131. }
  132.