[RSHELL]
[reactos.git] / base / shell / rshell / CMenuToolbars.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 class CMenuFocusManager;
24
25 #define WM_USER_ISTRACKEDITEM (WM_APP+41)
26 #define WM_USER_CHANGETRACKEDITEM (WM_APP+42)
27
28
29 class CMenuToolbarBase
30 {
31 private:
32 HWND m_hwnd; // May be the pager
33 HFONT m_marlett;
34 BOOL m_useFlatMenus;
35 WNDPROC m_SubclassOld;
36 BOOL m_disableMouseTrack;
37 BOOL m_timerEnabled;
38
39 protected:
40 CMenuBand * m_menuBand;
41 HWND m_hwndToolbar;
42 DWORD m_dwMenuFlags;
43 BOOL m_hasIdealSize;
44 SIZE m_idealSize;
45 BOOL m_usePager;
46 CMenuToolbarBase * m_hotBar;
47 INT m_hotItem;
48 CMenuToolbarBase * m_popupBar;
49 INT m_popupItem;
50
51 DWORD m_initFlags;
52 BOOL m_isTracking;
53
54 private:
55 static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
56
57 public:
58 CMenuToolbarBase(CMenuBand *menuBand, BOOL usePager);
59 virtual ~CMenuToolbarBase();
60
61 HRESULT IsWindowOwner(HWND hwnd);
62 HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags);
63 HRESULT GetWindow(HWND *phwnd);
64 HRESULT ShowWindow(BOOL fShow);
65 HRESULT Close();
66
67 HRESULT OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
68
69 HRESULT ChangeHotItem(CMenuToolbarBase * toolbar, INT item, DWORD dwFlags);
70 HRESULT ChangePopupItem(CMenuToolbarBase * toolbar, INT item);
71
72 HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu);
73 HRESULT PopupSubMenu(UINT itemId, UINT index, HMENU menu);
74 HRESULT DoContextMenu(IContextMenu* contextMenu);
75
76 HRESULT KeyboardItemChange(DWORD changeType);
77 HRESULT OnHotItemChange(const NMTBHOTITEM * hot, LRESULT * theResult);
78
79 HRESULT IsTrackedItem(INT index);
80 HRESULT ChangeTrackedItem(INT index);
81
82 HRESULT GetIdealSize(SIZE& size);
83 HRESULT SetPosSize(int x, int y, int cx, int cy);
84
85 void InvalidateDraw();
86
87 HRESULT DisableMouseTrack(BOOL bDisable);
88
89 virtual HRESULT FillToolbar(BOOL clearFirst=FALSE) = 0;
90 virtual HRESULT OnContextMenu(NMMOUSE * rclick) = 0;
91
92 HRESULT CancelCurrentPopup();
93 HRESULT PopupItem(INT iItem);
94 HRESULT GetDataFromId(INT iItem, INT* pIndex, DWORD_PTR* pData);
95
96 HRESULT KillPopupTimer();
97
98 protected:
99 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
100
101 virtual HRESULT OnDeletingButton(const NMTOOLBAR * tb) = 0;
102 virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData) = 0;
103 virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData) = 0;
104
105 virtual HRESULT GetInfoTip(LPWSTR pszText, INT cchTextMax, INT iItem, INT index, DWORD_PTR dwData)=0;
106
107 LRESULT CALLBACK SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
108
109 HRESULT AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last);
110 HRESULT AddSeparator(BOOL last);
111 HRESULT AddPlaceholder();
112
113 HRESULT UpdateImageLists();
114
115 private:
116 HRESULT OnPagerCalcSize(LPNMPGCALCSIZE csize);
117 HRESULT OnPopupTimer(DWORD timerId);
118 HRESULT OnCustomDraw(LPNMTBCUSTOMDRAW cdraw, LRESULT * theResult);
119 HRESULT OnGetInfoTip(NMTBGETINFOTIP * tip);
120 };
121
122 class CMenuStaticToolbar :
123 public CMenuToolbarBase
124 {
125 private:
126 HMENU m_hmenu;
127
128 public:
129 CMenuStaticToolbar(CMenuBand *menuBand);
130 virtual ~CMenuStaticToolbar() {}
131
132 HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
133 HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
134
135 virtual HRESULT FillToolbar(BOOL clearFirst=FALSE);
136 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
137 virtual HRESULT OnContextMenu(NMMOUSE * rclick);
138
139 protected:
140 virtual HRESULT OnDeletingButton(const NMTOOLBAR * tb);
141
142 virtual HRESULT GetInfoTip(LPWSTR pszText, INT cchTextMax, INT iItem, INT index, DWORD_PTR dwData);
143
144 virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData);
145 virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData);
146 };
147
148 class CMenuSFToolbar :
149 public CMenuToolbarBase
150 {
151 private:
152 CComPtr<IShellFolder> m_shellFolder;
153 LPCITEMIDLIST m_idList;
154 HKEY m_hKey;
155
156 public:
157 CMenuSFToolbar(CMenuBand *menuBand);
158 virtual ~CMenuSFToolbar();
159
160 HRESULT SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
161 HRESULT GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
162
163 virtual HRESULT FillToolbar(BOOL clearFirst=FALSE);
164 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
165 virtual HRESULT OnContextMenu(NMMOUSE * rclick);
166
167 protected:
168 virtual HRESULT OnDeletingButton(const NMTOOLBAR * tb);
169
170 virtual HRESULT GetInfoTip(LPWSTR pszText, INT cchTextMax, INT iItem, INT index, DWORD_PTR dwData);
171
172 virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData);
173 virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData);
174 };