Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
4.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: menubtns.h
  8. //
  9. // Menu Buttons implementation
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef MENUBTNS_H
  13. #define MENUBTNS_H
  14. #include "toolbars.h" // for CMenuButtonsMgrImpl
  15. #include "tstring.h"
  16. class CMenuBar;
  17. // The (individual) Menu Button.
  18. typedef struct MMC_MENUBUTTON
  19. {
  20. CMenuButtonNotify* pMenuButtonNotifyClbk; // Represents the IMenuButton object
  21. // exposed to the snapin.
  22. tstring lpButtonText;
  23. tstring lpStatusText;
  24. INT idCommand; // Unique ID given by the snapin, may not be unique within
  25. // this object as there may be another snapin with same id.
  26. // The pair of (pMenuButtonNotifyClbk, idCommand) is unique.
  27. INT nCommandIDFromMenuBar; // The CMenuBar has inserted this button and has
  28. // assigned this command id. CMenuButtonsMgrImpl
  29. // can call CMenuBar methods (other than InsertMenuButton)
  30. // using this id. Also this id will be unique for this button
  31. // in this object.
  32. bool m_fShowMenu : 1; // Represents hidden state set by snapin.
  33. MMC_MENUBUTTON()
  34. {
  35. pMenuButtonNotifyClbk = NULL;
  36. lpButtonText = _T("");
  37. lpStatusText = _T("");
  38. m_fShowMenu = true;
  39. nCommandIDFromMenuBar = -1;
  40. }
  41. void SetShowMenu (bool b = true) { m_fShowMenu = b; }
  42. bool CanShowMenu () const { return (m_fShowMenu); }
  43. } MMC_MENUBUTTON;
  44. // This is the collection of all menu buttons added by snapin
  45. // as well as MMC (Action, View, Favorites).
  46. typedef std::vector<MMC_MENUBUTTON> MMC_MenuButtonCollection;
  47. // This is the collection of each IMenuButton (objecct) that snapin
  48. // has called Attach on (therefore visible).
  49. typedef std::set<CMenuButtonNotify*> MMC_AttachedMenuButtons;
  50. class CMenuButtonsMgrImpl : public CMenuButtonsMgr
  51. {
  52. public:
  53. // CMenuButtonsMgr methods
  54. virtual SC ScAddMenuButton(CMenuButtonNotify* pMenuBtnNotifyClbk,
  55. INT idCommand, LPCOLESTR lpButtonText,
  56. LPCOLESTR lpStatusText);
  57. virtual SC ScAttachMenuButton(CMenuButtonNotify* pMenuBtnNotifyClbk);
  58. virtual SC ScDetachMenuButton(CMenuButtonNotify* pMenuBtnNotifyClbk);
  59. virtual SC ScModifyMenuButton(CMenuButtonNotify* pMenuBtnNotifyClbk,
  60. INT idCommand, LPCOLESTR lpButtonText,
  61. LPCOLESTR lpStatusText);
  62. virtual SC ScModifyMenuButtonState(CMenuButtonNotify* pMenuBtnNotifyClbk,
  63. INT idCommand, MMC_BUTTON_STATE nState,
  64. BOOL bState);
  65. virtual SC ScDisableMenuButtons();
  66. virtual SC ScToggleMenuButton(BOOL bShow);
  67. public:
  68. // These methods are used the Child Frame
  69. SC ScInit(CMainFrame* pMainFrame, CChildFrame* pParentWnd);
  70. SC ScAddMenuButtonsToMainMenu();
  71. // Used by CMenuBar to notify a menu button click.
  72. SC ScNotifyMenuClick(const INT nCommandID, const POINT& pt);
  73. public:
  74. CMenuButtonsMgrImpl();
  75. virtual ~CMenuButtonsMgrImpl();
  76. private:
  77. MMC_MenuButtonCollection::iterator GetMMCMenuButton(
  78. CMenuButtonNotify* pMenuBtnNotifyClbk,
  79. INT idCommand);
  80. MMC_MenuButtonCollection::iterator GetMMCMenuButton(INT nButtonID);
  81. bool IsAttached(CMenuButtonNotify* pMenuBtnNotifyClbk);
  82. private:
  83. // Data members
  84. CChildFrame* m_pChildFrame; // The child frame window.
  85. CMainFrame* m_pMainFrame; // The main frame window.
  86. // This is the collection of menu buttons.
  87. MMC_MenuButtonCollection m_MenuButtons;
  88. // This is the collection of each IMenuButton seen by the snapin.
  89. MMC_AttachedMenuButtons m_AttachedMenuButtons;
  90. // The Menu Bar object that is the main menu
  91. CMenuBar* m_pMenuBar;
  92. };
  93. #endif /* MENUBTNS_H */
  94. /////////////////////////////////////////////////////////////////////////////