home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / isubmenu.hp_ / ISUBMENU.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  7.4 KB  |  161 lines

  1. #ifndef _ISUBMENU_
  2.   #define _ISUBMENU_
  3. /**************************************************************/
  4. /* FILE NAME: isubmenu.hpp                                    */
  5. /*                                                            */
  6. /* DESCRIPTION:                                               */
  7. /*    Declaration of the class:                               */
  8. /*      ISubMenu - this is a wrapper for any menu.            */
  9. /*                 It can be used to make temporary changes   */
  10. /*                 to the menu that will be undone when       */
  11. /*                 the menu is no longer visible.             */
  12. /*                                                            */
  13. /* COPYRIGHT:                                                 */
  14. /*   Licensed Materials - Property of IBM                     */
  15. /*   (c) Copyright IBM Corporation 1992, 1993                 */
  16. /*   US Government Users Restricted Rights - Use duplication  */
  17. /*   or disclosure restricted by GSA ADP Schedule Contract    */
  18. /*   with IBM Corp.                                           */
  19. /*                                                            */
  20. //   $Log:   G:/IBMCLASS/IBASEAPP/VCS/ISUBMENU.HPV  $                                                    */
  21. // 
  22. //    Rev 1.5   26 Oct 1992 10:07:22   HARPERSP
  23. // Updates for documentation.
  24. // 
  25. //    Rev 1.2   08 Oct 1992 09:25:26   HARPERSP
  26. // First update using $Log$
  27. // Had to re-PUT because comment prefix was wrong.
  28. /*                                                            */
  29. /**************************************************************/
  30.  
  31. #ifndef _IMENU_
  32. #include <imenu.hpp>
  33. #endif
  34.  
  35. #include <iqueseq.h>
  36. #include <iqueue.h>
  37.  
  38. // Forward declarations for other classes
  39. class ISubMenu;
  40.  
  41. // IRestoreItem is 
  42. // used for keeping a collection of changes made
  43. // to the menu.
  44. // It's declared in isubmenu.cpp.
  45. class IRestoreItem;
  46.  
  47. class IWindowHandle;
  48. class IMenuItem;
  49.  
  50. typedef IQueue<IRestoreItem*> RefreshQueueType;
  51.  
  52. class ISubMenu : public IMenu
  53. {
  54.  
  55. /**********************************************************************
  56. * The IMenuHandler creates a ISubMenu wrapper whenever a menu is      *
  57. * about to be displayed. It then calls the menuShowing() callback     *
  58. * passing a pointer to the ISubMenu object.                           *
  59. * Within the menuShowing() callback you can use ISubMenu member       *
  60. * functions to alter the menu.                                        *
  61. * These changes are automatically undone by the IMenuHandler once     *
  62. * the menu is no longer visible.                                      *
  63. *                                                                     *
  64. * Example:                                                            *
  65. *                                                                     *
  66. *  void MyHandler :: menuShowing(const IMenuEvent& mnEvt,             *
  67. *                               ISubMenu* psmnAboutToShow)            *
  68. *  {                                                                  *
  69. *                                                                     *
  70. *     switch (psmnAboutToShow->id()) {                                *
  71. *                                                                     *
  72. *      case ID_MENU1:                                                 *
  73. *        psmnAboutToShow->addSeparator();                             *
  74. *        if (defaultABMActive()) {                                    *
  75. *          psmnAboutToShow->addItem(mni_AltABM);                      *
  76. *          psmnAboutToShow->disableItem(ID_TITLE_TEXT);               *
  77. *        } else {                                                     *
  78. *          psmnAboutToShow->addItem(mni_DefABM);                      *
  79. *          psmnAboutToShow->checkItem(ID_TITLE_TEXT);                 *
  80. *        }                                                            *
  81. *                                                                     *
  82. *         ...                                                         *
  83. *                                                                     *
  84. **********************************************************************/
  85.  
  86.   typedef IMenu inherited;
  87.  
  88.   public:
  89.  
  90. /*------------------ CONSTRUCTORS/DESTRUCTORS -------------------------
  91. |  There is 1 way to construct instances of this class:               |
  92. |     ISubMenu(IWindowHandle)                                         |
  93. |                                                                     |
  94. |  You should not have to construct any instances of this class       |
  95. |  since the IMenuHandler::dipatchHandlerEvent() does this for you.   |
  96. |                                                                     |
  97. ---------------------------------------------------------------------*/
  98.  
  99.      ISubMenu(IWindowHandle subMenuHandle);
  100.      ~ISubMenu();
  101.  
  102. /*---------------------- OVERRIDES ------------------------------------
  103. | The following IMenu member functions are overridden.                |
  104. | In each of its overriden versions of these functions                |
  105. | ISubMenu actually calls each of the IMenu versions of the functions |
  106. | to cause the menu to change, then it stores information about       |
  107. | how the menu was changed so that it can be undone.                  |
  108. |                                                                     |
  109. | checkItem                                                           |
  110. | uncheckItem                                                         |
  111. | enableItem                                                          |
  112. | disableItem                                                         |
  113. | addItem                                                             |
  114. | addSeparator                                                        |
  115. | deleteItem                                                          |
  116. |                                                                     |
  117. ---------------------------------------------------------------------*/
  118.  
  119.      virtual void checkItem(unsigned long itemId);
  120.      virtual void uncheckItem(unsigned long itemId);
  121.  
  122.      virtual void enableItem(unsigned long itemId);
  123.      virtual void disableItem(unsigned long itemId);
  124.  
  125.      virtual void addItem(const IMenuItem& mniNewItem);
  126.  
  127.      virtual void addSeparator(unsigned long newItemId = 0);
  128.  
  129.      virtual void deleteItem(unsigned long itemId);
  130.  
  131. /*---------------------- ACCESSORS ------------------------------------
  132. | refresh - called by IMenuHandler::dispatchHandlerEvent() to         |
  133. |           undo all the changes made to the ISubMenu.                |
  134. |           You should not need to ever call refresh().               |
  135. ---------------------------------------------------------------------*/
  136.  
  137.      void refresh();
  138.  
  139. /*----------------------- PRIVATE -----------------------------------*/
  140.   private:
  141.  
  142.      // addItem and addSeparator are not applicable
  143.      // to ISubMenu since the subMenuId is not needed.
  144.      // These functions are declared here but not defined.
  145.      virtual void  addItem(const IMenuItem& newItem,
  146.                            unsigned long subMenuId) {;}
  147.      virtual void  addSeparator(unsigned long newItemId,
  148.                                 unsigned long subMenuId) {;}
  149.  
  150.      ISubMenu(const IMenu&);
  151.      ISubMenu &operator=(const IMenu&);
  152.  
  153.      RefreshQueueType* pRefreshQueue;
  154.  
  155.      RefreshQueueType* getQueue();
  156.      void refreshItem(IRestoreItem*);
  157.  
  158. };
  159.  
  160. #endif
  161.