b8d8f1cff4473238a11cb88a4bfe3942536562de
[reactos.git] / dll / win32 / browseui / internettoolbar.h
1 /*
2 * ReactOS Explorer
3 *
4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #pragma once
22
23 static const int gSearchCommandID = 1003;
24 static const int gFoldersCommandID = 1004;
25 static const int gMoveToCommandID = FCIDM_SHVIEW_MOVETO;
26 static const int gCopyToCommandID = FCIDM_SHVIEW_COPYTO;
27 static const int gDeleteCommandID = FCIDM_SHVIEW_DELETE;
28 static const int gUndoCommandID = FCIDM_SHVIEW_UNDO;
29 static const int gViewsCommandID = FCIDM_SHVIEW_AUTOARRANGE;
30 static const int gStopCommandID = 1010;
31 static const int gHomeCommandID = 1012;
32 static const int gFavoritesCommandID = 1015;
33 static const int gHistoryCommandID = 1016;
34 static const int gFullScreenCommandID = 1017;
35 static const int gPropertiesCommandID = FCIDM_SHVIEW_PROPERTIES;
36 static const int gCutCommandID = FCIDM_SHVIEW_CUT;
37 static const int gCopyCommandID = FCIDM_SHVIEW_COPY;
38 static const int gPasteCommandID = FCIDM_SHVIEW_INSERT;
39
40 class CMenuCallback :
41 public CComObjectRootEx<CComMultiThreadModelNoCS>,
42 public IShellMenuCallback
43 {
44 private:
45 CComPtr<IShellMenu> fFavoritesMenu;
46 public:
47 CMenuCallback();
48 virtual ~CMenuCallback();
49
50 HRESULT STDMETHODCALLTYPE GetObject(LPSMDATA psmd, REFIID riid, void **ppvObject);
51 public:
52 // *** IShellMenuCallback methods ***
53 virtual HRESULT STDMETHODCALLTYPE CallbackSM(LPSMDATA psmd, UINT uMsg, WPARAM wParam, LPARAM lParam);
54
55 BEGIN_COM_MAP(CMenuCallback)
56 COM_INTERFACE_ENTRY_IID(IID_IShellMenuCallback, IShellMenuCallback)
57 END_COM_MAP()
58 };
59
60 class CInternetToolbar :
61 public CWindowImpl<CInternetToolbar, CWindow, CControlWinTraits>,
62 public CComCoClass<CInternetToolbar, &CLSID_InternetToolbar>,
63 public CComObjectRootEx<CComMultiThreadModelNoCS>,
64 public IInputObject,
65 public IDockingWindow,
66 public IPersistStreamInit,
67 public IOleCommandTarget,
68 public IDispatch,
69 public IExplorerToolbar,
70 public IShellChangeNotify,
71 public IObjectWithSite,
72 public IServiceProvider,
73 public IWinEventHandler,
74 public IBandSite
75 {
76 public:
77 CComPtr<IUnknown> fSite; // our site
78 HWND fMainReBar; // rebar for top of window
79 bool fLocked; // is bar locked to prevent changes?
80 CComPtr<IShellMenu> fMenuBar; // the menu rebar
81 HWND fMenuBandWindow;
82 HWND fNavigationWindow;
83 CComPtr<IUnknown> fLogoBar; // the reactos logo
84 CComPtr<IUnknown> fControlsBar; // navigation controls
85 CComPtr<IUnknown> fNavigationBar; // address bar
86 CComPtr<CMenuCallback> fMenuCallback;
87 CComPtr<IOleCommandTarget> fCommandTarget;
88 GUID fCommandCategory;
89 HWND fToolbarWindow;
90 DWORD fAdviseCookie;
91 CComPtr<IBandProxy> fBandProxy;
92 BOOL fSizing;
93 POINT fStartPosition;
94 LONG fStartHeight;
95 public:
96 CInternetToolbar();
97 virtual ~CInternetToolbar();
98 void AddDockItem(IUnknown *newItem, int bandID, int flags);
99 HRESULT ReserveBorderSpace(LONG maxHeight = -1);
100 HRESULT CreateMenuBar(IShellMenu **menuBar);
101 HRESULT CreateToolsBar(IUnknown **toolsBar);
102 HRESULT LockUnlockToolbars(bool locked);
103 HRESULT CommandStateChanged(bool newValue, int commandID);
104 HRESULT CreateAndInitBandProxy();
105 public:
106 // *** IInputObject specific methods ***
107 virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
108 virtual HRESULT STDMETHODCALLTYPE HasFocusIO();
109 virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
110
111 // *** IOleWindow methods ***
112 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd);
113 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
114
115 // *** IDockingWindow methods ***
116 virtual HRESULT STDMETHODCALLTYPE ShowDW(BOOL fShow);
117 virtual HRESULT STDMETHODCALLTYPE CloseDW(DWORD dwReserved);
118 virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved);
119
120 // *** IPersist methods ***
121 virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
122
123 // *** IPersistStreamInit methods ***
124 virtual HRESULT STDMETHODCALLTYPE IsDirty();
125 virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm);
126 virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty);
127 virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
128 virtual HRESULT STDMETHODCALLTYPE InitNew();
129
130 // *** IOleCommandTarget methods ***
131 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText);
132 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
133
134 // *** IDispatch methods ***
135 virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo);
136 virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
137 virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
138 virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
139
140 // *** IExplorerToolbar methods ***
141 virtual HRESULT STDMETHODCALLTYPE SetCommandTarget(IUnknown *theTarget, GUID *category, long param14);
142 virtual HRESULT STDMETHODCALLTYPE Unknown1();
143 virtual HRESULT STDMETHODCALLTYPE AddButtons(const GUID *pguidCmdGroup, long buttonCount, TBBUTTON *buttons);
144 virtual HRESULT STDMETHODCALLTYPE AddString(const GUID *pguidCmdGroup, HINSTANCE param10, LPCTSTR param14, long *param18);
145 virtual HRESULT STDMETHODCALLTYPE GetButton(const GUID *pguidCmdGroup, long param10, long param14);
146 virtual HRESULT STDMETHODCALLTYPE GetState(const GUID *pguidCmdGroup, long commandID, long *theState);
147 virtual HRESULT STDMETHODCALLTYPE SetState(const GUID *pguidCmdGroup, long commandID, long theState);
148 virtual HRESULT STDMETHODCALLTYPE AddBitmap(const GUID *pguidCmdGroup, long param10, long buttonCount, TBADDBITMAP *lParam, long *newIndex, COLORREF param20);
149 virtual HRESULT STDMETHODCALLTYPE GetBitmapSize(long *paramC);
150 virtual HRESULT STDMETHODCALLTYPE SendToolbarMsg(const GUID *pguidCmdGroup, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *result);
151 virtual HRESULT STDMETHODCALLTYPE SetImageList(const GUID *pguidCmdGroup, HIMAGELIST param10, HIMAGELIST param14, HIMAGELIST param18);
152 virtual HRESULT STDMETHODCALLTYPE ModifyButton(const GUID *pguidCmdGroup, long param10, long param14);
153
154 // *** IShellChangeNotify methods ***
155 virtual HRESULT STDMETHODCALLTYPE OnChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
156
157 // *** IObjectWithSite methods ***
158 virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
159 virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void **ppvSite);
160
161 // *** IServiceProvider methods ***
162 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
163
164 // *** IWinEventHandler methods ***
165 virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
166 virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd);
167
168 // *** IBandSite specific methods ***
169 virtual HRESULT STDMETHODCALLTYPE AddBand(IUnknown *punk);
170 virtual HRESULT STDMETHODCALLTYPE EnumBands(UINT uBand, DWORD *pdwBandID);
171 virtual HRESULT STDMETHODCALLTYPE QueryBand(DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName);
172 virtual HRESULT STDMETHODCALLTYPE SetBandState(DWORD dwBandID, DWORD dwMask, DWORD dwState);
173 virtual HRESULT STDMETHODCALLTYPE RemoveBand(DWORD dwBandID);
174 virtual HRESULT STDMETHODCALLTYPE GetBandObject(DWORD dwBandID, REFIID riid, void **ppv);
175 virtual HRESULT STDMETHODCALLTYPE SetBandSiteInfo(const BANDSITEINFO *pbsinfo);
176 virtual HRESULT STDMETHODCALLTYPE GetBandSiteInfo(BANDSITEINFO *pbsinfo);
177
178 // message handlers
179 LRESULT OnTravelBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
180 LRESULT OnTravelForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
181 LRESULT OnUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
182 LRESULT OnSearch(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
183 LRESULT OnFolders(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
184 LRESULT OnForwardToCommandTarget(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
185 LRESULT OnMenuDropDown(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
186 LRESULT OnQueryInsert(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
187 LRESULT OnQueryDelete(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
188 LRESULT OnNavigateCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
189 LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
190 LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
191 LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
192 LRESULT OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
193 LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
194 LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
195 LRESULT OnLDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
196 LRESULT OnLUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
197 LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
198 LRESULT OnWinIniChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
199
200 BEGIN_MSG_MAP(CInternetToolbar)
201 COMMAND_ID_HANDLER(IDM_GOTO_BACK, OnTravelBack)
202 COMMAND_ID_HANDLER(IDM_GOTO_FORWARD, OnTravelForward)
203 COMMAND_ID_HANDLER(IDM_GOTO_UPONELEVEL, OnUpLevel)
204 COMMAND_ID_HANDLER(gSearchCommandID, OnSearch)
205 COMMAND_ID_HANDLER(gFoldersCommandID, OnFolders)
206 COMMAND_RANGE_HANDLER(0x7000, 0x7fff, OnForwardToCommandTarget)
207 NOTIFY_HANDLER(0, TBN_DROPDOWN, OnMenuDropDown)
208 NOTIFY_HANDLER(0, TBN_QUERYINSERT, OnQueryInsert)
209 NOTIFY_HANDLER(0, TBN_QUERYDELETE, OnQueryDelete)
210 MESSAGE_HANDLER(WM_COMMAND, OnCommand)
211 MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
212 MESSAGE_HANDLER(WM_SIZE, OnSize)
213 MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
214 NOTIFY_CODE_HANDLER(TTN_NEEDTEXTW, OnTipText)
215 MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
216 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLDown)
217 MESSAGE_HANDLER(WM_LBUTTONUP, OnLUp)
218 MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
219 MESSAGE_HANDLER(WM_WININICHANGE, OnWinIniChange)
220 END_MSG_MAP()
221
222 DECLARE_REGISTRY_RESOURCEID(IDR_INTERNETTOOLBAR)
223 DECLARE_NOT_AGGREGATABLE(CInternetToolbar)
224
225 DECLARE_PROTECT_FINAL_CONSTRUCT()
226
227 BEGIN_COM_MAP(CInternetToolbar)
228 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
229 COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow)
230 COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
231 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist)
232 // COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream)
233 COM_INTERFACE_ENTRY_IID(IID_IPersistStreamInit, IPersistStreamInit)
234 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
235 COM_INTERFACE_ENTRY_IID(IID_IDispatch, IDispatch)
236 COM_INTERFACE_ENTRY_IID(IID_IExplorerToolbar, IExplorerToolbar)
237 COM_INTERFACE_ENTRY_IID(IID_IShellChangeNotify, IShellChangeNotify)
238 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
239 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
240 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
241 COM_INTERFACE_ENTRY_IID(IID_IBandSite, IBandSite)
242 END_COM_MAP()
243 };