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