[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
30 protected:
31 CMenuBand * m_menuBand;
32 HWND m_hwndToolbar;
33 DWORD m_dwMenuFlags;
34 INT m_hotItem;
35 WNDPROC m_SubclassOld;
36 BOOL m_hasIdealSize;
37 SIZE m_idealSize;
38 BOOL m_usePager;
39
40 private:
41 static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
42
43 public:
44 CMenuToolbarBase(CMenuBand *menuBand, BOOL usePager);
45 virtual ~CMenuToolbarBase() {}
46
47 HRESULT IsWindowOwner(HWND hwnd);
48 HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags);
49 HRESULT GetWindow(HWND *phwnd);
50 HRESULT ShowWindow(BOOL fShow);
51 HRESULT Close();
52
53 virtual HRESULT FillToolbar() = 0;
54 virtual HRESULT PopupItem(UINT uItem) = 0;
55 virtual HRESULT HasSubMenu(UINT uItem) = 0;
56 virtual HRESULT OnContextMenu(NMMOUSE * rclick) = 0;
57 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
58
59 HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu);
60 HRESULT PopupSubMenu(UINT index, HMENU menu);
61 HRESULT DoContextMenu(IContextMenu* contextMenu);
62
63 HRESULT ChangeHotItem(DWORD changeType);
64 HRESULT OnHotItemChange(const NMTBHOTITEM * hot);
65
66 HRESULT GetIdealSize(SIZE& size);
67 HRESULT SetPosSize(int x, int y, int cx, int cy);
68
69 void InvalidateDraw();
70
71 protected:
72 LRESULT CALLBACK SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
73
74 HRESULT UpdateImageLists();
75 };
76
77 class CMenuStaticToolbar :
78 public CMenuToolbarBase
79 {
80 private:
81 HMENU m_hmenu;
82
83 public:
84 CMenuStaticToolbar(CMenuBand *menuBand);
85 virtual ~CMenuStaticToolbar() {}
86
87 HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
88 HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
89
90 virtual HRESULT FillToolbar();
91 virtual HRESULT PopupItem(UINT uItem);
92 virtual HRESULT HasSubMenu(UINT uItem);
93 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
94 virtual HRESULT OnContextMenu(NMMOUSE * rclick);
95
96 };
97
98 class CMenuSFToolbar :
99 public CMenuToolbarBase
100 {
101 private:
102 IShellFolder * m_shellFolder;
103 LPCITEMIDLIST m_idList;
104 HKEY m_hKey;
105
106 public:
107 CMenuSFToolbar(CMenuBand *menuBand);
108 virtual ~CMenuSFToolbar();
109
110 HRESULT SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
111 HRESULT GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
112
113 virtual HRESULT FillToolbar();
114 virtual HRESULT PopupItem(UINT uItem);
115 virtual HRESULT HasSubMenu(UINT uItem);
116 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
117 virtual HRESULT OnContextMenu(NMMOUSE * rclick);
118
119 private:
120 LPITEMIDLIST GetPidlFromId(UINT uItem, INT* pIndex = NULL);
121 };