Leaked source code of windows server 2003
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.

224 lines
7.4 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: menubar.h
  7. *
  8. * Contents: Interface file for CMenuBar
  9. *
  10. * History: 14-Nov-97 JeffRo Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #ifndef MENUBAR_H
  14. #define MENUBAR_H
  15. #pragma once
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CMenuBar class
  18. class CRebarDockWindow; // forward declaration
  19. class CMDIMenuDecoration;
  20. class CRebarWnd;
  21. #define WM_POPUP_ASYNC WM_APP
  22. #define MAX_MENU_ITEMS 32 // Maximum # of items in main menu.
  23. class CMenuBar : public CMMCToolBarCtrlEx
  24. {
  25. friend class CPopupTrackContext;
  26. typedef std::vector<CString> ToolbarStringPool;
  27. typedef std::set<INT> CommandIDPool;
  28. std::auto_ptr<CMDIMenuDecoration> m_pMDIDec;
  29. ToolbarStringPool m_ToolbarStringPool;
  30. CMDIFrameWnd * m_pMDIFrame;
  31. CWnd* m_pwndLastActive;
  32. CRebarWnd * m_pRebar;
  33. HMENU m_hMenuLast;
  34. CAccel m_MenuAccel; // to handle Alt+<mnemonic>
  35. CAccel m_TrackingAccel; // to <mnemonic> while in menu mode
  36. CFont m_MenuFont;
  37. CString m_strAccelerators;
  38. HICON m_hMaxedChildIcon;
  39. bool m_fDestroyChildIcon;
  40. bool m_fDecorationsShowing;
  41. bool m_fMaxedChildIconIsInvalid;
  42. // following member is to indicate that the change in menu is because of attempt
  43. // to switch to another submenu, and should not be treated as dismissing the menu
  44. // thus accelerator state should not be changed
  45. bool m_bInProgressDisplayingPopup;
  46. CommandIDPool m_CommandIDUnUsed; // Command IDs pool (to recycle unused ids).
  47. static const CAccel& GetMenuUISimAccel();
  48. void DeleteMaxedChildIcon();
  49. public:
  50. CMenuBar ();
  51. virtual ~CMenuBar ();
  52. virtual void BeginTracking2 (CToolbarTrackerAuxWnd* pAuxWnd);
  53. virtual void EndTracking2 (CToolbarTrackerAuxWnd* pAuxWnd);
  54. virtual int GetFirstButtonIndex ();
  55. BOOL Create (CMDIFrameWnd* pwndFrame, CRebarDockWindow* pParentRebar, DWORD dwStyle, UINT idWindow);
  56. BOOL Create (CFrameWnd* pwndFrame, CRebarDockWindow* pParentRebar, DWORD dwStyle, UINT idWindow);
  57. void SetMenu (CMenu* pMenu);
  58. int AddString (const CString& strAdd);
  59. void PopupMenuAsync (int cmd);
  60. void OnIdle ();
  61. void GetAccelerators (int cchBuffer, LPTSTR lpBuffer) const;
  62. // Following methods used by CMenuButtonsMgr
  63. // to add/delete/modify menu buttons
  64. LONG InsertMenuButton(LPCTSTR lpszButtonText, BOOL bHidden, int iPreferredPos = -1);
  65. BOOL DeleteMenuButton(INT nCommandID);
  66. LONG SetMenuButton(INT nCommandID, LPCTSTR lpszButtonText);
  67. SC ScShowMMCMenus(bool bShow);
  68. CMenu* GetMenu () const
  69. {
  70. return (CMenu::FromHandle (m_hMenuLast));
  71. }
  72. void InvalidateMaxedChildIcon ()
  73. {
  74. if (m_fDecorationsShowing)
  75. {
  76. m_fMaxedChildIconIsInvalid = true;
  77. InvalidateRect (NULL);
  78. }
  79. }
  80. enum
  81. {
  82. cMaxTopLevelMenuItems = MAX_MENU_ITEMS,
  83. // top-level menu item commands
  84. ID_MTB_MENU_FIRST = CMMCToolBarCtrlEx::ID_MTBX_LAST + 1,
  85. // The following menus have fixed command-ids.
  86. ID_MTB_MENU_SYSMENU = ID_MTB_MENU_FIRST,
  87. ID_MTB_MENU_ACTION = ID_MTB_MENU_SYSMENU + 1,
  88. ID_MTB_MENU_VIEW = ID_MTB_MENU_ACTION + 1,
  89. ID_MTB_MENU_FAVORITES = ID_MTB_MENU_VIEW + 1,
  90. ID_MTB_MENU_SNAPIN_PLACEHOLDER = ID_MTB_MENU_FAVORITES + 1,
  91. // The following command ids are free to be assigned.
  92. // Starts with last fixed command-id.
  93. ID_MTB_FIRST_COMMANDID = ID_MTB_MENU_SNAPIN_PLACEHOLDER + 1,
  94. ID_MTB_MENU_LAST = ID_MTB_MENU_VIEW + cMaxTopLevelMenuItems,
  95. ID_MTB_ACTIVATE_CURRENT_POPUP,
  96. ID_MTB_FIRST = ID_MTB_MENU_FIRST,
  97. ID_MTB_LAST = ID_MTB_ACTIVATE_CURRENT_POPUP,
  98. ID_MDIDECORATION = 0x2001
  99. };
  100. int IndexToCommand (int nIndex) const
  101. {
  102. TBBUTTON tbbi;
  103. tbbi.idCommand = 0; // We need only idCommand so just init this.
  104. if (GetButton(nIndex, &tbbi))
  105. return tbbi.idCommand;
  106. ASSERT(FALSE);
  107. return -1;
  108. }
  109. // Overrides
  110. // ClassWizard generated virtual function overrides
  111. //{{AFX_VIRTUAL(CMenuBar)
  112. public:
  113. virtual BOOL PreTranslateMessage(MSG* pMsg);
  114. //}}AFX_VIRTUAL
  115. protected:
  116. void DestroyAcceleratorTable ();
  117. void SetMenuFont ();
  118. void SizeDecoration ();
  119. int GetMenuBandIndex () const;
  120. int GetDecorationBandIndex () const;
  121. void GetMaxedChildIcon (CWnd* pwnd);
  122. BOOL InsertButton (int nIndex, const CString& strText, int idCommand,
  123. DWORD_PTR dwMenuData, BYTE fsState, BYTE fsStyle);
  124. /*
  125. * Derived classes can override this to handle properties they support.
  126. * The base class should always be called first.
  127. */
  128. virtual SC ScGetPropValue (
  129. HWND hwnd, // I:accessible window
  130. DWORD idObject, // I:accessible object
  131. DWORD idChild, // I:accessible child object
  132. const MSAAPROPID& idProp, // I:property requested
  133. VARIANT& varValue, // O:returned property value
  134. BOOL& fGotProp); // O:was a property returned?
  135. virtual SC ScInsertAccPropIDs (PropIDCollection& v);
  136. // Generated message map functions
  137. protected:
  138. //{{AFX_MSG(CMenuBar)
  139. afx_msg void OnDropDown(NMHDR* pNMHDR, LRESULT* pResult);
  140. afx_msg void OnGetDispInfo(NMHDR* pNMHDR, LRESULT* pResult);
  141. afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
  142. afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  143. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  144. afx_msg void OnDestroy();
  145. //}}AFX_MSG
  146. afx_msg LRESULT OnPopupAsync(WPARAM, LPARAM);
  147. afx_msg void OnHotItemChange(NMHDR* pNMHDR, LRESULT* pResult);
  148. afx_msg void OnAccelPopup (UINT cmd);
  149. afx_msg void OnUpdateAllCmdUI (CCmdUI* pCmdUI);
  150. afx_msg void OnActivateCurrentPopup ();
  151. DECLARE_MESSAGE_MAP()
  152. void PopupMenu (int nItemIndex, bool bHighlightFirstItem);
  153. // Accelerators
  154. private:
  155. typedef std::vector<ACCEL> AccelVector;
  156. AccelVector m_vMenuAccels;
  157. AccelVector m_vTrackingAccels;
  158. private:
  159. void LoadAccels();
  160. bool IsStandardMenuAllowed(UINT uMenuID);
  161. };
  162. /*---------------------------------------------------------*\
  163. | copied from winuser.h since we currently compile
  164. | with _WIN32_WINNT == 0x0400
  165. \*---------------------------------------------------------*/
  166. #if(_WIN32_WINNT < 0x0500)
  167. #define WM_CHANGEUISTATE 0x0127
  168. #define WM_UPDATEUISTATE 0x0128
  169. #define WM_QUERYUISTATE 0x0129
  170. #define UIS_SET 1
  171. #define UIS_CLEAR 2
  172. #define UIS_INITIALIZE 3
  173. #define UISF_HIDEFOCUS 0x1
  174. #define UISF_HIDEACCEL 0x2
  175. #define WM_UNINITMENUPOPUP 0x0125
  176. #endif // (_WIN32_WINNT < 0x0500)
  177. #endif /* MENUBAR_H */