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