2014-02-24 11:59:34 +00:00
|
|
|
/*
|
|
|
|
* Shell Menu Band
|
|
|
|
*
|
|
|
|
* Copyright 2014 David Quintana
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class CMenuBand;
|
|
|
|
class CMenuFocusManager;
|
|
|
|
|
2014-03-20 15:39:25 +00:00
|
|
|
#define WM_USER_ISTRACKEDITEM (WM_APP+41)
|
|
|
|
#define WM_USER_CHANGETRACKEDITEM (WM_APP+42)
|
2014-03-19 15:33:41 +00:00
|
|
|
|
2014-11-11 01:05:39 +00:00
|
|
|
class CMenuToolbarBase :
|
2015-04-29 00:07:54 +00:00
|
|
|
public CWindowImplBaseT< CToolbar<DWORD_PTR>, CControlWinTraits >
|
2014-02-24 11:59:34 +00:00
|
|
|
{
|
2014-11-11 01:05:39 +00:00
|
|
|
CContainedWindow m_pager;
|
2014-02-24 11:59:34 +00:00
|
|
|
private:
|
2014-04-15 10:08:08 +00:00
|
|
|
HFONT m_marlett;
|
|
|
|
BOOL m_useFlatMenus;
|
|
|
|
BOOL m_disableMouseTrack;
|
|
|
|
BOOL m_timerEnabled;
|
2014-02-24 11:59:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CMenuBand * m_menuBand;
|
|
|
|
DWORD m_dwMenuFlags;
|
2014-04-07 18:41:47 +00:00
|
|
|
BOOL m_hasSizes;
|
2014-02-24 11:59:34 +00:00
|
|
|
SIZE m_idealSize;
|
2014-04-07 18:41:47 +00:00
|
|
|
SIZE m_itemSize;
|
2014-02-24 11:59:34 +00:00
|
|
|
BOOL m_usePager;
|
2014-02-27 11:56:28 +00:00
|
|
|
CMenuToolbarBase * m_hotBar;
|
|
|
|
INT m_hotItem;
|
|
|
|
CMenuToolbarBase * m_popupBar;
|
|
|
|
INT m_popupItem;
|
2014-02-24 11:59:34 +00:00
|
|
|
|
2014-04-02 17:37:37 +00:00
|
|
|
DWORD m_initFlags;
|
2014-04-07 18:41:47 +00:00
|
|
|
BOOL m_isTrackingPopup;
|
2014-03-07 22:28:55 +00:00
|
|
|
|
2014-10-28 15:39:47 +00:00
|
|
|
INT m_executeIndex;
|
|
|
|
INT m_executeItem;
|
|
|
|
DWORD_PTR m_executeData;
|
|
|
|
|
2014-11-11 01:05:39 +00:00
|
|
|
BOOL m_cancelingPopup;
|
2014-04-15 10:08:08 +00:00
|
|
|
|
2014-02-24 11:59:34 +00:00
|
|
|
public:
|
|
|
|
CMenuToolbarBase(CMenuBand *menuBand, BOOL usePager);
|
2014-02-26 11:13:23 +00:00
|
|
|
virtual ~CMenuToolbarBase();
|
2014-02-24 11:59:34 +00:00
|
|
|
|
|
|
|
HRESULT IsWindowOwner(HWND hwnd);
|
|
|
|
HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags);
|
|
|
|
HRESULT GetWindow(HWND *phwnd);
|
2014-11-11 01:05:39 +00:00
|
|
|
HRESULT ShowDW(BOOL fShow);
|
2014-02-24 11:59:34 +00:00
|
|
|
HRESULT Close();
|
|
|
|
|
2014-02-26 11:13:23 +00:00
|
|
|
HRESULT OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
|
|
|
|
|
2014-04-02 17:37:37 +00:00
|
|
|
HRESULT ChangeHotItem(CMenuToolbarBase * toolbar, INT item, DWORD dwFlags);
|
|
|
|
HRESULT ChangePopupItem(CMenuToolbarBase * toolbar, INT item);
|
2014-02-24 11:59:34 +00:00
|
|
|
|
2014-04-24 17:42:16 +00:00
|
|
|
HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu, BOOL keyInitiated);
|
2014-03-07 22:28:55 +00:00
|
|
|
HRESULT PopupSubMenu(UINT itemId, UINT index, HMENU menu);
|
2014-04-15 10:08:08 +00:00
|
|
|
HRESULT TrackContextMenu(IContextMenu* contextMenu, POINT pt);
|
2014-02-24 11:59:34 +00:00
|
|
|
|
2014-04-02 17:37:37 +00:00
|
|
|
HRESULT KeyboardItemChange(DWORD changeType);
|
2014-02-24 11:59:34 +00:00
|
|
|
|
2014-10-28 15:39:47 +00:00
|
|
|
HRESULT PrepareExecuteItem(INT iItem);
|
|
|
|
HRESULT ExecuteItem();
|
2014-04-24 11:25:46 +00:00
|
|
|
|
2014-04-07 18:41:47 +00:00
|
|
|
HRESULT GetSizes(SIZE* pMinSize, SIZE* pMaxSize, SIZE* pIntegralSize);
|
2014-02-24 11:59:34 +00:00
|
|
|
HRESULT SetPosSize(int x, int y, int cx, int cy);
|
|
|
|
|
|
|
|
void InvalidateDraw();
|
|
|
|
|
2014-03-15 21:38:15 +00:00
|
|
|
HRESULT DisableMouseTrack(BOOL bDisable);
|
|
|
|
|
2014-03-11 10:42:25 +00:00
|
|
|
virtual HRESULT FillToolbar(BOOL clearFirst=FALSE) = 0;
|
2014-04-15 10:08:08 +00:00
|
|
|
|
2014-04-02 17:37:37 +00:00
|
|
|
HRESULT CancelCurrentPopup();
|
2014-04-24 17:42:16 +00:00
|
|
|
HRESULT PopupItem(INT iItem, BOOL keyInitiated);
|
2014-04-02 17:37:37 +00:00
|
|
|
HRESULT GetDataFromId(INT iItem, INT* pIndex, DWORD_PTR* pData);
|
|
|
|
|
|
|
|
HRESULT KillPopupTimer();
|
2014-03-03 10:19:35 +00:00
|
|
|
|
2014-12-18 17:34:46 +00:00
|
|
|
HRESULT MenuBarMouseDown(INT iIndex, BOOL isLButton);
|
2016-08-20 22:05:12 +00:00
|
|
|
HRESULT MenuBarMouseUp(INT iIndex, BOOL isLButton);
|
2014-07-09 00:42:05 +00:00
|
|
|
HRESULT ProcessClick(INT iItem);
|
2014-12-18 17:34:46 +00:00
|
|
|
HRESULT ProcessContextMenu(INT iItem);
|
2014-11-11 01:05:39 +00:00
|
|
|
HRESULT BeforeCancelPopup();
|
2014-06-29 15:42:06 +00:00
|
|
|
|
2014-02-24 11:59:34 +00:00
|
|
|
protected:
|
2014-03-11 10:42:25 +00:00
|
|
|
virtual HRESULT OnDeletingButton(const NMTOOLBAR * tb) = 0;
|
2014-04-15 10:08:08 +00:00
|
|
|
|
|
|
|
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax) = 0;
|
|
|
|
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData) = 0;
|
2014-04-24 17:42:16 +00:00
|
|
|
virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated) = 0;
|
2014-04-02 17:37:37 +00:00
|
|
|
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData) = 0;
|
2014-04-15 10:08:08 +00:00
|
|
|
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt) = 0;
|
2014-02-25 10:44:28 +00:00
|
|
|
|
2014-03-03 11:14:04 +00:00
|
|
|
HRESULT AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last);
|
|
|
|
HRESULT AddSeparator(BOOL last);
|
2014-03-03 10:19:35 +00:00
|
|
|
HRESULT AddPlaceholder();
|
2014-04-15 10:08:08 +00:00
|
|
|
HRESULT ClearToolbar();
|
2014-03-03 10:19:35 +00:00
|
|
|
|
2014-11-11 01:05:39 +00:00
|
|
|
HWND GetToolbar() { return m_hWnd; }
|
2014-03-11 10:42:25 +00:00
|
|
|
|
|
|
|
private:
|
2014-04-15 10:08:08 +00:00
|
|
|
HRESULT UpdateImageLists();
|
|
|
|
|
2014-04-02 17:37:37 +00:00
|
|
|
HRESULT OnPagerCalcSize(LPNMPGCALCSIZE csize);
|
2014-03-11 10:42:25 +00:00
|
|
|
HRESULT OnCustomDraw(LPNMTBCUSTOMDRAW cdraw, LRESULT * theResult);
|
2014-04-02 17:37:37 +00:00
|
|
|
HRESULT OnGetInfoTip(NMTBGETINFOTIP * tip);
|
2014-11-11 01:05:39 +00:00
|
|
|
|
|
|
|
LRESULT IsTrackedItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
LRESULT ChangeTrackedItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
LRESULT OnWinEventWrap(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
HRESULT OnPopupTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
|
|
|
|
BEGIN_MSG_MAP(CMenuToolbarBase)
|
|
|
|
MESSAGE_HANDLER(WM_USER_ISTRACKEDITEM, IsTrackedItem)
|
|
|
|
MESSAGE_HANDLER(WM_USER_CHANGETRACKEDITEM, ChangeTrackedItem)
|
|
|
|
MESSAGE_HANDLER(WM_COMMAND, OnWinEventWrap)
|
|
|
|
MESSAGE_HANDLER(WM_NOTIFY, OnWinEventWrap)
|
|
|
|
MESSAGE_HANDLER(WM_TIMER, OnPopupTimer)
|
|
|
|
END_MSG_MAP()
|
2014-02-24 11:59:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CMenuStaticToolbar :
|
|
|
|
public CMenuToolbarBase
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
HMENU m_hmenu;
|
2014-10-29 22:28:51 +00:00
|
|
|
HWND m_hwndMenu;
|
2014-02-24 11:59:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CMenuStaticToolbar(CMenuBand *menuBand);
|
2014-06-03 01:04:19 +00:00
|
|
|
virtual ~CMenuStaticToolbar();
|
2014-02-24 11:59:34 +00:00
|
|
|
|
|
|
|
HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
|
|
|
|
HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
|
|
|
|
|
2014-03-11 10:42:25 +00:00
|
|
|
virtual HRESULT FillToolbar(BOOL clearFirst=FALSE);
|
2014-02-24 11:59:34 +00:00
|
|
|
|
2014-03-03 10:19:35 +00:00
|
|
|
protected:
|
2014-03-11 10:42:25 +00:00
|
|
|
virtual HRESULT OnDeletingButton(const NMTOOLBAR * tb);
|
|
|
|
|
2014-04-15 10:08:08 +00:00
|
|
|
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax);
|
|
|
|
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData);
|
2014-04-24 17:42:16 +00:00
|
|
|
virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated);
|
2014-04-02 17:37:37 +00:00
|
|
|
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData);
|
2014-04-15 10:08:08 +00:00
|
|
|
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt);
|
2014-02-24 11:59:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CMenuSFToolbar :
|
|
|
|
public CMenuToolbarBase
|
|
|
|
{
|
|
|
|
private:
|
2014-03-05 12:34:30 +00:00
|
|
|
CComPtr<IShellFolder> m_shellFolder;
|
2014-02-24 11:59:34 +00:00
|
|
|
LPCITEMIDLIST m_idList;
|
|
|
|
HKEY m_hKey;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CMenuSFToolbar(CMenuBand *menuBand);
|
|
|
|
virtual ~CMenuSFToolbar();
|
|
|
|
|
|
|
|
HRESULT SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
|
|
|
|
HRESULT GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
|
|
|
|
|
2014-03-11 10:42:25 +00:00
|
|
|
virtual HRESULT FillToolbar(BOOL clearFirst=FALSE);
|
2014-02-24 11:59:34 +00:00
|
|
|
|
2014-03-03 10:19:35 +00:00
|
|
|
protected:
|
2014-03-11 10:42:25 +00:00
|
|
|
virtual HRESULT OnDeletingButton(const NMTOOLBAR * tb);
|
|
|
|
|
2014-04-15 10:08:08 +00:00
|
|
|
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax);
|
|
|
|
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData);
|
2014-04-24 17:42:16 +00:00
|
|
|
virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated);
|
2014-04-02 17:37:37 +00:00
|
|
|
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData);
|
2014-04-15 10:08:08 +00:00
|
|
|
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt);
|
2014-02-24 11:59:34 +00:00
|
|
|
};
|