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.
19 class CNativeRibbonDynamicItemInfo
22 CNativeRibbonDynamicItemInfo(UINT cmdId
, const CString
& text
, UINT imageId
)
29 const CString
& GetLabel() const { return m_Text
; }
30 UINT
GetCommandId() const { return m_CmdId
; }
31 UINT
GetImageId() const { return m_ImageId
; }
38 class CNativeRibbonApp
: public IUIApplication
, public IUICommandHandler
41 CNativeRibbonApp(CFrameWnd
* pFrame
, IUIFramework
* pFramework
);
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
);
55 STDMETHOD(QueryInterface
)(REFIID riid
, void** ppvObject
);
56 STDMETHOD_(ULONG
, AddRef
)(void);
57 STDMETHOD_(ULONG
, Release
)(void);
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
);
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
);
79 CComPtr
<IUIFramework
> m_pFramework
;
80 std::list
<UINT32
> m_commandIds
;
81 std::list
<UINT32
> m_collectionCommandIds
;
83 CString m_SettingsFileName
;