// PropertiesPane.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 "GUI_VisualStudio.h" #include "PropertiesPane.h" #ifdef _DEBUG # define new DEBUG_NEW #endif IMPLEMENT_DYNAMIC(CPropertiesPane, CWnd); BEGIN_MESSAGE_MAP(CPropertiesPane, CWnd) ON_WM_CREATE() ON_WM_SIZE() ON_WM_PAINT() ON_WM_SETFOCUS() ON_MESSAGE(WM_XTP_SETCONTROLTHEME, OnSetControlTheme) ON_COMMAND(ID_PROPERTIES_CATEGORIZED, OnPanePropertiesCategorized) ON_UPDATE_COMMAND_UI(ID_PROPERTIES_CATEGORIZED, OnUpdatePanePropertiesCategorized) ON_COMMAND(ID_PROPERTIES_ALPHABETIC, OnPanePropertiesAlphabetic) ON_UPDATE_COMMAND_UI(ID_PROPERTIES_ALPHABETIC, OnUpdatePanePropertiesAlphabetic) END_MESSAGE_MAP() CPropertiesPane::CPropertiesPane() { m_pPane = NULL; m_rcMargin = CRect(0, 0, 0, 0); } CPropertiesPane::~CPropertiesPane() { } LRESULT CPropertiesPane::OnSetControlTheme(WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); XTPControlTheme nTheme = (XTPControlTheme)wParam; BOOL bVS2015Plus = ((nTheme == xtpControlThemeVisualStudio2015) || (nTheme == xtpControlThemeVisualStudio2017) || (nTheme == xtpControlThemeVisualStudio2019) || (nTheme == xtpControlThemeVisualStudio2022)); if (bVS2015Plus) m_rcMargin = CRect(XTP_DPI_X(1), 0, XTP_DPI_X(1), XTP_DPI_Y(1)); else m_rcMargin = CRect(0, 0, 0, 0); switch (nTheme) { case xtpControlThemeDefault: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeDefault); break; case xtpControlThemeVisualStudio2005: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2005); break; case xtpControlThemeVisualStudio2008: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2005); break; case xtpControlThemeVisualStudio2010: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2010); break; case xtpControlThemeVisualStudio2012Dark: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2012Dark); break; case xtpControlThemeVisualStudio2012Light: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2012Light); break; case xtpControlThemeVisualStudio2015: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2015); break; case xtpControlThemeVisualStudio2017: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2017); break; case xtpControlThemeVisualStudio2019: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2019); break; case xtpControlThemeVisualStudio2022: m_wndPropertyGrid.SetTheme(xtpPropertyGridThemeVisualStudio2022); break; default: ASSERT(FALSE); break; } LoadRasterIcons(); LoadVectorIcons(); return 0; } int CPropertiesPane::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) { TRACE(_T("ERROR: Unable to create properties pane.\n")); return -1; } if (!m_wndToolBar.CreateToolBar(WS_TABSTOP | WS_VISIBLE | WS_CHILD | CBRS_TOOLTIPS, this)) { TRACE(_T("ERROR: Unable to create properties pane toolbar.\n")); return -1; } m_wndToolBar.SetFlags(xtpFlagNoBorders); if (!m_wndToolBar.LoadToolBar(IDR_PROPERTIES_PANE, FALSE)) { TRACE(_T("ERROR: Unable to load properties pane toolbar.\n")); return -1; } if (!m_wndPropertyGrid.Create(CRect(0, 0, 0, 0), this, 0)) { TRACE(_T("ERROR: Unable to create properties pane grid.\n")); return -1; } m_wndPropertyGrid.SetOwner(this); LOGFONT lf; ::GetObject(::GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf); // Create document settings category. CXTPPropertyGridItem* pSettings = m_wndPropertyGrid.AddCategory(_T("Document Settings")); // Add child items to category. CXTPPropertyGridItem* pItemSaveOnClose = pSettings->AddChildItem( new CXTPPropertyGridItemBool(_T("SaveOnClose"), TRUE)); pSettings->AddChildItem(new CXTPPropertyGridItemFont(_T("WindowFont"), lf)); pSettings->AddChildItem(new CXTPPropertyGridItemSize(_T("WindowSize"), CSize(100, 100))); pSettings->Expand(); pItemSaveOnClose->Select(); // Create global settings category. CXTPPropertyGridItem* pGlobals = m_wndPropertyGrid.AddCategory(_T("Global Settings")); // Add child items to category. CXTPPropertyGridItem* pItemGreeting = pGlobals->AddChildItem( new CXTPPropertyGridItem(_T("Greeting Text"), _T("Welcome to your application!"))); pGlobals->AddChildItem(new CXTPPropertyGridItemNumber(_T("ItemsInMRUList"), 4)); CXTPPropertyGridItem* pItemRate = pGlobals->AddChildItem( new CXTPPropertyGridItemNumber(_T("MaxRepeatRate"), 10)); pGlobals->AddChildItem(new CXTPPropertyGridItemColor(_T("ToolbarColor"), RGB(255, 192, 128))); pItemGreeting->SetReadOnly(TRUE); pItemRate->SetDescription(_T("The rate in milliseconds that the text will repeat.")); // Create version category. CXTPPropertyGridItem* pVersion = m_wndPropertyGrid.AddCategory(_T("Version")); // Add child items to category. CXTPPropertyGridItem* pItemVersion = pVersion->AddChildItem( new CXTPPropertyGridItem(_T("AppVersion"), _T("1.0"))); CXTPPropertyGridItem* pItemLanguage = pVersion->AddChildItem( new CXTPPropertyGridItem(_T("Language"), _T("English (United States)"))); pItemVersion->SetReadOnly(TRUE); pVersion->Expand(); CXTPPropertyGridItemConstraints* pList = pItemLanguage->GetConstraints(); pList->AddConstraint(_T("Neutral")); pList->AddConstraint(_T("Arabic")); pList->AddConstraint(_T("German")); pList->AddConstraint(_T("Chinese(Taiwan)")); pList->AddConstraint(_T("English (United Kingdom)")); pList->AddConstraint(_T("English (United States)")); pList->AddConstraint(_T("France")); pList->AddConstraint(_T("Russian")); pItemLanguage->SetFlags(xtpPropertyGridItemHasComboButton | xtpPropertyGridItemHasEdit); // Create custom items category. CXTPPropertyGridItem* pCustom = m_wndPropertyGrid.AddCategory(_T("Custom Items")); // Add multi level tree node. CXTPPropertyGridItem* pItemOne = pCustom->AddChildItem( new CXTPPropertyGridItem(_T("First Level"), _T(""))); CXTPPropertyGridItem* pItemTwo = pItemOne->AddChildItem( new CXTPPropertyGridItem(_T("Second Level"), _T(""))); CXTPPropertyGridItem* pItemThird = pItemTwo->AddChildItem( new CXTPPropertyGridItem(_T("Third Level"), _T(""))); pItemThird->AddChildItem(new CXTPPropertyGridItem(_T("Fourth Level 1"), _T(""))); pItemThird->AddChildItem(new CXTPPropertyGridItem(_T("Fourth Level 2"), _T(""))); m_wndPropertyGrid.HighlightChangedItems(TRUE); m_wndPropertyGrid.SetBorderStyle(xtpPropertyGridBorderNone); return 0; } void CPropertiesPane::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); int x = m_rcMargin.left; int y = m_rcMargin.top; cx -= (x + m_rcMargin.right); cy -= (y + m_rcMargin.bottom); if (::IsWindow(m_wndToolBar)) { CSize sz = m_wndToolBar.CalcDockingLayout(cx, LM_HORZDOCK | LM_HORZ | LM_COMMIT); m_wndToolBar.MoveWindow(x, y, cx, sz.cy); m_wndToolBar.Invalidate(FALSE); y += sz.cy; cy -= sz.cy; } if (::IsWindow(m_wndPropertyGrid)) { m_wndPropertyGrid.MoveWindow(x, y, cx, cy); m_wndPropertyGrid.Invalidate(FALSE); } } void CPropertiesPane::OnPaint() { CPaintDC dc(this); if (!m_rcMargin.IsRectNull()) { CXTPClientRect rClient(this); theApp.GetPaneColorSet()->DrawBorders(&dc, rClient, m_pPane); } } void CPropertiesPane::OnPanePropertiesCategorized() { m_wndPropertyGrid.SetPropertySort(xtpPropertyGridSortCategorized); } void CPropertiesPane::OnUpdatePanePropertiesCategorized(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->SetCheck(m_wndPropertyGrid.GetPropertySort() == xtpPropertyGridSortCategorized); } void CPropertiesPane::OnPanePropertiesAlphabetic() { m_wndPropertyGrid.SetPropertySort(xtpPropertyGridSortAlphabetical); } void CPropertiesPane::OnUpdatePanePropertiesAlphabetic(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->SetCheck(m_wndPropertyGrid.GetPropertySort() == xtpPropertyGridSortAlphabetical); } void CPropertiesPane::OnSetFocus(CWnd* /*pOldWnd*/) { if (::IsWindow(m_wndPropertyGrid)) { m_wndPropertyGrid.SetFocus(); } } void CPropertiesPane::LoadRasterIcons() { CString strThemeSettings = theApp.GetAppThemeSettings(); UINT paneIcons = IDB_PROPERTIES; if (0 < strThemeSettings.Find(_T("BLUE"))) { paneIcons = IDB_PROPERTIES_LIGHT; } else if (0 < strThemeSettings.Find(_T("BLUEEXTRA"))) { paneIcons = IDB_PROPERTIES_LIGHT; } else if (0 < strThemeSettings.Find(_T("DARK"))) { paneIcons = IDB_PROPERTIES_DARK; } else if (0 < strThemeSettings.Find(_T("LIGHT"))) { paneIcons = IDB_PROPERTIES_LIGHT; } UINT buttons[] = { ID_PROPERTIES_CATEGORIZED, ID_PROPERTIES_ALPHABETIC, ID_PROPERTIES_PAGES }; XTPImageManager()->SetIcons(paneIcons, buttons, _countof(buttons), CSize(16, 16)); } void CPropertiesPane::LoadVectorIcons() { // }