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.

240 lines
11 KiB

  1. #ifndef CSFTOOLBAR
  2. #define CSFTOOLBAR
  3. #include "bands.h"
  4. #include "cwndproc.h"
  5. #include "droptgt.h"
  6. #include "CommonControls.h"
  7. // Each CISFBand toolbar button lParam points to one of these.
  8. class IBDATA
  9. {
  10. protected:
  11. DWORD _dwFlags; // Class specific flags
  12. BITBOOL _fNoIcon:1;
  13. PORDERITEM _poi;
  14. public:
  15. IBDATA(PORDERITEM poi) { _poi = poi; }
  16. virtual ~IBDATA() { /* Don't Delete Me */ }
  17. LPITEMIDLIST GetPidl() { return _poi ? _poi->pidl : NULL; }
  18. void SetOrderItem(PORDERITEM poi) { _poi = poi; }
  19. DWORD GetFlags() { return _dwFlags; }
  20. void SetFlags(DWORD dwFlags) { _dwFlags = dwFlags; }
  21. BOOL GetNoIcon() { return _fNoIcon; }
  22. void SetNoIcon(BOOL b) { _fNoIcon = BOOLIFY(b); }
  23. PORDERITEM GetOrderItem() { return _poi ; }
  24. };
  25. typedef IBDATA * PIBDATA;
  26. // Special HitTest results
  27. #define IBHT_SOURCE (-32768)
  28. #define IBHT_BACKGROUND (-32767)
  29. #define IBHT_PAGER (-32766)
  30. #define IBHT_OUTSIDEWINDOW (-32765)
  31. // Flags for _OnFSNotifyAdd and _AddPidl
  32. #define FSNA_BULKADD 0x0001 // This is a bulk add - don't recalc needlessly
  33. #define FSNA_ADDDEFAULT 0x0002 // Add the item at the default position (overrides nIndex)
  34. class CSFToolbar : public IWinEventHandler,
  35. public IShellChangeNotify,
  36. public CDelegateDropTarget,
  37. public IContextMenu,
  38. public IShellFolderBand,
  39. public CNotifySubclassWndProc
  40. {
  41. public:
  42. // *** IUnknown methods (override) ***
  43. virtual STDMETHODIMP_(ULONG) AddRef(void) PURE;
  44. virtual STDMETHODIMP_(ULONG) Release(void) PURE;
  45. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  46. // *** IWinEventHandler methods ***
  47. virtual STDMETHODIMP OnWinEvent (HWND hwnd, UINT dwMsg, WPARAM wParam, LPARAM lParam, LRESULT* plre);
  48. virtual STDMETHODIMP IsWindowOwner(HWND hwnd);
  49. // *** IShellChangeNotify methods ***
  50. virtual STDMETHODIMP OnChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  51. // *** CDelegateDropTarget ***
  52. virtual HRESULT GetWindowsDDT (HWND * phwndLock, HWND * phwndScroll);
  53. virtual HRESULT HitTestDDT (UINT nEvent, LPPOINT ppt, DWORD_PTR * pdwId, DWORD *pdwEffect);
  54. virtual HRESULT GetObjectDDT (DWORD_PTR dwId, REFIID riid, LPVOID * ppvObj);
  55. virtual HRESULT OnDropDDT (IDropTarget *pdt, IDataObject *pdtobj, DWORD * pgrfKeyState, POINTL pt, DWORD *pdwEffect);
  56. // *** IContextMenu methods ***
  57. virtual STDMETHODIMP QueryContextMenu(HMENU hmenu, UINT indexMenu,UINT idCmdFirst,UINT idCmdLast,UINT uFlags);
  58. virtual STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpici);
  59. virtual STDMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
  60. // *** IShellFolderBand ***
  61. virtual STDMETHODIMP InitializeSFB(LPSHELLFOLDER psf, LPCITEMIDLIST pidl) { return SetShellFolder(psf, pidl); };
  62. virtual STDMETHODIMP SetBandInfoSFB(BANDINFOSFB * pbi) { return E_NOTIMPL; };
  63. virtual STDMETHODIMP GetBandInfoSFB(BANDINFOSFB * pbi) { return E_NOTIMPL; };
  64. // Toolbar Management
  65. virtual HRESULT SetShellFolder(IShellFolder* psf, LPCITEMIDLIST pidl);
  66. virtual void EmptyToolbar();
  67. protected:
  68. CSFToolbar();
  69. virtual ~CSFToolbar();
  70. virtual HRESULT _CreateToolbar(HWND hwndParent);
  71. virtual HWND _CreatePager(HWND hwndParent);
  72. void _DestroyToolbar();
  73. virtual void _FillToolbar();
  74. void _UnregisterToolbar();
  75. void _RegisterToolbar();
  76. void _RegisterChangeNotify();
  77. void _UnregisterChangeNotify(); // Unregisters
  78. void _Refresh();
  79. void _ReleaseShellFolder();
  80. virtual BOOL _AddPidl(LPITEMIDLIST pidl, DWORD dwFlags, int index);
  81. virtual PIBDATA _AddOrderItemTB(PORDERITEM poi, int index, TBBUTTON* ptbb);
  82. virtual void _FillDPA(HDPA hdpa, HDPA hdpaSort, DWORD dwEnumFlags);
  83. virtual PIBDATA _CreateItemData(PORDERITEM poi);
  84. virtual HWND GetHWNDForUIObject() { return _hwndTB; };
  85. virtual HRESULT _LoadOrderStream() { return E_NOTIMPL; };
  86. virtual HRESULT _SaveOrderStream();
  87. virtual BOOL _AllowDropOnTitle() { return FALSE; };
  88. virtual HRESULT _GetIEnumIDList(DWORD dwEnumFlags, IEnumIDList **ppenum);
  89. LPITEMIDLIST _pidl;
  90. IShellFolder* _psf;
  91. ITranslateShellChangeNotify* _ptscn;
  92. HWND _hwndPager;
  93. HWND _hwndTB;
  94. HWND _hwndToolTips;
  95. DWORD _dwStyle; // style bits to be ORd in when _hwndTB is created
  96. TBINSERTMARK _tbim;
  97. int _iDragSource;
  98. HDPA _hdpaOrder; // current order list (if non-default)
  99. HDPA _hdpa; // current set of items, mirrors _hwndTB content
  100. long _lEvents;
  101. int _iButtonCur;
  102. IContextMenu *_pcmSF;
  103. IContextMenu2 * _pcm2;
  104. IImageList* _piml;
  105. int _nNextCommandID;
  106. int _idCmdSF;
  107. int _cxMin;
  108. int _cxMax;
  109. HWND _hwndDD;
  110. HWND _hwndWorkerWindow;
  111. // Flags
  112. BITBOOL _fNoShowText :1; // TRUE iff no text with icon
  113. BITBOOL _fShow :1; // TRUE when ShowDW has happened
  114. BITBOOL _fDirty :1; // TRUE iff hidden contents modified
  115. BITBOOL _fCheckIds :1; // TRUE iff _GetCommandID has wrapped
  116. BITBOOL _fFSNotify :1; // TRUE to receive FS Notifications
  117. BITBOOL _fFSNRegistered :1; // are we already registered?
  118. BITBOOL _fAccelerators :1; // whether to show & as accel or as &
  119. BITBOOL _fAllowRename :1; // TRUE to query _psf for IContextMenu of _pidl
  120. BITBOOL _fDropping :1; // TRUE while doing drop.
  121. BITBOOL _fDropped :1; // TRUE if we have reordered, _hdpaOrder may not have been created yet
  122. BITBOOL _fNoNameSort :1; // TRUE if band should _not_ sort icons by name
  123. BITBOOL _fVariableWidth :1;
  124. BITBOOL _fNoIcons :1; // turns off icons
  125. BITBOOL _fVertical :1; // TRUE: band is displayed vertically
  126. BITBOOL _fMulticolumn : 1;
  127. BITBOOL _fHasOrder: 1;
  128. BITBOOL _fPSFBandDesktop :1;// TRUE iff _psfBand came from desktop
  129. // this implies psfDesktop->BindToObject(_pidl)
  130. // results in the correct ISF
  131. BITBOOL _fRegisterChangeNotify: 1; // TRUE: We will register for change notify.
  132. BITBOOL _fAllowReorder: 1;
  133. BITBOOL _fChangedOrder: 1; // Only send change notifies if we actually changed the order
  134. UINT _uIconSize : 2; // Large/Small/Logo
  135. // Virtual Function Overrides for Window Subclass
  136. virtual LRESULT _OnHotItemChange(NMTBHOTITEM * pnmhot);
  137. virtual HRESULT OnTranslatedChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  138. virtual LRESULT _OnTimer(WPARAM wParam);
  139. virtual LRESULT _DefWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  140. virtual LRESULT _OnCustomDraw(NMCUSTOMDRAW* pnmcd);
  141. virtual void _OnDragBegin(int iItem, DWORD dwPreferredEffect);
  142. virtual void _OnToolTipsCreated(NMTOOLTIPSCREATED* pnm);
  143. virtual LRESULT _OnNotify(LPNMHDR pnm);
  144. virtual LRESULT _OnCommand(WPARAM wParam, LPARAM lParam) { return 0; };
  145. virtual void _OnFSNotifyAdd(LPCITEMIDLIST pidl, DWORD dwFlags, int nIndex);
  146. virtual void _OnFSNotifyRemove(LPCITEMIDLIST pidl);
  147. virtual void _OnFSNotifyRename(LPCITEMIDLIST pidlFrom, LPCITEMIDLIST pidlTo);
  148. virtual void _OnFSNotifyUpdate(LPCITEMIDLIST pidl);
  149. virtual void _NotifyBulkOperation(BOOL fStart) { }
  150. virtual HRESULT _OnRenameFolder(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  151. virtual HMENU _GetContextMenu(IContextMenu* pcm, int* pid);
  152. virtual void _OnDefaultContextCommand(int idCmd);
  153. virtual LRESULT _OnContextMenu(WPARAM wParam, LPARAM lParam);
  154. // Helper Functions
  155. int _GetCommandID();
  156. virtual void _ObtainPIDLName(LPCITEMIDLIST pidl, LPTSTR psz, int cchMax);
  157. BOOL _IsParentID(LPCITEMIDLIST pidl);
  158. BOOL _IsChildID(LPCITEMIDLIST pidlChild, BOOL fImmediate);
  159. BOOL _IsEqualID(LPCITEMIDLIST pidl);
  160. LPVOID _GetUIObjectOfPidl(LPCITEMIDLIST pidl, REFIID riid);
  161. HMENU _GetBaseContextMenu();
  162. HRESULT _GetTopBrowserWindow(HWND* phwnd);
  163. HRESULT _OnOpen(int id, BOOL fExplore);
  164. HRESULT _HandleSpecialCommand(IContextMenu* pcm, PPOINT ppt, int id, int idCmd);
  165. LRESULT _DoContextMenu(IContextMenu* pcm, LPPOINT ppt, int id, LPRECT prcExclude);
  166. void _SortDPA(HDPA hdpa);
  167. virtual HWND CreateWorkerWindow();
  168. BOOL_PTR InlineDeleteButton(int iTBIndex);
  169. static INT_PTR CALLBACK _RenameDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  170. HRESULT _OnRename(LPPOINT ppt, int id);
  171. UINT _IndexToID(int iTBIndex);
  172. LPCITEMIDLIST _IDToPidl(UINT uiCmd, int *piPos = NULL);
  173. PIBDATA _IDToPibData(UINT uiCmd, int * piPos = NULL);
  174. PIBDATA _PosToPibData(UINT iPos);
  175. void _RememberOrder();
  176. void _UpdateButtons();
  177. void _OnGetDispInfo(LPNMHDR pnm, BOOL fUnicode);
  178. HRESULT _GetButtonFromPidl(LPCITEMIDLIST pidl, TBBUTTONINFO * ptbbi, int * pIndex, LPITEMIDLIST *ppidlOut);
  179. DWORD _GetAttributesOfPidl(LPCITEMIDLIST pidl, DWORD dwAttribs);
  180. BOOL _UpdateShowText(BOOL fNoShowText);
  181. // Virtual Helper Functions
  182. virtual int _GetBitmap(int iCommandID, PIBDATA pibdata, BOOL fUseCache);
  183. virtual void _SetDirty(BOOL fDirty);
  184. virtual HMENU _GetContextMenu();
  185. virtual BOOL _UpdateIconSize(UINT uIconSize, BOOL fUpdateButton);
  186. virtual HRESULT _TBStyleForPidl(LPCITEMIDLIST pidl,
  187. DWORD * pdwTBStyle, DWORD* pdwTBState, DWORD * pdwMIFFlags, int* piIcon);
  188. virtual BOOL _FilterPidl(LPCITEMIDLIST pidl);
  189. virtual int _DefaultInsertIndex();
  190. virtual void _ToolbarChanged() { };
  191. virtual void _Dropped(int nIndex, BOOL fDroppedOnSource);
  192. virtual HRESULT _AfterLoad();
  193. virtual void v_CalcWidth(int* pcxMin, int* pcxMax);
  194. virtual void _SetToolbarState();
  195. virtual void v_NewItem(LPCITEMIDLIST pidl) {};
  196. virtual int v_TBIndexToDPAIndex(int iTBIndex) { return iTBIndex; }
  197. virtual int v_DPAIndexToTBIndex(int iIndex) { return iIndex; }
  198. static void s_NewItem(LPVOID pvParam, LPCITEMIDLIST pidl);
  199. };
  200. BOOL TBHasImage(HWND hwnd, int iImageIndex);
  201. LRESULT CALLBACK HiddenWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  202. #endif