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.

231 lines
10 KiB

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