// PaneCommandBars.cpp // // (c)1998-2025 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "CommandBarsDesigner.h" #include "EmbeddedFrame.h" #include "PaneCommandBars.h" #include "ResourceManager.h" #include "DialogListEditor.h" #include "PropertyItemFlags.h" #include "IPCData.h" #include "MainFrm.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define PAINT_THEME_OFFICE_2016 _T("xtpThemeOffice2016") static const struct { LPCTSTR lpName; XTPPaintTheme nTheme; } g_lpThemes[] = { { _T("xtpThemeNone"), xtpThemeNone }, { _T("xtpThemeCustom"), xtpThemeCustom }, { _T("xtpThemeNativeWinXP"), xtpThemeNativeWinXP }, { _T("xtpThemeResource"), xtpThemeResource }, { _T("xtpThemeRibbon"), xtpThemeRibbon }, { _T("xtpThemeOffice2000"), xtpThemeOffice2000 }, { _T("xtpThemeOfficeXP"), xtpThemeOfficeXP }, { _T("xtpThemeOffice2003"), xtpThemeOffice2003 }, { _T("xtpThemeOffice2007System"), xtpThemeOffice2007System }, { _T("xtpThemeOffice2013"), xtpThemeOffice2013 }, { _T("xtpThemeOffice2016"), xtpThemeOffice2016 }, { _T("xtpThemeVisualStudio6"), xtpThemeVisualStudio6 }, { _T("xtpThemeVisualStudio2005"), xtpThemeVisualStudio2005 }, { _T("xtpThemeVisualStudio2008"), xtpThemeVisualStudio2008 }, { _T("xtpThemeVisualStudio2010"), xtpThemeVisualStudio2010 }, { _T("xtpThemeVisualStudio2012"), xtpThemeVisualStudio2012 }, { _T("xtpThemeVisualStudio2015"), xtpThemeVisualStudio2015 }, { _T("xtpThemeVisualStudio2017"), xtpThemeVisualStudio2017 }, { _T("xtpThemeVisualStudio2019"), xtpThemeVisualStudio2019 }, { _T("xtpThemeVisualStudio2022"), xtpThemeVisualStudio2022 }, { _T("xtpThemeNativeWindows10"), xtpThemeNativeWindows10 } }; static const struct THEME_STYLES_INFO { #define THEME_STYLE_ENTRY(name) \ { \ _T(#name), name \ } XTPPaintTheme nTheme; BOOL bEnableFrameTheme; BOOL m_bThemeOffice2016; struct { LPCTSTR lpName; LPCTSTR lpValue; } styles[30]; } g_ThemeStyles[] = { { xtpThemeResource, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniWindows7Blue), THEME_STYLE_ENTRY(xtpIniOffice2007Aqua), THEME_STYLE_ENTRY(xtpIniOffice2007Blue), THEME_STYLE_ENTRY(xtpIniOffice2007Black), THEME_STYLE_ENTRY(xtpIniOffice2007Silver), THEME_STYLE_ENTRY(xtpIniOffice2010Blue), THEME_STYLE_ENTRY(xtpIniOffice2010Black), THEME_STYLE_ENTRY(xtpIniOffice2010Silver), } }, { xtpThemeRibbon, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniWindows7Blue), THEME_STYLE_ENTRY(xtpIniOffice2007Aqua), THEME_STYLE_ENTRY(xtpIniOffice2007Blue), THEME_STYLE_ENTRY(xtpIniOffice2007Black), THEME_STYLE_ENTRY(xtpIniOffice2007Silver), THEME_STYLE_ENTRY(xtpIniOffice2010Blue), THEME_STYLE_ENTRY(xtpIniOffice2010Black), THEME_STYLE_ENTRY(xtpIniOffice2010Silver), } }, { xtpThemeOffice2013, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniOffice2013Access), THEME_STYLE_ENTRY(xtpIniOffice2013Excel), THEME_STYLE_ENTRY(xtpIniOffice2013OneNote), THEME_STYLE_ENTRY(xtpIniOffice2013Outlook), THEME_STYLE_ENTRY(xtpIniOffice2013PowerPoint), THEME_STYLE_ENTRY(xtpIniOffice2013Publisher), THEME_STYLE_ENTRY(xtpIniOffice2013Word), THEME_STYLE_ENTRY(xtpIniOffice2013AccessGrayDark), THEME_STYLE_ENTRY(xtpIniOffice2013ExcelGrayDark), THEME_STYLE_ENTRY(xtpIniOffice2013OneNoteGrayDark), THEME_STYLE_ENTRY(xtpIniOffice2013OutlookGrayDark), THEME_STYLE_ENTRY(xtpIniOffice2013PowerPointGrayDark), THEME_STYLE_ENTRY(xtpIniOffice2013PublisherGrayDark), THEME_STYLE_ENTRY(xtpIniOffice2013WordGrayDark), THEME_STYLE_ENTRY(xtpIniOffice2013AccessGrayLight), THEME_STYLE_ENTRY(xtpIniOffice2013ExcelGrayLight), THEME_STYLE_ENTRY(xtpIniOffice2013OneNoteGrayLight), THEME_STYLE_ENTRY(xtpIniOffice2013OutlookGrayLight), THEME_STYLE_ENTRY(xtpIniOffice2013PowerPointGrayLight), THEME_STYLE_ENTRY(xtpIniOffice2013PublisherGrayLight), THEME_STYLE_ENTRY(xtpIniOffice2013WordGrayLight) } }, { xtpThemeOffice2016, TRUE, TRUE, { THEME_STYLE_ENTRY(xtpIniOffice2016AccessColorful), THEME_STYLE_ENTRY(xtpIniOffice2016ExcelColorful), THEME_STYLE_ENTRY(xtpIniOffice2016OneNoteColorful), THEME_STYLE_ENTRY(xtpIniOffice2016OutlookColorful), THEME_STYLE_ENTRY(xtpIniOffice2016PowerPointColorful), THEME_STYLE_ENTRY(xtpIniOffice2016PublisherColorful), THEME_STYLE_ENTRY(xtpIniOffice2016WordColorful), THEME_STYLE_ENTRY(xtpIniOffice2016AccessWhite), THEME_STYLE_ENTRY(xtpIniOffice2016ExcelWhite), THEME_STYLE_ENTRY(xtpIniOffice2016OneNoteWhite), THEME_STYLE_ENTRY(xtpIniOffice2016OutlookWhite), THEME_STYLE_ENTRY(xtpIniOffice2016PowerPointWhite), THEME_STYLE_ENTRY(xtpIniOffice2016PublisherWhite), THEME_STYLE_ENTRY(xtpIniOffice2016WordWhite), THEME_STYLE_ENTRY(xtpIniOffice2016AccessDarkGray), THEME_STYLE_ENTRY(xtpIniOffice2016ExcelDarkGray), THEME_STYLE_ENTRY(xtpIniOffice2016OneNoteDarkGray), THEME_STYLE_ENTRY(xtpIniOffice2016OutlookDarkGray), THEME_STYLE_ENTRY(xtpIniOffice2016PowerPointDarkGray), THEME_STYLE_ENTRY(xtpIniOffice2016PublisherDarkGray), THEME_STYLE_ENTRY(xtpIniOffice2016WordDarkGray), THEME_STYLE_ENTRY(xtpIniOffice2016AccessBlack), THEME_STYLE_ENTRY(xtpIniOffice2016ExcelBlack), THEME_STYLE_ENTRY(xtpIniOffice2016OneNoteBlack), THEME_STYLE_ENTRY(xtpIniOffice2016OutlookBlack), THEME_STYLE_ENTRY(xtpIniOffice2016PowerPointBlack), THEME_STYLE_ENTRY(xtpIniOffice2016PublisherBlack), THEME_STYLE_ENTRY(xtpIniOffice2016WordBlack) } }, { xtpThemeVisualStudio2012, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniVisualStudio2012Light), THEME_STYLE_ENTRY(xtpIniVisualStudio2012Dark) } }, { xtpThemeVisualStudio2015, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniVisualStudio2015Blue), THEME_STYLE_ENTRY(xtpIniVisualStudio2015Dark), THEME_STYLE_ENTRY(xtpIniVisualStudio2015Light) } }, { xtpThemeVisualStudio2017, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniVisualStudio2017Blue), THEME_STYLE_ENTRY(xtpIniVisualStudio2017BlueExtra), THEME_STYLE_ENTRY(xtpIniVisualStudio2017Dark), THEME_STYLE_ENTRY(xtpIniVisualStudio2017Light) } }, { xtpThemeVisualStudio2019, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniVisualStudio2019Blue), THEME_STYLE_ENTRY(xtpIniVisualStudio2019BlueExtra), THEME_STYLE_ENTRY(xtpIniVisualStudio2019Dark), THEME_STYLE_ENTRY(xtpIniVisualStudio2019Light) } }, { xtpThemeVisualStudio2022, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniVisualStudio2022Blue), THEME_STYLE_ENTRY(xtpIniVisualStudio2022BlueExtra), THEME_STYLE_ENTRY(xtpIniVisualStudio2022Dark), THEME_STYLE_ENTRY(xtpIniVisualStudio2022Light) } }, { xtpThemeNativeWindows10, TRUE, FALSE, { THEME_STYLE_ENTRY(xtpIniWindows10Light), THEME_STYLE_ENTRY(xtpIniWindows10Dark) } } }; ///////////////////////////////////////////////////////////////////////////// // CPaneCommandBars CPaneCommandBars::CPaneCommandBars() : m_pCommandBars(NULL) , m_pActivePane(NULL) , m_bCommandBarsChanged(FALSE) , m_bThemeOffice2016(FALSE) , m_isActivePreviewView(FALSE) { m_nTheme = DefaultTheme; } BEGIN_MESSAGE_MAP(CPaneCommandBars, CWnd) ////{{AFX_MSG_MAP(CPaneCommandBars) ON_WM_CREATE() ON_WM_SIZE() ON_WM_SETFOCUS() ON_COMMAND(ID_PANEPROPERTIES_CATEGORIZED, OnPaneCategorized) ON_UPDATE_COMMAND_UI(ID_PANEPROPERTIES_CATEGORIZED, OnUpdatePaneCategorized) ON_COMMAND(ID_PANEPROPERTIES_ALPHABETIC, OnPaneAlphabetic) ON_UPDATE_COMMAND_UI(ID_PANEPROPERTIES_ALPHABETIC, OnUpdatePaneAlphabetic) ON_MESSAGE(XTPWM_PROPERTYGRID_NOTIFY, OnGridNotify) ////}}AFX_MSG_MAP END_MESSAGE_MAP() void CPaneCommandBars::Refresh(CXTPCommandBars* pActiveCommandBars /*= NULL*/) { _ASSERTE(NULL != m_hWnd); if (m_pCommandBars != pActiveCommandBars) { m_pCommandBars = pActiveCommandBars; m_bCommandBarsChanged = TRUE; } RefreshPane(); m_bCommandBarsChanged = FALSE; } void CPaneCommandBars::RefreshPane() { m_wndGrid.ResetContent(); if (NULL == m_pCommandBars) return; RefreshSettings(); FillGeneralProperties(); FillPaintManagerProperties(); FillPreviewProperties(); UpdatePreviewSettings(); } void CPaneCommandBars::RefreshSettings() { ASSERT_VALID(m_pCommandBars); CXTPCommandBarsOptions* pOptions = m_pCommandBars->GetCommandBarsOptions(); ASSERT_VALID(pOptions); m_settings.bAlwaysShowFullMenus = pOptions->bAlwaysShowFullMenus; m_settings.bLargeIcons = pOptions->bLargeIcons; m_settings.bShowFullAfterDelay = pOptions->bShowFullAfterDelay; m_settings.bToolBarAccelTips = pOptions->bToolBarAccelTips; m_settings.bToolBarScreenTips = pOptions->bToolBarScreenTips; m_settings.szIcons = pOptions->szIcons; m_settings.szLargeIcons = pOptions->szLargeIcons; m_settings.szPopupIcons = pOptions->szPopupIcons; m_settings.bShowExpandButtonAlways = pOptions->bShowExpandButtonAlways; m_settings.bSyncFloatingBars = pOptions->bSyncFloatingBars; m_settings.bDblClickFloat = pOptions->bDblClickFloat; m_settings.bShowTextBelowIcons = pOptions->bShowTextBelowIcons; m_settings.bAltDragCustomization = pOptions->bAltDragCustomization; m_settings.bAutoHideUnusedPopups = pOptions->bAutoHideUnusedPopups; m_settings.nAnimationType = pOptions->animationType; m_settings.nKeyboardCuesShow = pOptions->GetShowKeyboardCues(); m_settings.nKeyboardCuesUse = pOptions->keyboardCuesUse; XTP_COMMANDBARS_ICONSINFO* pIconsInfo = m_pCommandBars->GetPaintManager()->GetIconsInfo(); _ASSERTE(NULL != pIconsInfo); m_settings.bIconsWithShadow = pIconsInfo->bIconsWithShadow; m_settings.bUseDisabledIcons = pIconsInfo->bUseDisabledIcons; m_settings.bUseFadedIcons = pIconsInfo->bUseFadedIcons; CEmbeddedFrame* pFrame = DYNAMIC_DOWNCAST(CEmbeddedFrame, m_pCommandBars->GetSite()); ASSERT_VALID(pFrame); m_settings.theme = pFrame->m_theme; m_bThemeOffice2016 = pFrame->m_bThemeOffice2016; m_settings.strPreviewINIStyle = pFrame->m_strPreviewINIStyle; m_settings.bCustomizable = pFrame->m_bCustomizable; } void CPaneCommandBars::FillGeneralProperties() { CXTPPropertyGridItem* pCategory = m_wndGrid.AddCategory(_T("General")); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Customizable"), m_settings.bCustomizable, &m_settings.bCustomizable)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Always Show Full Menus"), m_settings.bAlwaysShowFullMenus, &m_settings.bAlwaysShowFullMenus)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Show Full Menus After Delay"), m_settings.bShowFullAfterDelay, &m_settings.bShowFullAfterDelay)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Show ScreenTips on Toolbars"), m_settings.bToolBarScreenTips, &m_settings.bToolBarScreenTips)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Show Shortcut Keys in ScreenTips"), m_settings.bToolBarAccelTips, &m_settings.bToolBarAccelTips)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Show Expand Buttons Always"), m_settings.bShowExpandButtonAlways, &m_settings.bShowExpandButtonAlways)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Large Icons"), m_settings.bLargeIcons, &m_settings.bLargeIcons)); pCategory->AddChildItem( new CXTPPropertyGridItemSize(_T("Icons Size"), m_settings.szIcons, &m_settings.szIcons)); pCategory->AddChildItem(new CXTPPropertyGridItemSize(_T("Large Icons Size"), m_settings.szLargeIcons, &m_settings.szLargeIcons)); pCategory->AddChildItem(new CXTPPropertyGridItemSize(_T("Popup Icons Size"), m_settings.szPopupIcons, &m_settings.szPopupIcons)); CXTPPropertyGridItem* pItemAnimation = pCategory->AddChildItem( new CXTPPropertyGridItemEnum(_T("Menu Animation"), m_settings.nAnimationType, (int*)&m_settings.nAnimationType)); pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateWindowsDefault"), xtpAnimateWindowsDefault); pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateRandom"), xtpAnimateRandom); pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateUnfold"), xtpAnimateUnfold); pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateSlide"), xtpAnimateSlide); pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateFade"), xtpAnimateFade); pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateNone"), xtpAnimateNone); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Sync Floating Toolbars"), m_settings.bSyncFloatingBars, &m_settings.bSyncFloatingBars)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Float Toolbars by DblClick "), m_settings.bDblClickFloat, &m_settings.bDblClickFloat)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Show Text Below Icons"), m_settings.bShowTextBelowIcons, &m_settings.bShowTextBelowIcons)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("AltDrag Customization"), m_settings.bAltDragCustomization, &m_settings.bAltDragCustomization)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Auto Hide Unused Popups"), m_settings.bAutoHideUnusedPopups, &m_settings.bAutoHideUnusedPopups)); CXTPPropertyGridItem* pItemKeyboardCuesShow = pCategory->AddChildItem( new CXTPPropertyGridItemEnum(_T("Show Keyboard Cues"), m_settings.nKeyboardCuesShow, (int*)&m_settings.nKeyboardCuesShow)); pItemKeyboardCuesShow->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesShowAlways"), xtpKeyboardCuesShowAlways); pItemKeyboardCuesShow->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesShowNever"), xtpKeyboardCuesShowNever); pItemKeyboardCuesShow->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesShowWindowsDefault"), xtpKeyboardCuesShowWindowsDefault); CXTPPropertyGridItem* pItemKeyboardCuesUse = pCategory->AddChildItem( new CXTPPropertyGridItemEnum(_T("Use Keyboard Cues"), m_settings.nKeyboardCuesUse, (int*)&m_settings.nKeyboardCuesUse)); pItemKeyboardCuesUse->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesUseMenuOnly"), xtpKeyboardCuesUseMenuOnly); pItemKeyboardCuesUse->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesUseAll"), xtpKeyboardCuesUseAll); pItemKeyboardCuesUse->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesUseNone"), xtpKeyboardCuesUseNone); pCategory->Expand(); } void CPaneCommandBars::FillPaintManagerProperties() { CXTPPropertyGridItem* pCategory = m_wndGrid.AddCategory(_T("Paint Manager")); CXTPPropertyGridItem* pItemTheme = pCategory->AddChildItem( new CXTPPropertyGridItemEnum(ID_GRID_ITEM_THEME, m_settings.theme, (int*)&m_settings.theme)); CXTPPropertyGridItemConstraints* pConstrants = pItemTheme->GetConstraints(); for (int i = 0; i < _countof(g_lpThemes); i++) pConstrants->AddConstraint(g_lpThemes[i].lpName, static_cast(g_lpThemes[i].nTheme)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(ID_GRID_ITEM_ICONS_SHADOW, m_settings.bIconsWithShadow, &m_settings.bIconsWithShadow)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(_T("Generate disabled icons"), m_settings.bUseDisabledIcons, &m_settings.bUseDisabledIcons)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(ID_GRID_ITEM_ICONS_FADED, m_settings.bUseFadedIcons, &m_settings.bUseFadedIcons)); pCategory->Expand(); } void CPaneCommandBars::FillPreviewProperties() { CXTPPropertyGridItem* pCategory = m_wndGrid.AddCategory(_T("Preview")); pCategory->AddChildItem(new CXTPPropertyGridItemEnum(ID_GRID_ITEM_INI_STYLE)); pCategory->AddChildItem(new CXTPPropertyGridItemBool(ID_GRID_ITEM_FRAME_THEME_ENABLED, m_settings.bPreviewFrameThemeEnabled, &m_settings.bPreviewFrameThemeEnabled)); pCategory->Expand(); } void CPaneCommandBars::CommitOptionsChanges() { ASSERT_VALID(m_pCommandBars); CXTPCommandBarsOptions* pOptions = m_pCommandBars->GetCommandBarsOptions(); _ASSERTE(NULL != pOptions); pOptions->bAlwaysShowFullMenus = m_settings.bAlwaysShowFullMenus; pOptions->bLargeIcons = m_settings.bLargeIcons; pOptions->bShowFullAfterDelay = m_settings.bShowFullAfterDelay; pOptions->bToolBarAccelTips = m_settings.bToolBarAccelTips; pOptions->bToolBarScreenTips = m_settings.bToolBarScreenTips; pOptions->szIcons = m_settings.szIcons; pOptions->szLargeIcons = m_settings.szLargeIcons; pOptions->szPopupIcons = m_settings.szPopupIcons; pOptions->bShowExpandButtonAlways = m_settings.bShowExpandButtonAlways; pOptions->bSyncFloatingBars = m_settings.bSyncFloatingBars; pOptions->bDblClickFloat = m_settings.bDblClickFloat; pOptions->bShowTextBelowIcons = m_settings.bShowTextBelowIcons; pOptions->bAltDragCustomization = m_settings.bAltDragCustomization; pOptions->bAutoHideUnusedPopups = m_settings.bAutoHideUnusedPopups; pOptions->animationType = m_settings.nAnimationType; pOptions->ShowKeyboardCues(m_settings.nKeyboardCuesShow); pOptions->keyboardCuesUse = m_settings.nKeyboardCuesUse; CEmbeddedFrame* pFrame = DYNAMIC_DOWNCAST(CEmbeddedFrame, m_pCommandBars->GetSite()); ASSERT_VALID(pFrame); pFrame->m_theme = m_settings.theme; pFrame->m_bThemeOffice2016 = m_bThemeOffice2016; pFrame->m_strPreviewINIStyle = m_settings.strPreviewINIStyle; pFrame->m_bCustomizable = m_settings.bCustomizable; PREVIEW_SETTINGS previewSettings; memset(&previewSettings, 0, sizeof(previewSettings)); previewSettings.theme = m_settings.theme; previewSettings.bFrameThemeEnabled = m_settings.bPreviewFrameThemeEnabled; if (!m_settings.strPreviewINIStyle.IsEmpty()) { STRCPY_S(previewSettings.szStyle, _countof(previewSettings.szStyle), m_settings.strPreviewINIStyle); } pFrame->SetPreviewSettings(&previewSettings); if (m_isActivePreviewView) pFrame->UpdatePreview(); XTP_COMMANDBARS_ICONSINFO* pIconsInfo = m_pCommandBars->GetPaintManager()->GetIconsInfo(); _ASSERTE(NULL != pIconsInfo); pIconsInfo->bIconsWithShadow = m_settings.bIconsWithShadow; pIconsInfo->bUseDisabledIcons = m_settings.bUseDisabledIcons; pIconsInfo->bUseFadedIcons = m_settings.bUseFadedIcons; m_pCommandBars->RedrawCommandBars(); m_pCommandBars->RecalcFrameLayout(); } void CPaneCommandBars::UpdatePreviewSettings(BOOL bForceUpdate /*= FALSE*/) { if (m_bCommandBarsChanged) { bForceUpdate = TRUE; } const THEME_STYLES_INFO* pStyleInfo = NULL; for (int i = 0; i < _countof(g_ThemeStyles); ++i) { if ((m_bThemeOffice2016 && g_ThemeStyles[i].m_bThemeOffice2016) || (!m_bThemeOffice2016 && g_ThemeStyles[i].nTheme == m_settings.theme)) { pStyleInfo = &g_ThemeStyles[i]; break; } } if (m_bThemeOffice2016) { CXTPPropertyGridItemEnum* pTheme = DYNAMIC_DOWNCAST(CXTPPropertyGridItemEnum, m_wndGrid.FindItem(ID_GRID_ITEM_THEME)); if (pTheme) { CXTPPropertyGridItemConstraints* pThemeConstraints = pTheme->GetConstraints(); if (pThemeConstraints) { for (int i = 0; i < pThemeConstraints->GetCount(); ++i) { CXTPPropertyGridItemConstraint* pThemeConstraint = pThemeConstraints->GetConstraintAt(i); if (pThemeConstraint) { if (PAINT_THEME_OFFICE_2016 == pThemeConstraint->m_strConstraint) { pTheme->SetEnum(pThemeConstraint); break; } } } } } } CXTPPropertyGridItemEnum* pINIStyles = DYNAMIC_DOWNCAST(CXTPPropertyGridItemEnum, m_wndGrid.FindItem(ID_GRID_ITEM_INI_STYLE)); _ASSERTE(NULL != pINIStyles); CXTPPropertyGridItemConstraints* pINIConstraints = pINIStyles->GetConstraints(); _ASSERTE(NULL != pINIConstraints); CXTPPropertyGridItemConstraint* pFirstINIConstraint = NULL; pINIStyles->GetConstraints()->RemoveAll(); pINIStyles->SetEnum(NULL); if (NULL != pStyleInfo) { _ASSERTE(NULL != pStyleInfo->styles[0].lpValue); for (int i = 0; i < _countof(pStyleInfo->styles) && NULL != pStyleInfo->styles[i].lpName; ++i) { CXTPPropertyGridItemConstraint* pConstraint = pINIConstraints->AddConstraint( pStyleInfo->styles[i].lpName, reinterpret_cast(pStyleInfo->styles[i].lpValue)); if (NULL == pFirstINIConstraint && m_settings.strPreviewINIStyle == reinterpret_cast(pConstraint->m_dwData)) { pFirstINIConstraint = pConstraint; } } pFirstINIConstraint = pFirstINIConstraint != NULL ? pFirstINIConstraint : pINIConstraints->GetConstraintAt(0); } if (NULL != pStyleInfo) { if (bForceUpdate) { m_settings.bPreviewFrameThemeEnabled = pStyleInfo->bEnableFrameTheme; if (NULL != pFirstINIConstraint) { pINIStyles->SetEnum(pFirstINIConstraint); _ASSERTE(0 != pFirstINIConstraint->m_dwData); m_settings.strPreviewINIStyle = reinterpret_cast( pFirstINIConstraint->m_dwData); } else { m_settings.strPreviewINIStyle = _T(""); } } else { for (int i = 0; i < pINIConstraints->GetCount(); ++i) { CXTPPropertyGridItemConstraint* pConstraint = pINIConstraints->GetConstraintAt(i); _ASSERTE(NULL != pConstraint); LPCTSTR lpStyle = reinterpret_cast(pConstraint->m_dwData); if (NULL != lpStyle && m_settings.strPreviewINIStyle == lpStyle) { pINIStyles->SetEnum(pConstraint); break; } } } } else { m_settings.bPreviewFrameThemeEnabled = FALSE; m_settings.strPreviewINIStyle = _T(""); } CXTPPropertyGridItemBool* pFrameThemeEnabled = DYNAMIC_DOWNCAST( CXTPPropertyGridItemBool, m_wndGrid.FindItem(ID_GRID_ITEM_FRAME_THEME_ENABLED)); _ASSERTE(NULL != pFrameThemeEnabled); pFrameThemeEnabled->SetBool(m_settings.bPreviewFrameThemeEnabled); } void CPaneCommandBars::RefreshTheme() { if (DefaultTheme == m_nTheme) { m_wndGrid.SetTheme(xtpPropertyGridThemeVisualStudio2005); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeDefault); } else { m_wndGrid.SetTheme(xtpPropertyGridThemeOffice2013); SendMessageToDescendants(WM_XTP_SETCONTROLTHEME, xtpControlThemeOffice2013); } } int CPaneCommandBars::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; VERIFY(m_wndToolBar.CreateToolBar(WS_TABSTOP | WS_VISIBLE | WS_CHILD | CBRS_TOOLTIPS, this)); VERIFY(m_wndToolBar.LoadToolBar(IDR_PANE_COMMANDBARS, FALSE)); m_wndToolBar.SetIconSize(XTP_DPI_SIZE(CSize(16, 16))); XTPImageManager()->SetVectorIcon(_T("RT_XAML"), IDR_XAML_ICON_NORMAL_LIST, ID_PANEPROPERTIES_CATEGORIZED, XTP_DPI_X(16)); XTPImageManager()->SetVectorIcon(_T("RT_XAML"), IDR_XAML_ICON_NORMAL_SORT_TEXT, ID_PANEPROPERTIES_ALPHABETIC, XTP_DPI_X(16)); XTPImageManager()->SetVectorIcon(_T("RT_XAML"), IDR_XAML_ICON_NORMAL_TOOL_WRENCH, ID_PANEPROPERTIES_PAGES, XTP_DPI_X(16)); XTPImageManager()->SetVectorIcon(_T("RT_XAML"), IDR_XAML_ICON_DISABLED_LIST, ID_PANEPROPERTIES_CATEGORIZED, XTP_DPI_X(16), xtpImageDisabled); XTPImageManager()->SetVectorIcon(_T("RT_XAML"), IDR_XAML_ICON_DISABLED_SORT_TEXT, ID_PANEPROPERTIES_ALPHABETIC, XTP_DPI_X(16), xtpImageDisabled); XTPImageManager()->SetVectorIcon(_T("RT_XAML"), IDR_XAML_ICON_DISABLED_TOOL_WRENCH, ID_PANEPROPERTIES_PAGES, XTP_DPI_X(16), xtpImageDisabled); VERIFY(m_wndGrid.Create(CRect(0, 0, 0, 0), this, 0)); m_wndGrid.SetBorderStyle(xtpPropertyGridBorderNone); RefreshTheme(); return 0; } void CPaneCommandBars::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); CSize sz(0); if (m_wndToolBar.GetSafeHwnd()) { sz = m_wndToolBar.CalcDockingLayout(cx, LM_HORZDOCK | LM_HORZ | LM_COMMIT); m_wndToolBar.MoveWindow(0, 0, cx, sz.cy); m_wndToolBar.Invalidate(FALSE); } if (m_wndGrid.GetSafeHwnd()) { m_wndGrid.MoveWindow(0, sz.cy, cx, cy - sz.cy); } } void CPaneCommandBars::OnSetFocus(CWnd*) { m_wndGrid.SetFocus(); } void CPaneCommandBars::OnPaneCategorized() { m_wndGrid.SetPropertySort(xtpPropertyGridSortCategorized); } void CPaneCommandBars::OnUpdatePaneCategorized(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_wndGrid.GetPropertySort() == xtpPropertyGridSortCategorized); } void CPaneCommandBars::OnPaneAlphabetic() { m_wndGrid.SetPropertySort(xtpPropertyGridSortAlphabetical); } void CPaneCommandBars::OnUpdatePaneAlphabetic(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_wndGrid.GetPropertySort() == xtpPropertyGridSortAlphabetical); } LRESULT CPaneCommandBars::OnGridNotify(WPARAM wParam, LPARAM lParam) { if (wParam == XTP_PGN_ITEMVALUE_CHANGED) { CXTPPropertyGridItem* pItem = reinterpret_cast(lParam); ASSERT_VALID(pItem); switch (pItem->GetID()) { case ID_GRID_ITEM_THEME: { CString strTheme = pItem->GetValue(); CEmbeddedFrame* pFrame = GetMainFrame()->GetActiveEmbeddedFrame(); if (pFrame) { if (pFrame->GetCommandBars() && pFrame->GetCommandBars()->GetMenuBar() && pFrame->GetCommandBars()->GetMenuBar()->IsRibbonBar()) { if (!IsThemeSupportedByRibbon(strTheme)) { AfxMessageBox(ID_THEME_IS_NOT_SUPPORTED_BY_RIBBON); strTheme = L"xtpThemeOffice2016"; } } } m_bThemeOffice2016 = (PAINT_THEME_OFFICE_2016 == strTheme) ? TRUE : FALSE; for (int i = 0; i < _countof(g_lpThemes); i++) { if (strTheme == g_lpThemes[i].lpName) { switch (g_lpThemes[i].nTheme) { case xtpThemeOfficeXP: (DYNAMIC_DOWNCAST(CXTPPropertyGridItemBool, m_wndGrid.FindItem(ID_GRID_ITEM_ICONS_SHADOW))) ->SetBool(TRUE); (DYNAMIC_DOWNCAST(CXTPPropertyGridItemBool, m_wndGrid.FindItem(ID_GRID_ITEM_ICONS_FADED))) ->SetBool(TRUE); break; case xtpThemeNativeWinXP: (DYNAMIC_DOWNCAST(CXTPPropertyGridItemBool, m_wndGrid.FindItem(ID_GRID_ITEM_ICONS_SHADOW))) ->SetBool(FALSE); (DYNAMIC_DOWNCAST(CXTPPropertyGridItemBool, m_wndGrid.FindItem(ID_GRID_ITEM_ICONS_FADED))) ->SetBool(TRUE); break; default: (DYNAMIC_DOWNCAST(CXTPPropertyGridItemBool, m_wndGrid.FindItem(ID_GRID_ITEM_ICONS_SHADOW))) ->SetBool(FALSE); (DYNAMIC_DOWNCAST(CXTPPropertyGridItemBool, m_wndGrid.FindItem(ID_GRID_ITEM_ICONS_FADED))) ->SetBool(FALSE); break; } break; } } UpdatePreviewSettings(TRUE); break; } case ID_GRID_ITEM_INI_STYLE: { m_settings.strPreviewINIStyle = _T(""); CXTPPropertyGridItemEnum* pEnum = DYNAMIC_DOWNCAST(CXTPPropertyGridItemEnum, pItem); _ASSERTE(NULL != pEnum); CXTPPropertyGridItemConstraints* pConstraints = pEnum->GetConstraints(); if (NULL != pConstraints && !pConstraints->IsEmpty()) { CXTPPropertyGridItemConstraint* pConstraint = pConstraints->GetConstraintAt( pConstraints->GetCurrent()); if (NULL != pConstraint && 0 != pConstraint->m_dwData) { m_settings.strPreviewINIStyle = reinterpret_cast( pConstraint->m_dwData); } } break; } } CommitOptionsChanges(); } return FALSE; } BOOL CPaneCommandBars::IsThemeSupportedByRibbon(CString strTheme) { BOOL isSupported = FALSE; for (int i = 0; i < _countof(g_lpThemes); i++) { if (strTheme == g_lpThemes[i].lpName) { switch (g_lpThemes[i].nTheme) { case xtpThemeResource: case xtpThemeRibbon: case xtpThemeOffice2007System: case xtpThemeOffice2013: // case xtpThemeOffice2016: case xtpThemeVisualStudio2015: case xtpThemeVisualStudio2017: case xtpThemeVisualStudio2019: case xtpThemeVisualStudio2022: case xtpThemeNativeWindows10: isSupported = TRUE; break; default: isSupported = FALSE; break; } } } return isSupported; }