ed5c5888dd9f49d48b513aa2c1c9f5e2b7fa8328
[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 HMENU m_currentMenu;
45 HHOOK m_hHook;
46 DWORD m_threadId;
47 BOOL m_mouseTrackDisabled;
48 WPARAM m_lastMoveFlags;
49 LPARAM m_lastMovePos;
50
51 // TODO: make dynamic
52 #define MAX_RECURSE 20
53 CMenuBand* m_bandStack[MAX_RECURSE];
54 int m_bandCount;
55
56 HRESULT PushToArray(CMenuBand * item);
57 HRESULT PopFromArray(CMenuBand ** pItem);
58 HRESULT PeekArray(CMenuBand ** pItem);
59
60 protected:
61 CMenuFocusManager();
62 ~CMenuFocusManager();
63
64 public:
65
66 DECLARE_NOT_AGGREGATABLE(CMenuFocusManager)
67 DECLARE_PROTECT_FINAL_CONSTRUCT()
68 BEGIN_COM_MAP(CMenuFocusManager)
69 END_COM_MAP()
70
71 private:
72 LRESULT GetMsgHook(INT nCode, WPARAM wParam, LPARAM lParam);
73 HRESULT PlaceHooks(HWND window);
74 HRESULT RemoveHooks(HWND window);
75 HRESULT UpdateFocus(CMenuBand * newBand, HMENU popupToTrack = NULL);
76 HRESULT ActivationChange(HWND newHwnd);
77 void DisableMouseTrack(HWND enableTo, BOOL disableThis);
78 HRESULT IsTrackedWindow(HWND hWnd);
79
80 public:
81 HRESULT PushMenu(CMenuBand * mb);
82 HRESULT PopMenu(CMenuBand * mb);
83 HRESULT PushTrackedPopup(CMenuBand * mb, HMENU popup);
84 HRESULT PopTrackedPopup(CMenuBand * mb, HMENU popup);
85 };