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.

182 lines
7.2 KiB

  1. #ifndef MNBASE
  2. #define MNBASE
  3. // Characters for _DrawMenuGlyph
  4. #define CH_MENUARROWA '8'
  5. #define CH_MENUARROW TEXT(CH_MENUARROWA)
  6. #define CH_MENUCHECKA 'a'
  7. #define CH_MENUCHEVRONA 187
  8. class CMenuBand; // Forward Declare
  9. class CMenuBandMetrics;
  10. #define LIST_GAP 8 // from Observation
  11. class CMenuToolbarBase: public IWinEventHandler, public IObjectWithSite
  12. {
  13. public:
  14. // *** IUnknown ***
  15. virtual STDMETHODIMP_(ULONG) AddRef(void);
  16. virtual STDMETHODIMP_(ULONG) Release(void);
  17. virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppvObj);
  18. // *** IObjectWithSite methods ***
  19. virtual STDMETHODIMP SetSite(IUnknown* punkSite);
  20. virtual STDMETHODIMP GetSite(REFIID riid, void ** ppvSite);
  21. // *** IWinEventHandler methods ***
  22. virtual STDMETHODIMP IsWindowOwner(HWND hwnd) PURE;
  23. virtual STDMETHODIMP OnWinEvent(HWND hwnd, UINT dwMsg, WPARAM wParam, LPARAM lParam, LRESULT *plres);
  24. // Other public methods
  25. CMenuToolbarBase(CMenuBand* pmb, DWORD dwFlags);
  26. // Returns the HWND and Converts the pt to child.
  27. virtual void v_ForwardMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  28. virtual void v_SendMenuNotification(UINT idCmd, BOOL fClear) PURE;
  29. virtual BOOL v_TrackingSubContextMenu() PURE;
  30. virtual void v_Show(BOOL fShow, BOOL fForceUpdate);
  31. virtual BOOL v_UpdateIconSize(UINT uIconSize, BOOL fUpdateButtons) PURE;
  32. virtual void v_UpdateButtons(BOOL fNegotiateSize) PURE;
  33. virtual HRESULT v_GetSubMenu(int iCmd, const GUID* pguidService, REFIID riid, void** pObj) PURE;
  34. virtual HRESULT v_CallCBItem(int idtCmd, UINT uMsg, WPARAM wParam, LPARAM lParam) PURE;
  35. virtual HRESULT v_GetState(int idtCmd, LPSMDATA psmd) PURE;
  36. virtual HRESULT v_ExecItem(int iCmd) PURE;
  37. virtual DWORD v_GetFlags(int iCmd) PURE;
  38. virtual void v_Refresh() PURE;
  39. virtual void v_Close();
  40. virtual void v_OnEmptyToolbar();
  41. virtual void v_OnDeleteButton(LPVOID pData) {};
  42. virtual HRESULT v_InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
  43. { return E_NOTIMPL; };
  44. virtual void NegotiateSize();
  45. virtual void SetWindowPos(LPSIZE psize, LPRECT prc, DWORD dwFlags);
  46. virtual void GetSize(SIZE*);
  47. virtual void CreateToolbar(HWND hwndParent);
  48. virtual void SetParent(HWND hwndParent);
  49. virtual HRESULT GetShellFolder(LPITEMIDLIST* ppidl, REFIID riid, void** ppvObj) {return E_FAIL;};
  50. virtual HRESULT GetMenu(HMENU* phmenu, HWND* phwnd, DWORD* pdwFlags) { return E_FAIL; };
  51. virtual HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags) { return E_FAIL;};
  52. virtual void Expand(BOOL fExpand) {};
  53. HRESULT GetSubMenu(int idCmd, GUID* pguidService, REFIID riid, void** ppvObj);
  54. HRESULT PositionSubmenu(int idCmd);
  55. void Activate(BOOL fActivate);
  56. void SetMenuBandMetrics(CMenuBandMetrics* pmbm);
  57. void PostPopup(int idCmd, BOOL bSetItem, BOOL bInitialSelect);
  58. void PopupClose(void);
  59. HRESULT PopupOpen(int nCmd);
  60. void PopupHelper(int idCmd, BOOL bInitialSelect);
  61. void KillPopupTimer();
  62. void SetToTop(BOOL bToTop);
  63. void EmptyToolbar(); // override
  64. DWORD GetFlags(void) { return _dwFlags; };
  65. BOOL DontShowEmpty() { return _fDontShowEmpty; };
  66. void DontShowEmpty(BOOL fDontShowEmpty) { _fDontShowEmpty = BOOLIFY(fDontShowEmpty); };
  67. BOOL GetChevronID() { return _idCmdChevron; };
  68. int GetValidHotItem(int iDir, int iIndex, int iCount, DWORD dwFlags);
  69. BOOL SetHotItem(int iDir, int iIndex, int iCount, DWORD dwFlags);
  70. void SetKeyboardCue();
  71. inline virtual BOOL ShowAmpersand() { return FALSE; }
  72. virtual ~CMenuToolbarBase() {};
  73. BOOL IsEmpty() { return _fEmpty; };
  74. HWND _hwndMB;
  75. protected:
  76. static void s_FadeCallback(DWORD dwStep, LPVOID pvParam);
  77. virtual void v_CalcWidth(int* pcxMin, int* pcxMax);
  78. virtual int v_GetDragOverButton() PURE;
  79. virtual HRESULT v_GetInfoTip(int iCmd, LPTSTR psz, UINT cch) PURE;
  80. virtual HRESULT v_CreateTrackPopup(int idCmd, REFIID riid, void** ppvObj) PURE;
  81. // Window Proc Overrides
  82. LRESULT _DropDownOrExec(UINT idCmd, BOOL bKeyboard);
  83. LRESULT _OnCustomDraw(NMCUSTOMDRAW * pnmcd);
  84. void _PaintButton(HDC hdc, int idCmd, LPRECT prc, DWORD dwMBIF);
  85. LRESULT _OnWrapHotItem(NMTBWRAPHOTITEM* pnmwh);
  86. LRESULT _OnWrapAccelerator(NMTBWRAPACCELERATOR* pnmwa);
  87. LRESULT _OnDupAccelerator(NMTBDUPACCELERATOR* pnmda);
  88. virtual LRESULT _OnHotItemChange(NMTBHOTITEM * pnmhot);
  89. virtual LRESULT _OnNotify(LPNMHDR pnm);
  90. virtual LRESULT _OnDropDown(LPNMTOOLBAR pnmtb);
  91. virtual LRESULT _OnTimer( WPARAM wParam );
  92. virtual void _FlashChevron();
  93. virtual LRESULT _DefWindowProcMB(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  94. BOOL _OnKey(BOOL bDown, UINT vk, UINT uFlags);
  95. void _OnSelectArrow(int iDir);
  96. void _FireEvent(BYTE bEvent);
  97. // Utility Functions
  98. void _DoPopup(int idCmd, BOOL bInitialSelect);
  99. virtual void _SetFontMetrics();
  100. virtual void _SetToolbarState();
  101. void _PressBtn(int idBtn, BOOL bDown);
  102. HRESULT _SetMenuBand(IShellMenu* psm);
  103. BOOL _SetTimer(int nTimer);
  104. void _DrawMenuArrowGlyph( HDC hdc, RECT * prc, COLORREF rgbText );
  105. void _DrawMenuGlyph( HDC hdc, HFONT hFont, RECT * prc,
  106. CHAR ch, COLORREF rgbText,
  107. LPSIZE psize);
  108. int _CalcChevronSize();
  109. void _DrawChevron(HDC hdc, LPRECT prect, BOOL fFocus, BOOL fSelected);
  110. BOOL _HandleObscuredItem(int idCmd);
  111. CMenuBand* _pcmb;
  112. DEBUG_CODE (int _cRef); // To debug references to the sub objects.
  113. DWORD _dwFlags; // SMSET_* flags
  114. UINT _uIconSizeMB;
  115. UINT _nItemTimer;
  116. int _idCmdChevron; // -1 if no chevron exists
  117. int _cPromotedItems; // Number of promoted items.
  118. BYTE _cFlashCount;
  119. int _idCmdLastClicked;
  120. int _iLastClickedTime;
  121. int _idCmdDragging;
  122. BITBOOL _fHasDemotedItems: 1;
  123. BITBOOL _fVerticalMB: 1;
  124. BITBOOL _fTopLevel: 1;
  125. BITBOOL _fEmpty : 1;
  126. BITBOOL _fHasSubMenu: 1;
  127. BITBOOL _fEditMode : 1;
  128. BITBOOL _fClickHandled: 1;
  129. BITBOOL _fProcessingWrapHotItem: 1;
  130. BITBOOL _fEmptyingToolbar : 1;
  131. BITBOOL _fMulticolumnMB : 1;
  132. BITBOOL _fExpandTimer: 1; // There is an expand timer.
  133. BITBOOL _fIgnoreHotItemChange: 1;
  134. BITBOOL _fShowMB: 1;
  135. BITBOOL _fFirstTime: 1;
  136. BITBOOL _fHasDrop: 1;
  137. BITBOOL _fRefreshInfo: 1;
  138. BITBOOL _fDontShowEmpty: 1;
  139. BITBOOL _fSuppressUserMonitor: 1;
  140. BITBOOL _fHorizInVerticalMB: 1; // TRUE: Don't set EX_Vertical on the Toolbar
  141. };
  142. int GetButtonCmd(HWND hwndTB, int iPos);
  143. void* ItemDataFromPos(HWND hwndTB, int iPos);
  144. BOOL SetHotItem(HWND hwnd, int iDir, int iIndex, int iCount, DWORD dwFlags);
  145. long GetIndexFromChild(BOOL fTop, int iIndex);
  146. // UEM Parameters
  147. #define UEM_TIMEOUT 0
  148. #define UEM_HOT_ITEM 1
  149. #define UEM_HOT_FOLDER 2
  150. #define UEM_RESET -1
  151. #endif // MNBASE