[RSHELL]
[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 = 0x701f;
26 static const int gCopyToCommandID = 0x701e;
27 static const int gDeleteCommandID = 0x7011;
28 static const int gUndoCommandID = 0x701b;
29 static const int gViewsCommandID = 0x7031;
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 = 0x7013;
36 static const int gCutCommandID = 0x7018;
37 static const int gCopyCommandID = 0x7019;
38 static const int gPasteCommandID = 0x701a;
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 CreateBrandBand(IUnknown **logoBar);
102 HRESULT CreateToolsBar(IUnknown **toolsBar);
103 HRESULT CreateAddressBand(IUnknown **toolsBar);
104 HRESULT LockUnlockToolbars(bool locked);
105 HRESULT CommandStateChanged(bool newValue, int commandID);
106 HRESULT CreateAndInitBandProxy();
107 public:
108 // *** IInputObject specific methods ***
109 virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
110 virtual HRESULT STDMETHODCALLTYPE HasFocusIO();
111 virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
112
113 // *** IOleWindow methods ***
114 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd);
115 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
116
117 // *** IDockingWindow methods ***
118 virtual HRESULT STDMETHODCALLTYPE ShowDW(BOOL fShow);
119 virtual HRESULT STDMETHODCALLTYPE CloseDW(DWORD dwReserved);
120 virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved);
121
122 // *** IPersist methods ***
123 virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
124
125 // *** IPersistStreamInit methods ***
126 virtual HRESULT STDMETHODCALLTYPE IsDirty();
127 virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm);
128 virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty);
129 virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
130 virtual HRESULT STDMETHODCALLTYPE InitNew();
131
132 // *** IOleCommandTarget methods ***
133 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText);
134 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
135
136 // *** IDispatch methods ***
137 virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo);
138 virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
139 virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
140 virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
141
142 // *** IExplorerToolbar methods ***
143 virtual HRESULT STDMETHODCALLTYPE SetCommandTarget(IUnknown *theTarget, GUID *category, long param14);
144 virtual HRESULT STDMETHODCALLTYPE Unknown1();
145 virtual HRESULT STDMETHODCALLTYPE AddButtons(const GUID *pguidCmdGroup, long buttonCount, TBBUTTON *buttons);
146 virtual HRESULT STDMETHODCALLTYPE AddString(const GUID *pguidCmdGroup, HINSTANCE param10, LPCTSTR param14, long *param18);
147 virtual HRESULT STDMETHODCALLTYPE GetButton(const GUID *pguidCmdGroup, long param10, long param14);
148 virtual HRESULT STDMETHODCALLTYPE GetState(const GUID *pguidCmdGroup, long commandID, long *theState);
149 virtual HRESULT STDMETHODCALLTYPE SetState(const GUID *pguidCmdGroup, long commandID, long theState);
150 virtual HRESULT STDMETHODCALLTYPE AddBitmap(const GUID *pguidCmdGroup, long param10, long buttonCount, TBADDBITMAP *lParam, long *newIndex, COLORREF param20);
151 virtual HRESULT STDMETHODCALLTYPE GetBitmapSize(long *paramC);
152 virtual HRESULT STDMETHODCALLTYPE SendToolbarMsg(const GUID *pguidCmdGroup, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *result);
153 virtual HRESULT STDMETHODCALLTYPE SetImageList(const GUID *pguidCmdGroup, HIMAGELIST param10, HIMAGELIST param14, HIMAGELIST param18);
154 virtual HRESULT STDMETHODCALLTYPE ModifyButton(const GUID *pguidCmdGroup, long param10, long param14);
155
156 // *** IShellChangeNotify methods ***
157 virtual HRESULT STDMETHODCALLTYPE OnChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
158
159 // *** IObjectWithSite methods ***
160 virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
161 virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void **ppvSite);
162
163 // *** IServiceProvider methods ***
164 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
165
166 // *** IWinEventHandler methods ***
167 virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
168 virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd);
169
170 // *** IBandSite specific methods ***
171 virtual HRESULT STDMETHODCALLTYPE AddBand(IUnknown *punk);
172 virtual HRESULT STDMETHODCALLTYPE EnumBands(UINT uBand, DWORD *pdwBandID);
173 virtual HRESULT STDMETHODCALLTYPE QueryBand(DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName);
174 virtual HRESULT STDMETHODCALLTYPE SetBandState(DWORD dwBandID, DWORD dwMask, DWORD dwState);
175 virtual HRESULT STDMETHODCALLTYPE RemoveBand(DWORD dwBandID);
176 virtual HRESULT STDMETHODCALLTYPE GetBandObject(DWORD dwBandID, REFIID riid, void **ppv);
177 virtual HRESULT STDMETHODCALLTYPE SetBandSiteInfo(const BANDSITEINFO *pbsinfo);
178 virtual HRESULT STDMETHODCALLTYPE GetBandSiteInfo(BANDSITEINFO *pbsinfo);
179
180 // message handlers
181 LRESULT OnTravelBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
182 LRESULT OnTravelForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
183 LRESULT OnUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
184 LRESULT OnSearch(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
185 LRESULT OnFolders(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
186 LRESULT OnForwardToCommandTarget(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
187 LRESULT OnMenuDropDown(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
188 LRESULT OnQueryInsert(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
189 LRESULT OnQueryDelete(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
190 LRESULT OnNavigateCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
191 LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
192 LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
193 LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
194 LRESULT OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
195 LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
196 LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
197 LRESULT OnLDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
198 LRESULT OnLUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
199 LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
200
201 BEGIN_MSG_MAP(CInternetToolbar)
202 COMMAND_ID_HANDLER(IDM_GOTO_BACK, OnTravelBack)
203 COMMAND_ID_HANDLER(IDM_GOTO_FORWARD, OnTravelForward)
204 COMMAND_ID_HANDLER(IDM_GOTO_UPONELEVEL, OnUpLevel)
205 COMMAND_ID_HANDLER(gSearchCommandID, OnSearch)
206 COMMAND_ID_HANDLER(gFoldersCommandID, OnFolders)
207 COMMAND_RANGE_HANDLER(0x7000, 0x7fff, OnForwardToCommandTarget)
208 NOTIFY_HANDLER(0, TBN_DROPDOWN, OnMenuDropDown)
209 NOTIFY_HANDLER(0, TBN_QUERYINSERT, OnQueryInsert)
210 NOTIFY_HANDLER(0, TBN_QUERYDELETE, OnQueryDelete)
211 MESSAGE_HANDLER(WM_COMMAND, OnCommand)
212 MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
213 MESSAGE_HANDLER(WM_SIZE, OnSize)
214 MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
215 NOTIFY_CODE_HANDLER(TTN_NEEDTEXTW, OnTipText)
216 MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
217 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLDown)
218 MESSAGE_HANDLER(WM_LBUTTONUP, OnLUp)
219 MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
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 };