// MainFrm.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 "MarkupPad.h" #include "PaneSamplesWnd.h" #include "MainFrm.h" #include "MarkupPadEdit.h" #include "MarkupPadView.h" #include "Controls/Util/XTPRegistryManager.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! ON_WM_CREATE() //}}AFX_MSG_MAP ON_XTP_CREATECONTROL() ON_MESSAGE(XTPWM_DOCKINGPANE_NOTIFY, OnDockingPaneNotify) ON_MESSAGE(XTPWM_TASKPANEL_NOTIFY, OnTaskPanelNotify) ON_COMMAND(ID_VIEW_RTL, CMainFrame::OnViewRTL) ON_UPDATE_COMMAND_UI(ID_VIEW_RTL, CMainFrame::OnUpdateViewRTL) ON_COMMAND(ID_SMOOTHINGMODE_APPLYTOTEXT, OnSmoothingModeApplyToText) ON_UPDATE_COMMAND_UI(ID_SMOOTHINGMODE_APPLYTOTEXT, OnUpdateSmoothingModeApplyToText) ON_COMMAND_RANGE(ID_SMOOTHINGMODE_DEFAULT, ID_SMOOTHINGMODE_NONE, OnSmoothingMode) ON_UPDATE_COMMAND_UI_RANGE(ID_SMOOTHINGMODE_DEFAULT, ID_SMOOTHINGMODE_NONE, OnUpdateSmoothingMode) ON_UPDATE_COMMAND_UI(ID_APPTHEME, OnThemeUpdate) ON_COMMAND_RANGE(ID_THEMEOFFICE2016_COLORFUL_ACCESS, ID_THEMEOFFICE2016_BLACK_WORD, OnThemeChanged) ON_UPDATE_COMMAND_UI_RANGE(ID_THEMEOFFICE2016_COLORFUL_ACCESS, ID_THEMEOFFICE2016_BLACK_WORD, OnUpdateThemeChanged) END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() : m_bRTL(FALSE) , m_DefaultSmoothingMode(xtpMarkupSmoothingDefault) , m_bDefaultTextSmoothing(FALSE) , m_nCurrentThemeID(ID_THEMEOFFICE2016_COLORFUL_WORD) { TCHAR szAppPath[_MAX_PATH]; VERIFY(::GetModuleFileName(GetModuleHandle(NULL), szAppPath, _MAX_PATH)); CString strAppPath(szAppPath); int nIndex = strAppPath.ReverseFind(_T('\\')); if (nIndex > 0) { strAppPath = strAppPath.Left(nIndex); } else { strAppPath.Empty(); } m_strMarkupsFolder = strAppPath + _T("\\Markups\\"); } CMainFrame::~CMainFrame() { } void CMainFrame::LoadVectorIcons() { CString type(_T("RT_XAML")); UINT nWidth = 0; nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_NEW, ID_FILE_NEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_FOLDER_OPEN, ID_FILE_OPEN, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SAVE, ID_FILE_SAVE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SAVEAS, ID_FILE_SAVE_AS, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CUT, ID_EDIT_CUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COPY, ID_EDIT_COPY, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PASTE, ID_EDIT_PASTE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COMMAND_UNDO_1, ID_EDIT_UNDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_COMMAND_REDO_1, ID_EDIT_REDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_BUTTON_HELP, ID_APP_ABOUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_EXIT, ID_APP_EXIT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_CLOSE, ID_FILE_CLOSE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PRINTER, ID_FILE_PRINT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PRINT_PREVIEW, ID_FILE_PRINT_PREVIEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_PRINT_SETUP, ID_FILE_PRINT_SETUP, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SEARCH, ID_EDIT_FIND, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_SELECT, ID_EDIT_SELECT_ALL, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_REPLACE, ID_EDIT_REPLACE, nWidth); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_NEW, ID_FILE_NEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_FOLDER_OPEN, ID_FILE_OPEN, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SAVE, ID_FILE_SAVE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SAVEAS, ID_FILE_SAVE_AS, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CUT, ID_EDIT_CUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COPY, ID_EDIT_COPY, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PASTE, ID_EDIT_PASTE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COMMAND_UNDO_1, ID_EDIT_UNDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_COMMAND_REDO_1, ID_EDIT_REDO, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_BUTTON_HELP, ID_APP_ABOUT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_EXIT, ID_APP_EXIT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_CLOSE, ID_FILE_CLOSE, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PRINTER, ID_FILE_PRINT, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PRINT_PREVIEW, ID_FILE_PRINT_PREVIEW, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_PRINT_SETUP, ID_FILE_PRINT_SETUP, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SEARCH, ID_EDIT_FIND, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_SELECT, ID_EDIT_SELECT_ALL, nWidth); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_NORMAL_REPLACE, ID_EDIT_REPLACE, nWidth); nWidth = XTP_DPI_X(16); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_NEW, ID_FILE_NEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_FOLDER_OPEN, ID_FILE_OPEN, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SAVE, ID_FILE_SAVE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SAVEAS, ID_FILE_SAVE_AS, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CUT, ID_EDIT_CUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COPY, ID_EDIT_COPY, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PASTE, ID_EDIT_PASTE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COMMAND_UNDO_1, ID_EDIT_UNDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_COMMAND_REDO_1, ID_EDIT_REDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_BUTTON_HELP, ID_APP_ABOUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_EXIT, ID_APP_EXIT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_CLOSE, ID_FILE_CLOSE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PRINTER, ID_FILE_PRINT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PRINT_PREVIEW, ID_FILE_PRINT_PREVIEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_PRINT_SETUP, ID_FILE_PRINT_SETUP, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SEARCH, ID_EDIT_FIND, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_SELECT, ID_EDIT_SELECT_ALL, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_REPLACE, ID_EDIT_REPLACE, nWidth, xtpImageDisabled); nWidth = XTP_DPI_X(32); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_NEW, ID_FILE_NEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_FOLDER_OPEN, ID_FILE_OPEN, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SAVE, ID_FILE_SAVE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SAVEAS, ID_FILE_SAVE_AS, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CUT, ID_EDIT_CUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COPY, ID_EDIT_COPY, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PASTE, ID_EDIT_PASTE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COMMAND_UNDO_1, ID_EDIT_UNDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_COMMAND_REDO_1, ID_EDIT_REDO, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_BUTTON_HELP, ID_APP_ABOUT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_EXIT, ID_APP_EXIT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_CLOSE, ID_FILE_CLOSE, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PRINTER, ID_FILE_PRINT, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PRINT_PREVIEW, ID_FILE_PRINT_PREVIEW, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_PRINT_SETUP, ID_FILE_PRINT_SETUP, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SEARCH, ID_EDIT_FIND, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_SELECT, ID_EDIT_SELECT_ALL, nWidth, xtpImageDisabled); XTPImageManager()->SetVectorIcon(type, IDR_XAML_LARGE_ICON_DISABLED_REPLACE, ID_EDIT_REPLACE, nWidth, xtpImageDisabled); } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // Create Status bar. // Important: All control bars including the Status Bar // must be created before CommandBars.... if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } m_wndStatusBar.EnableMarkup(); // Initialize the command bars if (!InitCommandBars()) return -1; // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if (pCommandBars == NULL) { TRACE0("Failed to create command bars object.\n"); return -1; // fail to create } // Add the menu bar CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); if (pMenuBar == NULL) { TRACE0("Failed to create menu bar.\n"); return -1; // fail to create } // Create ToolBar CXTPToolBar* pToolBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME, FALSE)) { TRACE0("Failed to create toolbar\n"); return -1; } LoadVectorIcons(); pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); if (theApp.m_hModule2016.GetModuleState() == CXTPModuleHandle::xtpModLoaded) { CXTPRegistryManager regMgr; int nThemeID = regMgr.GetProfileInt(_T("Settings"), _T("ApplicationTheme"), ID_THEMEOFFICE2016_COLORFUL_WORD); OnThemeChanged(nThemeID); } else { m_nCurrentThemeID = 0; } if (m_wndPane.Create(_T("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0)) { m_wndPane.SetTaskPanelOwner(this); m_wndPane.ResetToolboxItems(); SendMessageToDescendants(WM_REFRESHMETRICS, m_nCurrentThemeID); } m_paneManager.InstallDockingPanes(this); CXTPDockingPane* pPaneEdit = m_paneManager.CreatePane(ID_PANE_MARKUP, XTP_DPI(CRect(0, 0, 200, 200)), xtpPaneDockBottom); if (pPaneEdit) { pPaneEdit->SetTitle(_T("Markup")); pPaneEdit->SetOptions(xtpPaneNoCloseable); } CXTPDockingPane* pPaneSamples = m_paneManager.CreatePane(ID_PANE_SAMPLES, XTP_DPI(CRect(0, 0, 200, 200)), xtpPaneDockRight); if (pPaneSamples) { pPaneSamples->SetTitle(_T("Samples")); pPaneSamples->SetOptions(xtpPaneNoCloseable); } return 0; } void CMainFrame::OnViewRTL() { m_bRTL = !m_bRTL; // Apply RTL style to the views CDocument* pActiveDoc = GetActiveDocument(); if (NULL != pActiveDoc) { POSITION pos = pActiveDoc->GetFirstViewPosition(); while (NULL != pos) { CView* pView = pActiveDoc->GetNextView(pos); if (NULL != pView) { pView->ModifyStyleEx(!m_bRTL ? WS_EX_LAYOUTRTL : 0, m_bRTL ? WS_EX_LAYOUTRTL : 0); } } } // Apply RTL style to other components if (m_bRTL) { ModifyStyleEx(0, WS_EX_LAYOUTRTL); m_paneManager.ModifyStyleEx(0, WS_EX_LAYOUTRTL); m_pEditView->ModifyStyleEx(0, WS_EX_LAYOUTRTL); static_cast(m_pEditView)->GetEditCtrl().ModifyStyleEx(0, WS_EX_LAYOUTRTL); } else { ModifyStyleEx(WS_EX_LAYOUTRTL, 0); m_paneManager.ModifyStyleEx(WS_EX_LAYOUTRTL, 0); m_pEditView->ModifyStyleEx(WS_EX_LAYOUTRTL, 0); static_cast(m_pEditView)->GetEditCtrl().ModifyStyleEx(WS_EX_LAYOUTRTL, 0); } GetCommandBars()->SetLayoutRTL(m_bRTL); // Enforce re-drawing static_cast(m_pEditView)->OnChange(); m_paneManager.RedrawPanes(); m_pEditView->Invalidate(); m_pEditView->UpdateWindow(); Invalidate(); UpdateWindow(); } void CMainFrame::OnUpdateViewRTL(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_bRTL); } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if (!CFrameWnd::PreCreateWindow(cs)) return FALSE; cs.lpszClass = _T("XTPMainFrame"); CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME)); cs.style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam) { if (wParam == XTP_DPN_SHOWWINDOW) { // get a pointer to the docking pane being shown. CXTPDockingPane* pPane = (CXTPDockingPane*)lParam; if (!pPane->IsValid()) { switch (pPane->GetID()) { case ID_PANE_MARKUP: pPane->Attach(m_pEditView); static_cast(m_pEditView)->SetOwnerPane(pPane); break; case ID_PANE_SAMPLES: pPane->Attach(&m_wndPane); m_wndPane.SetOwnerPane(pPane); break; } } return TRUE; // handled } return FALSE; } LRESULT CMainFrame::OnTaskPanelNotify(WPARAM wParam, LPARAM lParam) { switch (wParam) { case XTP_TPN_CLICK: { CXTPTaskPanelGroupItem* pItem = (CXTPTaskPanelGroupItem*)lParam; _ASSERTE(pItem); CString filePath = pItem->GetTooltip(); AfxGetApp()->OpenDocumentFile(filePath); } break; } return 0; } BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { if (!CFrameWnd::OnCreateClient(lpcs, pContext)) return FALSE; pContext->m_pNewViewClass = RUNTIME_CLASS(CMarkupPadEdit); m_pEditView = (CView*)CreateView(pContext); m_pEditView->SetDlgCtrlID(0); return TRUE; } void CMainFrame::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState) { // Toggle CommandBars GetCommandBars()->OnSetPreviewMode(bPreview); // Toggle Docking Panes. m_paneManager.OnSetPreviewMode(bPreview); CFrameWnd::OnSetPreviewMode(bPreview, pState); } void CMainFrame::OnSmoothingModeApplyToText() { m_bDefaultTextSmoothing = !m_bDefaultTextSmoothing; UpdateMarkupViews(); } void CMainFrame::OnUpdateSmoothingModeApplyToText(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->SetCheck(m_bDefaultTextSmoothing); } void CMainFrame::OnSmoothingMode(UINT nCommand) { switch (nCommand) { case ID_SMOOTHINGMODE_DEFAULT: m_DefaultSmoothingMode = xtpMarkupSmoothingDefault; break; case ID_SMOOTHINGMODE_HIGHSPEED: m_DefaultSmoothingMode = xtpMarkupSmoothingHighSpeed; break; case ID_SMOOTHINGMODE_HIGHQUALITY: m_DefaultSmoothingMode = xtpMarkupSmoothingHighQuality; break; case ID_SMOOTHINGMODE_ANTIALIASING: m_DefaultSmoothingMode = xtpMarkupSmoothingAntiAlias; break; case ID_SMOOTHINGMODE_NONE: m_DefaultSmoothingMode = xtpMarkupSmoothingNone; break; default: _ASSERTE(!"Unexpected ID"); break; } UpdateMarkupViews(); } void CMainFrame::OnUpdateSmoothingMode(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); XTPMarkupSmoothingMode mode = xtpMarkupSmoothingDefault; switch (pCmdUI->m_nID) { case ID_SMOOTHINGMODE_DEFAULT: mode = xtpMarkupSmoothingDefault; break; case ID_SMOOTHINGMODE_HIGHSPEED: mode = xtpMarkupSmoothingHighSpeed; break; case ID_SMOOTHINGMODE_HIGHQUALITY: mode = xtpMarkupSmoothingHighQuality; break; case ID_SMOOTHINGMODE_ANTIALIASING: mode = xtpMarkupSmoothingAntiAlias; break; case ID_SMOOTHINGMODE_NONE: mode = xtpMarkupSmoothingNone; break; default: _ASSERTE(!"Unexpected ID"); break; } pCmdUI->SetCheck(m_DefaultSmoothingMode == mode); } void CMainFrame::UpdateMarkupViews() { CDocument* pActiveDoc = GetActiveDocument(); if (NULL != pActiveDoc) { POSITION pos = pActiveDoc->GetFirstViewPosition(); while (NULL != pos) { CView* pView = pActiveDoc->GetNextView(pos); if (NULL != pView) { CMarkupPadView* pMarkupView = DYNAMIC_DOWNCAST(CMarkupPadView, pView); if (NULL != pMarkupView) { pMarkupView->SetDefaultSmoothingMode(m_DefaultSmoothingMode); pMarkupView->SetDefaultTextSmoothing(m_bDefaultTextSmoothing); pMarkupView->Invalidate(); } } } } } void CMainFrame::OnThemeChanged(UINT nTheme) { if (m_nCurrentThemeID == 0) return; m_nCurrentThemeID = nTheme; CXTPRegistryManager regMgr; regMgr.WriteProfileInt(_T("Settings"), _T("ApplicationTheme"), m_nCurrentThemeID); CXTPCommandBars* pCommandBars = GetCommandBars(); _ASSERTE(pCommandBars); XTPPaintTheme nXTPTheme = xtpThemeOffice2013; XTPDockingPanePaintTheme nXTPPaneTheme = xtpPaneThemeOffice2013; HMODULE hModule = theApp.m_hModule2016; LPCTSTR lpszINI = xtpIniOffice2016WordColorful; BOOL bLightTheme = FALSE; switch (nTheme) { case ID_THEMEOFFICE2016_COLORFUL_ACCESS: lpszINI = xtpIniOffice2016AccessColorful; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_COLORFUL_EXCEL: lpszINI = xtpIniOffice2016ExcelColorful; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_COLORFUL_ONENOTE: lpszINI = xtpIniOffice2016OneNoteColorful; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_COLORFUL_OUTLOOK: lpszINI = xtpIniOffice2016OutlookColorful; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_COLORFUL_POWERPOINT: lpszINI = xtpIniOffice2016PowerPointColorful; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_COLORFUL_PUBLISHER: lpszINI = xtpIniOffice2016PublisherColorful; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_COLORFUL_WORD: lpszINI = xtpIniOffice2016WordColorful; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_WHITE_ACCESS: lpszINI = xtpIniOffice2016AccessWhite; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_WHITE_EXCEL: lpszINI = xtpIniOffice2016ExcelWhite; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_WHITE_ONENOTE: lpszINI = xtpIniOffice2016OneNoteWhite; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_WHITE_OUTLOOK: lpszINI = xtpIniOffice2016OutlookWhite; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_WHITE_POWERPOINT: lpszINI = xtpIniOffice2016PowerPointWhite; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_WHITE_PUBLISHER: lpszINI = xtpIniOffice2016PublisherWhite; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_WHITE_WORD: lpszINI = xtpIniOffice2016WordWhite; bLightTheme = TRUE; break; case ID_THEMEOFFICE2016_DARKGRAY_ACCESS: lpszINI = xtpIniOffice2016AccessDarkGray; break; case ID_THEMEOFFICE2016_DARKGRAY_EXCEL: lpszINI = xtpIniOffice2016ExcelDarkGray; break; case ID_THEMEOFFICE2016_DARKGRAY_ONENOTE: lpszINI = xtpIniOffice2016OneNoteDarkGray; break; case ID_THEMEOFFICE2016_DARKGRAY_OUTLOOK: lpszINI = xtpIniOffice2016OutlookDarkGray; break; case ID_THEMEOFFICE2016_DARKGRAY_POWERPOINT: lpszINI = xtpIniOffice2016PowerPointDarkGray; break; case ID_THEMEOFFICE2016_DARKGRAY_PUBLISHER: lpszINI = xtpIniOffice2016PublisherDarkGray; break; case ID_THEMEOFFICE2016_DARKGRAY_WORD: lpszINI = xtpIniOffice2016WordDarkGray; break; case ID_THEMEOFFICE2016_BLACK_ACCESS: lpszINI = xtpIniOffice2016AccessBlack; break; case ID_THEMEOFFICE2016_BLACK_EXCEL: lpszINI = xtpIniOffice2016ExcelBlack; break; case ID_THEMEOFFICE2016_BLACK_ONENOTE: lpszINI = xtpIniOffice2016OneNoteBlack; break; case ID_THEMEOFFICE2016_BLACK_OUTLOOK: lpszINI = xtpIniOffice2016OutlookBlack; break; case ID_THEMEOFFICE2016_BLACK_POWERPOINT: lpszINI = xtpIniOffice2016PowerPointBlack; break; case ID_THEMEOFFICE2016_BLACK_PUBLISHER: lpszINI = xtpIniOffice2016PublisherBlack; break; case ID_THEMEOFFICE2016_BLACK_WORD: lpszINI = xtpIniOffice2016WordBlack; break; default: lpszINI = xtpIniOffice2016WordColorful; } XTPResourceImages()->SetHandle(hModule, lpszINI); CXTPPaintManager::SetTheme(nXTPTheme); m_paneManager.SetTheme(nXTPPaneTheme); m_paneManager.EnableFloatingFrameTheme(TRUE); theApp.m_csPane.RefreshMetrics(nXTPPaneTheme); if (bLightTheme) theApp.m_csPane.m_clrMarkupText = RGB(0, 0, 0); static_cast(m_pEditView)->RefreshColors(nTheme); m_paneManager.SetClientMargin(XTP_DPI_X(1)); m_paneManager.GetPaintManager()->m_nSplitterSize = XTP_DPI_Y(2); pCommandBars->EnableFrameTheme(TRUE); pCommandBars->GetPaintManager()->m_bAutoResizeIcons = TRUE; pCommandBars->GetPaintManager()->m_bEnableAnimation = TRUE; pCommandBars->GetPaintManager()->RefreshMetrics(); GetCommandBars()->RedrawCommandBars(); m_paneManager.RedrawPanes(); RedrawWindow(0, 0, RDW_ALLCHILDREN | RDW_INVALIDATE); SendMessageToDescendants(WM_REFRESHMETRICS, m_nCurrentThemeID); } void CMainFrame::OnUpdateThemeChanged(CCmdUI* pCmdUI) { pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrentThemeID); pCmdUI->Enable(m_nCurrentThemeID != 0); } int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl) { if (lpCreateControl->nID == ID_APPTHEME) { CXTPControlPopup* pControl = CXTPControlPopup::CreateControlPopup(xtpControlPopup); pControl->SetFlags(xtpFlagRightAlign); CMenu mnuOptions; mnuOptions.LoadMenu(IDR_MENU_THEME); pControl->SetCommandBar(mnuOptions.GetSubMenu(0)); pControl->SetCaption(_T("Themes")); lpCreateControl->pControl = pControl; return TRUE; } return FALSE; } void CMainFrame::OnThemeUpdate(CCmdUI* pCmdUI) { pCmdUI->Enable(m_nCurrentThemeID != 0); }