30a5d80adfded5a45e4df0bd0790a404dfaa2efc
[reactos.git] / reactos / dll / win32 / shell32 / shellmenu / CBandSite.h
1 /*
2 * Rebar band site
3 *
4 * Copyright 2007 Hervé Poussineau
5 * Copyright 2009 Andrew Hill
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #pragma once
23
24 class CBandSiteBase :
25 public CComObjectRootEx<CComMultiThreadModelNoCS>,
26 public IBandSite,
27 public IInputObjectSite,
28 public IInputObject,
29 public IDeskBarClient,
30 public IWinEventHandler,
31 public IPersistStream,
32 public IDropTarget,
33 public IServiceProvider,
34 public IBandSiteHelper,
35 public IOleCommandTarget
36 {
37 private:
38 struct BandObject
39 {
40 IDeskBand *DeskBand;
41 IOleWindow *OleWindow;
42 IWinEventHandler *WndEvtHandler;
43 DESKBANDINFO dbi;
44 };
45
46 LONG fBandsCount;
47 LONG fBandsAllocated;
48 struct BandObject *fBands;
49 HWND fRebarWindow;
50 CComPtr<IOleWindow> fOleWindow;
51 public:
52 CBandSiteBase();
53 ~CBandSiteBase();
54
55 // *** IBandSite methods ***
56 virtual HRESULT STDMETHODCALLTYPE AddBand(IUnknown *punk);
57 virtual HRESULT STDMETHODCALLTYPE EnumBands(UINT uBand, DWORD *pdwBandID);
58 virtual HRESULT STDMETHODCALLTYPE QueryBand(DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName);
59 virtual HRESULT STDMETHODCALLTYPE SetBandState(DWORD dwBandID, DWORD dwMask, DWORD dwState);
60 virtual HRESULT STDMETHODCALLTYPE RemoveBand(DWORD dwBandID);
61 virtual HRESULT STDMETHODCALLTYPE GetBandObject(DWORD dwBandID, REFIID riid, void **ppv);
62 virtual HRESULT STDMETHODCALLTYPE SetBandSiteInfo(const BANDSITEINFO *pbsinfo);
63 virtual HRESULT STDMETHODCALLTYPE GetBandSiteInfo(BANDSITEINFO *pbsinfo);
64
65 // *** IWinEventHandler methods ***
66 virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
67 virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd);
68
69 // *** IOleWindow methods ***
70 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd);
71 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
72
73 // *** IDeskBarClient methods ***
74 virtual HRESULT STDMETHODCALLTYPE SetDeskBarSite(IUnknown *punkSite);
75 virtual HRESULT STDMETHODCALLTYPE SetModeDBC(DWORD dwMode);
76 virtual HRESULT STDMETHODCALLTYPE UIActivateDBC(DWORD dwState);
77 virtual HRESULT STDMETHODCALLTYPE GetSize(DWORD dwWhich, LPRECT prc);
78
79 // *** IOleCommandTarget methods ***
80 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText);
81 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
82
83 // *** IInputObject methods ***
84 virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
85 virtual HRESULT STDMETHODCALLTYPE HasFocusIO();
86 virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
87
88 // *** IInputObjectSite methods ***
89 virtual HRESULT STDMETHODCALLTYPE OnFocusChangeIS(struct IUnknown *paramC, int param10);
90
91 // *** IServiceProvider methods ***
92 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
93
94 // *** IPersist methods ***
95 virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
96
97 // *** IPersistStream methods ***
98 virtual HRESULT STDMETHODCALLTYPE IsDirty();
99 virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm);
100 virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty);
101 virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
102
103 // *** IDropTarget methods ***
104 virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
105 virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
106 virtual HRESULT STDMETHODCALLTYPE DragLeave();
107 virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
108
109 // *** IBandSiteHelper methods ***
110 virtual HRESULT STDMETHODCALLTYPE LoadFromStreamBS(IStream *, const GUID &, void **);
111 virtual HRESULT STDMETHODCALLTYPE SaveToStreamBS(IUnknown *, IStream *);
112
113 private:
114 UINT GetBandID(struct BandObject *Band);
115 struct BandObject *GetBandByID(DWORD dwBandID);
116 void FreeBand(struct BandObject *Band);
117 DWORD GetBandSiteViewMode();
118 VOID BuildRebarBandInfo(struct BandObject *Band, REBARBANDINFOW *prbi);
119 HRESULT UpdateSingleBand(struct BandObject *Band);
120 HRESULT UpdateAllBands();
121 HRESULT UpdateBand(DWORD dwBandID);
122 struct BandObject *GetBandFromHwnd(HWND hwnd);
123
124 BEGIN_COM_MAP(CBandSiteBase)
125 COM_INTERFACE_ENTRY_IID(IID_IBandSite, IBandSite)
126 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
127 COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow)
128 COM_INTERFACE_ENTRY_IID(IID_IDeskBarClient, IDeskBarClient)
129 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
130 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
131 COM_INTERFACE_ENTRY_IID(IID_IInputObjectSite, IInputObjectSite)
132 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
133 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist)
134 COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream)
135 COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget)
136 COM_INTERFACE_ENTRY_IID(IID_IBandSiteHelper, IBandSiteHelper)
137 END_COM_MAP()
138 };
139
140 class CBandSite :
141 public CComCoClass<CBandSite, &CLSID_RebarBandSite>,
142 public CBandSiteBase
143 {
144 public:
145 DECLARE_REGISTRY_RESOURCEID(IDR_REBARBANDSITE)
146 DECLARE_AGGREGATABLE(CBandSite)
147
148 DECLARE_PROTECT_FINAL_CONSTRUCT()
149 };