Get rid of magic numbers
[TortoiseGit.git] / src / TortoiseMerge / NativeRibbonApp.h
blob5ef2b09942144ea400feab63c4f9bb8adbb37a5b
1 // Copyright (C) 2017 - TortoiseSVN
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software Foundation,
15 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 #pragma once
19 class CNativeRibbonDynamicItemInfo
21 public:
22 CNativeRibbonDynamicItemInfo(UINT cmdId, const CString& text, UINT imageId)
23 : m_CmdId(cmdId)
24 , m_Text(text)
25 , m_ImageId(imageId)
29 const CString & GetLabel() const { return m_Text; }
30 UINT GetCommandId() const { return m_CmdId; }
31 UINT GetImageId() const { return m_ImageId; }
32 private:
33 UINT m_CmdId;
34 CString m_Text;
35 UINT m_ImageId;
38 class CNativeRibbonApp : public IUIApplication, public IUICommandHandler
40 public:
41 CNativeRibbonApp(CFrameWnd* pFrame, IUIFramework* pFramework);
42 ~CNativeRibbonApp();
44 void SetSettingsFileName(const CString& file)
46 m_SettingsFileName = file;
49 void UpdateCmdUI(BOOL bDisableIfNoHandler);
50 int GetRibbonHeight();
51 void SetItems(UINT cmdId, const std::list<CNativeRibbonDynamicItemInfo>& items);
53 protected:
54 // IUnknown
55 STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
56 STDMETHOD_(ULONG, AddRef)(void);
57 STDMETHOD_(ULONG, Release)(void);
59 // IUIApplication
60 STDMETHOD(OnViewChanged)(UINT32 viewId, UI_VIEWTYPE typeID, IUnknown* view, UI_VIEWVERB verb, INT32 uReasonCode);
62 STDMETHOD(OnCreateUICommand)(UINT32 commandId, UI_COMMANDTYPE typeID, IUICommandHandler** commandHandler);
64 STDMETHOD(OnDestroyUICommand)(UINT32 commandId, UI_COMMANDTYPE typeID, IUICommandHandler* commandHandler);
66 // IUICommandHandler
67 STDMETHOD(Execute)(UINT32 commandId, UI_EXECUTIONVERB verb, const PROPERTYKEY* key, const PROPVARIANT* currentValue, IUISimplePropertySet* commandExecutionProperties);
69 STDMETHOD(UpdateProperty)(UINT32 commandId, REFPROPERTYKEY key, const PROPVARIANT* currentValue, PROPVARIANT* newValue);
71 HRESULT SaveRibbonViewSettings(IUIRibbon* pRibbonView, const CString& fileName);
72 HRESULT LoadRibbonViewSettings(IUIRibbon* pRibbonView, const CString& fileName);
73 CComPtr<IUICollection> GetUICommandItemsSource(UINT commandId);
74 void SetUICommandItemsSource(UINT commandId, IUICollection* pItems);
75 static UINT GetCommandIdProperty(IUISimplePropertySet* propertySet);
77 private:
78 CFrameWnd* m_pFrame;
79 CComPtr<IUIFramework> m_pFramework;
80 std::list<UINT32> m_commandIds;
81 std::list<UINT32> m_collectionCommandIds;
82 ULONG m_cRefCount;
83 CString m_SettingsFileName;