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