[RSHELL]
[reactos.git] / base / shell / rshell / CMenuFocusManager.h
1 /*
2 * Shell Menu Band
3 *
4 * Copyright 2014 David Quintana
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20 #pragma once
21
22 class CMenuBand;
23
24 class CMenuFocusManager :
25 public CComCoClass<CMenuFocusManager>,
26 public CComObjectRootEx<CComMultiThreadModelNoCS>
27 {
28 private:
29 static DWORD TlsIndex;
30
31 static CMenuFocusManager * GetManager();
32
33 public:
34 static CMenuFocusManager * AcquireManager();
35
36 static void ReleaseManager(CMenuFocusManager * obj);
37
38 private:
39 static LRESULT CALLBACK s_GetMsgHook(INT nCode, WPARAM wParam, LPARAM lParam);
40
41 private:
42 CMenuBand * m_currentBand;
43 HWND m_currentFocus;
44 HHOOK m_hHook;
45 DWORD m_threadId;
46
47 // TODO: make dynamic
48 #define MAX_RECURSE 20
49 CMenuBand* m_bandStack[MAX_RECURSE];
50 int m_bandCount;
51
52 HRESULT PushToArray(CMenuBand * item);
53 HRESULT PopFromArray(CMenuBand ** pItem);
54 HRESULT PeekArray(CMenuBand ** pItem);
55
56 protected:
57 CMenuFocusManager();
58 ~CMenuFocusManager();
59
60 public:
61
62 DECLARE_NOT_AGGREGATABLE(CMenuFocusManager)
63 DECLARE_PROTECT_FINAL_CONSTRUCT()
64 BEGIN_COM_MAP(CMenuFocusManager)
65 END_COM_MAP()
66
67 LRESULT GetMsgHook(INT nCode, WPARAM wParam, LPARAM lParam);
68 HRESULT PlaceHooks(HWND window);
69 HRESULT RemoveHooks(HWND window);
70 HRESULT UpdateFocus(CMenuBand * newBand);
71
72 public:
73 HRESULT PushMenu(CMenuBand * mb);
74 HRESULT PopMenu(CMenuBand * mb);
75 };