// WorkspaceView.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 "MultiLangRibbon.h" #include "MultiLangRibbonDoc.h" #include "WorkspaceView.h" #include "MultiLangRibbonView.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWorkspaceView IMPLEMENT_DYNCREATE(CWorkspaceView, CView) CWorkspaceView::CWorkspaceView() { m_pView = 0; } CWorkspaceView::~CWorkspaceView() { } BEGIN_MESSAGE_MAP(CWorkspaceView, CView) //{{AFX_MSG_MAP(CWorkspaceView) ON_WM_CREATE() ON_WM_SIZE() ON_WM_ERASEBKGND() ON_WM_PAINT() ON_WM_VSCROLL() // ON_WM_XTP_THEMECHANGED() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWorkspaceView drawing void CWorkspaceView::OnDraw(CDC* /*pDC*/) { } ///////////////////////////////////////////////////////////////////////////// // CWorkspaceView diagnostics #ifdef _DEBUG void CWorkspaceView::AssertValid() const { CView::AssertValid(); } void CWorkspaceView::Dump(CDumpContext& dc) const { CView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CWorkspaceView message handlers int CWorkspaceView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; ModifyStyleEx(WS_EX_CLIENTEDGE, 0); CCreateContext contextT; contextT.m_pCurrentDoc = GetDocument(); contextT.m_pNewViewClass = RUNTIME_CLASS(CMultiLangRibbonView); contextT.m_pNewDocTemplate = GetDocument()->GetDocTemplate(); TRY { m_pView = (CMultiLangRibbonView*)contextT.m_pNewViewClass->CreateObject(); if (m_pView == NULL) { AfxThrowMemoryException(); } } CATCH_ALL(e) { TRACE0("Out of memory creating a view.\n"); // Note: DELETE_EXCEPTION(e) not required return FALSE; } END_CATCH_ALL DWORD dwStyle = AFX_WS_DEFAULT_VIEW; dwStyle &= ~WS_BORDER; // Create with the right size (wrong position) CRect rect(0, 0, 0, 0); if (!m_pView->Create(NULL, NULL, dwStyle, rect, this, AFX_IDW_PANE_FIRST, &contextT)) { TRACE0("Warning: couldn't create client tab for view.\n"); // pWnd will be cleaned up by PostNcDestroy return NULL; } m_pView->ModifyStyle(0, WS_BORDER, SWP_FRAMECHANGED); m_pView->ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED); m_pView->SetOwner(this); GetParentFrame()->SetActiveView(m_pView); m_wndScrollBar[SB_VERT].Create(WS_CHILD | WS_VISIBLE | SBS_VERT, CRect(10, 10, 50, 50), this, 100); m_wndScrollBar[SB_VERT].SetScrollBarStyle(xtpScrollStyleOffice2007Dark); // m_wndScrollBar[SB_HORZ].Create(WS_CHILD | WS_VISIBLE | SBS_HORZ, CRect(10, 10, 50, 50), this, // 100); m_wndScrollBar[SB_HORZ].SetScrollBarStyle(xtpScrollStyleOffice2007Dark); return 0; } void CWorkspaceView::Reposition(CSize sz) { BOOL bBothVisible = m_wndScrollBar[SB_VERT].GetSafeHwnd() && m_wndScrollBar[SB_HORZ].GetSafeHwnd(); if (m_wndScrollBar[SB_VERT].GetSafeHwnd()) { int nWidth = GetSystemMetrics(SM_CXVSCROLL); m_wndScrollBar[SB_VERT].MoveWindow( sz.cx - nWidth, 0, nWidth, sz.cy - (bBothVisible ? GetSystemMetrics(SM_CYHSCROLL) : 0)); } if (m_wndScrollBar[SB_HORZ].GetSafeHwnd()) { int nHeight = GetSystemMetrics(SM_CYHSCROLL); m_wndScrollBar[SB_HORZ].MoveWindow( 0, sz.cy - nHeight, sz.cx - (bBothVisible ? GetSystemMetrics(SM_CXVSCROLL) : 0), nHeight); } if (m_pView) { CRect rc(GetViewRect(CRect(0, 0, sz.cx, sz.cy))); m_pView->MoveWindow(rc); } } void CWorkspaceView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); Reposition(CSize(cx, cy)); } CRect CWorkspaceView::GetViewRect(CRect rc) { if (m_wndScrollBar[SB_VERT].GetSafeHwnd()) { int nWidth = GetSystemMetrics(SM_CXVSCROLL); rc.right -= nWidth; } if (m_wndScrollBar[SB_HORZ].GetSafeHwnd()) { int nHeight = GetSystemMetrics(SM_CYHSCROLL); rc.bottom -= nHeight; } m_pView->CalcWindowRect(&rc, 0); return rc; } BOOL CWorkspaceView::OnEraseBkgnd(CDC* /*pDC*/) { return TRUE; } void CWorkspaceView::OnPaint() { CPaintDC dc(this); CXTPClientRect rc(this); // dc.FillSolidRect(&rc, RGB(255, 255, 255)); if (m_wndScrollBar[SB_VERT].GetSafeHwnd()) { rc.right -= CXTPWindowRect(&m_wndScrollBar[SB_VERT]).Width(); } if (m_wndScrollBar[SB_HORZ].GetSafeHwnd()) { rc.bottom -= CXTPWindowRect(&m_wndScrollBar[SB_HORZ]).Height(); } CXTPWindowRect rcClient(GetDlgItem(AFX_IDW_PANE_FIRST)); ScreenToClient(&rcClient); XTPPaintManager()->FillWorkspace(&dc, rc, rcClient); } void CWorkspaceView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { m_pView->OnVScroll(nSBCode, nPos, pScrollBar); } BOOL CWorkspaceView::PreCreateWindow(CREATESTRUCT& cs) { // Prevent main view to drawn on top of the auto-hide panes with set these window styles. cs.style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; return CView::PreCreateWindow(cs); }