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.

193 lines
7.7 KiB

  1. #ifndef MENUSF
  2. #define MENUSF
  3. #include "mnbase.h"
  4. #include "sftbar.h"
  5. class CMenuData : public IBDATA
  6. {
  7. protected:
  8. IUnknown* _punkSubmenu;
  9. public:
  10. CMenuData(PORDERITEM poi) : IBDATA(poi) {};
  11. virtual ~CMenuData();
  12. void SetSubMenu(IUnknown* pmb2);
  13. HRESULT GetSubMenu(const GUID* pguidService, REFIID riid, void**);
  14. };
  15. class CMenuBand;
  16. class CMenuSFToolbar : public CSFToolbar,
  17. public CMenuToolbarBase
  18. {
  19. public:
  20. // *** IUnknown (override) ***
  21. // This deliberately forwards AddRef and Release to CMenuToolbarBase, and
  22. // forwards QI separately to CSFToolbar.
  23. virtual STDMETHODIMP_(ULONG) AddRef(void) { return CMenuToolbarBase::AddRef(); };
  24. virtual STDMETHODIMP_(ULONG) Release(void) { return CMenuToolbarBase::Release(); };
  25. virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppvObj);
  26. // *** IObjectWithSite methods ***
  27. virtual STDMETHODIMP SetSite(IUnknown* punkSite);
  28. // *** IShellChangeNotify methods ***
  29. virtual STDMETHODIMP OnChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  30. // *** IWinEventHandler methods (override) ***
  31. virtual STDMETHODIMP IsWindowOwner(HWND hwnd);
  32. virtual STDMETHODIMP OnWinEvent(HWND hwnd, UINT dwMsg, WPARAM wParam, LPARAM lParam, LRESULT *plres);
  33. // *** CDelegateDropTarget methods ***
  34. virtual STDMETHODIMP DragEnter(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  35. virtual STDMETHODIMP DragLeave(void);
  36. virtual HRESULT HitTestDDT (UINT nEvent, LPPOINT ppt, DWORD_PTR * pdwId, DWORD *pdwEffect);
  37. virtual HRESULT GetObjectDDT (DWORD_PTR dwId, REFIID riid, LPVOID * ppvObj);
  38. virtual HRESULT OnDropDDT (IDropTarget *pdt, IDataObject *pdtobj, DWORD * pgrfKeyState, POINTL pt, DWORD *pdwEffect);
  39. // Other public methods
  40. virtual HWND v_GetHWND()
  41. { return _hwndTB; };
  42. virtual void v_ForwardMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  43. virtual void v_SendMenuNotification(UINT idCmd, BOOL fClear);
  44. virtual BOOL v_TrackingSubContextMenu() { return (BOOL) ( _pcm2 ? 1 : 0 );}; // Win64: should be ok since _pcm2 used as boolean in all contexts
  45. virtual BOOL v_UpdateIconSize(UINT uIconSize, BOOL fUpdateButtons);
  46. virtual void v_Close();
  47. virtual void v_Show(BOOL fShow, BOOL fForceUpdate);
  48. virtual void v_UpdateButtons(BOOL fNegotiateSize);
  49. virtual void NegotiateSize();
  50. virtual void Expand(BOOL fExpand);
  51. virtual void GetSize(SIZE* size);
  52. virtual void SetWindowPos(LPSIZE psize, LPRECT prc, DWORD dwFlags);
  53. virtual HRESULT CreateToolbar(HWND hwndParent);
  54. virtual void SetParent(HWND hwndParent);
  55. virtual HRESULT GetShellFolder(LPITEMIDLIST* ppidl, REFIID riid, void** ppvObj);
  56. virtual void v_OnEmptyToolbar(); // override
  57. virtual void v_OnDeleteButton(LPVOID pData);
  58. virtual HRESULT v_InvalidateItem(LPSMDATA psmd, DWORD dwFlags);
  59. virtual HRESULT SetShellFolder(IShellFolder* psf, LPCITEMIDLIST pidl);
  60. inline virtual BOOL ShowAmpersand() { return TRUE; }
  61. // Change HKEY to IStream*
  62. CMenuSFToolbar(CMenuBand* pmb, IShellFolder* psf, LPCITEMIDLIST pidl, HKEY hKey, DWORD dwFlags);
  63. protected:
  64. ~CMenuSFToolbar();
  65. // Window Proc Overrides
  66. virtual LRESULT _DefWindowProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
  67. virtual LRESULT _OnContextMenu(WPARAM wParam, LPARAM lParam);
  68. virtual void _OnDragBegin(int iItem, DWORD dwPreferredEffect);
  69. virtual void _OnFSNotifyAdd(LPCITEMIDLIST pidl, DWORD dwFlags, int nIndex);
  70. virtual void _OnFSNotifyRemove(LPCITEMIDLIST pidl);
  71. virtual void _OnFSNotifyRename(LPCITEMIDLIST pidlFrom, LPCITEMIDLIST pidlTo);
  72. virtual void _NotifyBulkOperation(BOOL fStart);
  73. virtual HRESULT OnTranslatedChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  74. virtual LRESULT v_OnCustomDraw(NMCUSTOMDRAW * pnmcd);
  75. virtual void _FillToolbar();
  76. virtual LRESULT _OnNotify(LPNMHDR pnm);
  77. virtual LRESULT _OnTimer(WPARAM wParam);
  78. virtual void _SetToolbarState()
  79. { CMenuToolbarBase::_SetToolbarState(); };
  80. virtual void EmptyToolbar()
  81. { CMenuToolbarBase::EmptyToolbar(); };
  82. virtual int v_GetDragOverButton()
  83. { return _tbim.iButton; };
  84. virtual HRESULT v_GetSubMenu(int iCmd, const GUID* pguidService, REFIID riid, void** pObj);
  85. virtual HRESULT v_GetInfoTip(int iCmd, LPTSTR psz, UINT cch);
  86. virtual HRESULT v_CallCBItem(int idtCmd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  87. virtual HRESULT v_GetState(int idtCmd, LPSMDATA psmd);
  88. virtual HRESULT v_ExecItem(int iCmd);
  89. virtual DWORD v_GetFlags(int iCmd);
  90. virtual void v_Refresh()
  91. { _Refresh(); };
  92. virtual void v_CalcWidth(int* pcxMin, int* pcxMax)
  93. { CMenuToolbarBase::v_CalcWidth(pcxMin, pcxMax); };
  94. // Utility Functions
  95. virtual BOOL _AddPidl(LPITEMIDLIST pidl, DWORD dwFlags, int index);
  96. virtual PIBDATA _AddOrderItemTB(PORDERITEM poi, int index, TBBUTTON* ptbb);
  97. virtual void _Dropped(int nIndex, BOOL fDroppedOnSource);
  98. virtual HRESULT _TBStyleForPidl(LPCITEMIDLIST pidl, DWORD * pdwStyle,
  99. DWORD* pdwState, DWORD * pdwFlags,int* piIcon);
  100. virtual void _ToolbarChanged();
  101. virtual void _FillDPA(HDPA hdpa, HDPA hdpaSort, DWORD dwEnumFlags);
  102. virtual BOOL _FilterPidl(LPCITEMIDLIST pidl);
  103. virtual void _ObtainPIDLName(LPCITEMIDLIST pidl, LPTSTR psz, int cchMax);
  104. virtual HMENU _GetContextMenu(IContextMenu* pcm, int* pid);
  105. virtual void _OnDefaultContextCommand(int idCmd);
  106. virtual void v_NewItem(LPCITEMIDLIST pidl);
  107. virtual void _SetDirty(BOOL fDirty);
  108. virtual void _SetFontMetrics();
  109. virtual int _GetBitmap(int iCommandID, PIBDATA pibdata, BOOL fUseCache);
  110. virtual HWND GetHWNDForUIObject();
  111. virtual HWND CreateWorkerWindow();
  112. virtual int v_TBIndexToDPAIndex(int iTBIndex);
  113. virtual int v_DPAIndexToTBIndex(int iIndex);
  114. static void s_IconCallback(LPVOID pvData, UINT uId, UINT iIconIndex);
  115. void _AddChevron();
  116. void _RemoveChevron();
  117. void _AddNSSeparator();
  118. void _RemoveNSSeparator();
  119. void _RefreshInfo();
  120. BOOL _IsSpecialCmd(int cmd) { return cmd == _idCmdChevron || cmd == _idCmdSep; }
  121. BOOL _IsAboveNSSeparator(LPCITEMIDLIST pidl);
  122. BOOL _IsBelowNSSeparator(int iIndex);
  123. int _GetNSSeparatorPlacement();
  124. HRESULT _GetFolderForCreateViewObject(BOOL fAbove, IShellFolder **ppsf);
  125. void BroadcastIntelliMenuState(LPCITEMIDLIST pidlItem, BOOL fPromoted);
  126. BOOL _ReBindToFolder(LPCITEMIDLIST pidl);
  127. virtual HRESULT _LoadOrderStream();
  128. virtual HRESULT _SaveOrderStream();
  129. virtual HRESULT _AfterLoad();
  130. HRESULT _GetInfo(LPCITEMIDLIST pidl, SMINFO* pmbiinfo);
  131. HRESULT CallCB(LPCITEMIDLIST pidl, DWORD dwMsg, WPARAM wParam, LPARAM lParam);
  132. HKEY _GetKey(LPCITEMIDLIST pidl);
  133. void _MarkItem(int idCmd);
  134. LRESULT _OnGetObject(NMOBJECTNOTIFY*);
  135. void _FindMinPromotedItems(BOOL fSetOrderStream);
  136. virtual LRESULT _OnDropDown(LPNMTOOLBAR pnmtb);
  137. virtual HRESULT v_CreateTrackPopup(int, REFIID, void**)
  138. { AssertMsg(0, TEXT("MenuSF trying to get a TrackPopup")); return E_FAIL; };
  139. virtual PIBDATA _CreateItemData(PORDERITEM poi);
  140. // Member Variables
  141. HKEY _hKey;
  142. BITBOOL _fPreventToolbarChange: 1;
  143. IAugmentedShellFolder2* _pasf2;
  144. int _iDefaultIconIndex;
  145. int _cMinPromotedItems;
  146. int _idCmdSep; // -1 if no artificial separator
  147. GUID _guidAboveSep; // The namespace guid that goes ahead of the separator
  148. };
  149. #define MNFOLDER_NORODER -5 // Some random negative number to denote there is no order
  150. #define MNFOLDER_IS_PARENT -1 // -1 is passed to the child as uIdParent so that
  151. // it knows it's not rooted at a static menu
  152. #endif // MENUSF