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.

194 lines
7.7 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 HRESULT 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. HRESULT SetMinWidth(int cxMenu);
  73. HRESULT SetNoBorder(BOOL fNoBorder);
  74. HRESULT SetTheme(LPCWSTR pszTheme);
  75. virtual ~CMenuToolbarBase();
  76. BOOL IsEmpty() { return _fEmpty; };
  77. HWND _hwndMB;
  78. WCHAR* _pszTheme;
  79. BOOL _fNoBorder;
  80. protected:
  81. virtual void v_CalcWidth(int* pcxMin, int* pcxMax);
  82. virtual int v_GetDragOverButton() PURE;
  83. virtual HRESULT v_GetInfoTip(int iCmd, LPTSTR psz, UINT cch) PURE;
  84. virtual HRESULT v_CreateTrackPopup(int idCmd, REFIID riid, void** ppvObj) PURE;
  85. // Window Proc Overrides
  86. LRESULT _DropDownOrExec(UINT idCmd, BOOL bKeyboard);
  87. virtual LRESULT v_OnCustomDraw(NMCUSTOMDRAW * pnmcd);
  88. void _PaintButton3D(HDC hdc, int idCmd, LPRECT prc, DWORD dwMBIF);
  89. LRESULT _OnWrapHotItem(NMTBWRAPHOTITEM* pnmwh);
  90. LRESULT _OnWrapAccelerator(NMTBWRAPACCELERATOR* pnmwa);
  91. LRESULT _OnDupAccelerator(NMTBDUPACCELERATOR* pnmda);
  92. virtual LRESULT _OnHotItemChange(NMTBHOTITEM * pnmhot);
  93. virtual LRESULT _OnNotify(LPNMHDR pnm);
  94. virtual LRESULT _OnDropDown(LPNMTOOLBAR pnmtb);
  95. virtual LRESULT _OnTimer( WPARAM wParam );
  96. virtual void _FlashChevron();
  97. virtual LRESULT _DefWindowProcMB(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  98. BOOL _OnKey(BOOL bDown, UINT vk, UINT uFlags);
  99. void _OnSelectArrow(int iDir);
  100. void _FireEvent(BYTE bEvent);
  101. void _RefreshTheme();
  102. // Utility Functions
  103. void _DoPopup(int idCmd, BOOL bInitialSelect);
  104. virtual void _SetFontMetrics();
  105. virtual void _SetToolbarState();
  106. void _PressBtn(int idBtn, BOOL bDown);
  107. HRESULT _SetMenuBand(IShellMenu* psm);
  108. BOOL _SetTimer(int nTimer);
  109. void _DrawMenuArrowGlyph( HDC hdc, RECT * prc, COLORREF rgbText );
  110. void _DrawMenuGlyph( HDC hdc, HFONT hFont, RECT * prc,
  111. CHAR ch, COLORREF rgbText,
  112. LPSIZE psize);
  113. int _CalcChevronSize();
  114. void _DrawChevron(HDC hdc, LPRECT prect, BOOL fFocus, BOOL fSelected);
  115. BOOL _HandleObscuredItem(int idCmd);
  116. CMenuBand* _pcmb;
  117. DEBUG_CODE (int _cRef); // To debug references to the sub objects.
  118. DWORD _dwFlags; // SMSET_* flags
  119. UINT _uIconSizeMB;
  120. UINT _nItemTimer;
  121. int _idCmdChevron; // -1 if no chevron exists
  122. int _cPromotedItems; // Number of promoted items.
  123. BYTE _cFlashCount;
  124. int _idCmdLastClicked;
  125. int _iLastClickedTime;
  126. int _idCmdDragging;
  127. int _cxMinMenu;
  128. HTHEME _hTheme;
  129. BITBOOL _fHasDemotedItems: 1;
  130. BITBOOL _fVerticalMB: 1;
  131. BITBOOL _fTopLevel: 1;
  132. BITBOOL _fEmpty : 1;
  133. BITBOOL _fHasSubMenu: 1;
  134. BITBOOL _fEditMode : 1;
  135. BITBOOL _fClickHandled: 1;
  136. BITBOOL _fProcessingWrapHotItem: 1;
  137. BITBOOL _fEmptyingToolbar : 1;
  138. BITBOOL _fMulticolumnMB : 1;
  139. BITBOOL _fExpandTimer: 1; // There is an expand timer.
  140. BITBOOL _fIgnoreHotItemChange: 1;
  141. BITBOOL _fShowMB: 1;
  142. BITBOOL _fFirstTime: 1;
  143. BITBOOL _fHasDrop: 1;
  144. BITBOOL _fRefreshInfo: 1;
  145. BITBOOL _fDontShowEmpty: 1;
  146. BITBOOL _fSuppressUserMonitor: 1;
  147. BITBOOL _fHorizInVerticalMB: 1; // TRUE: Don't set EX_Vertical on the Toolbar
  148. };
  149. int GetButtonCmd(HWND hwndTB, int iPos);
  150. void* ItemDataFromPos(HWND hwndTB, int iPos);
  151. BOOL SetHotItem(HWND hwnd, int iDir, int iIndex, int iCount, DWORD dwFlags);
  152. long GetIndexFromChild(BOOL fTop, int iIndex);
  153. int GetTBImageListWidth(HWND hwnd);
  154. // UEM Parameters
  155. #define UEM_TIMEOUT 0
  156. #define UEM_HOT_ITEM 1
  157. #define UEM_HOT_FOLDER 2
  158. #define UEM_RESET -1
  159. // This fudge factor is to widen the icon spacing.
  160. #define ICONFUDGE 4
  161. // This fudge factor is the width we add on to the icon width in order to draw a "pleasent" background.
  162. #define ICONBACKGROUNDFUDGE 5
  163. #endif // MNBASE