Sync with trunk r62754.
[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 class CMenuToolbarBase
29 {
30 private:
31 HWND m_hwnd; // May be the pager
32 HWND m_hwndToolbar;
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 DWORD m_dwMenuFlags;
42 BOOL m_hasSizes;
43 SIZE m_idealSize;
44 SIZE m_itemSize;
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_isTrackingPopup;
53
54 private:
55 static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
56
57 LRESULT SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
58
59 public:
60 CMenuToolbarBase(CMenuBand *menuBand, BOOL usePager);
61 virtual ~CMenuToolbarBase();
62
63 HRESULT IsWindowOwner(HWND hwnd);
64 HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags);
65 HRESULT GetWindow(HWND *phwnd);
66 HRESULT ShowWindow(BOOL fShow);
67 HRESULT Close();
68
69 HRESULT OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
70
71 HRESULT ChangeHotItem(CMenuToolbarBase * toolbar, INT item, DWORD dwFlags);
72 HRESULT ChangePopupItem(CMenuToolbarBase * toolbar, INT item);
73
74 HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu);
75 HRESULT PopupSubMenu(UINT itemId, UINT index, HMENU menu);
76 HRESULT TrackContextMenu(IContextMenu* contextMenu, POINT pt);
77
78 HRESULT KeyboardItemChange(DWORD changeType);
79
80 HRESULT IsTrackedItem(INT index);
81 HRESULT ChangeTrackedItem(INT index, BOOL wasTracking);
82
83 HRESULT GetSizes(SIZE* pMinSize, SIZE* pMaxSize, SIZE* pIntegralSize);
84 HRESULT SetPosSize(int x, int y, int cx, int cy);
85
86 void InvalidateDraw();
87
88 HRESULT DisableMouseTrack(BOOL bDisable);
89
90 virtual HRESULT FillToolbar(BOOL clearFirst=FALSE) = 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 OnDeletingButton(const NMTOOLBAR * tb) = 0;
100
101 virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax) = 0;
102 virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData) = 0;
103 virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData) = 0;
104 virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData) = 0;
105 virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt) = 0;
106
107 HRESULT AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last);
108 HRESULT AddSeparator(BOOL last);
109 HRESULT AddPlaceholder();
110 HRESULT ClearToolbar();
111
112 HWND GetToolbar() { return m_hwndToolbar; }
113
114 private:
115 HRESULT UpdateImageLists();
116
117 HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
118 HRESULT OnPagerCalcSize(LPNMPGCALCSIZE csize);
119 HRESULT OnPopupTimer(DWORD timerId);
120 HRESULT OnContextMenu(NMMOUSE * rclick);
121 HRESULT OnCustomDraw(LPNMTBCUSTOMDRAW cdraw, LRESULT * theResult);
122 HRESULT OnGetInfoTip(NMTBGETINFOTIP * tip);
123 };
124
125 class CMenuStaticToolbar :
126 public CMenuToolbarBase
127 {
128 private:
129 HMENU m_hmenu;
130
131 public:
132 CMenuStaticToolbar(CMenuBand *menuBand);
133 virtual ~CMenuStaticToolbar() {}
134
135 HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
136 HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
137
138 virtual HRESULT FillToolbar(BOOL clearFirst=FALSE);
139
140 protected:
141 virtual HRESULT OnDeletingButton(const NMTOOLBAR * tb);
142
143 virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax);
144 virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData);
145 virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData);
146 virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData);
147 virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt);
148 };
149
150 class CMenuSFToolbar :
151 public CMenuToolbarBase
152 {
153 private:
154 CComPtr<IShellFolder> m_shellFolder;
155 LPCITEMIDLIST m_idList;
156 HKEY m_hKey;
157
158 public:
159 CMenuSFToolbar(CMenuBand *menuBand);
160 virtual ~CMenuSFToolbar();
161
162 HRESULT SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
163 HRESULT GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
164
165 virtual HRESULT FillToolbar(BOOL clearFirst=FALSE);
166
167 protected:
168 virtual HRESULT OnDeletingButton(const NMTOOLBAR * tb);
169
170 virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax);
171 virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData);
172 virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData);
173 virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData);
174 virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt);
175 };