BOOL CBCGPRibbonDialogBar::Create(LPCTSTR lpszCaption, CWnd* pParentWnd, const RECT& rect, UINT nImagesSmall, UINT nImagesLarge, BOOL bHasGripper, UINT nID, DWORD dwStyle, DWORD dwTabbedStyle, DWORD dwBCGStyle, CCreateContext* pContext) { ASSERT_VALID (this); m_nImagesSmall = nImagesSmall; m_nImagesLarge = nImagesLarge; if (!CBCGPDockingControlBar::CreateEx (0, lpszCaption, pParentWnd, rect, bHasGripper, nID, dwStyle, dwTabbedStyle, dwBCGStyle, pContext)) { return FALSE; } SetOwner (BCGCBProGetTopLevelFrame (this)); return TRUE; }
//************************************************************************************* void CBCGPFrameWnd::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState) { ASSERT_VALID (this); CBCGPFrameWnd* pMainFrame = DYNAMIC_DOWNCAST (CBCGPFrameWnd, BCGCBProGetTopLevelFrame (this)); if (pMainFrame != NULL) { pMainFrame->SetPrintPreviewFrame (bPreview ? this : NULL); } m_dockManager.SetPrintPreviewMode (bPreview, pState); DWORD dwSavedState = pState->dwStates; CFrameWnd::OnSetPreviewMode (bPreview, pState); pState->dwStates = dwSavedState; AdjustDockingLayout (); RecalcLayout (); #ifndef BCGP_EXCLUDE_RIBBON if (m_Impl.m_pRibbonBar != NULL && m_Impl.m_pRibbonBar->IsReplaceFrameCaption ()) { PostMessage (BCGM_POSTSETPREVIEWFRAME, bPreview); } #endif }
int CUndoMenu::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMiniFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; DWORD toolbarStyle = dwDefaultToolbarStyle; if (m_AnimationType != NO_ANIMATION && !CBCGPToolBar::IsCustomizeMode ()) { toolbarStyle &= ~WS_VISIBLE; } if (!m_wndUndoBar.Create (this, toolbarStyle | CBRS_TOOLTIPS | CBRS_FLYBY, 1)) { TRACE(_T("Can't create popup menu bar\n")); return -1; } CWnd* pWndParent = GetParent (); ASSERT_VALID (pWndParent); m_wndUndoBar.SetOwner (pWndParent); m_wndUndoBar.SetBarStyle(m_wndUndoBar.GetBarStyle() | CBRS_TOOLTIPS); ActivatePopupMenu (BCGCBProGetTopLevelFrame (pWndParent), this); RecalcLayout (); return 0; }
//********************************************************************************************************* void CBCGPVisualManagerVS2008::OnEraseTabsArea (CDC* pDC, CRect rect, const CBCGPBaseTabWnd* pTabWnd) { ASSERT_VALID (pDC); ASSERT_VALID (pTabWnd); if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !pTabWnd->IsVS2005Style () || pTabWnd->IsDialogControl ()) { CBCGPVisualManagerVS2005::OnEraseTabsArea (pDC, rect, pTabWnd); return; } CFrameWnd* pMainFrame = BCGCBProGetTopLevelFrame (pTabWnd); if (pMainFrame->GetSafeHwnd () != NULL) { CRect rectMain; pMainFrame->GetClientRect (rectMain); pMainFrame->MapWindowPoints ((CBCGPTabWnd*)pTabWnd, &rectMain); rect.top = rectMain.top; rect.left = rectMain.left; rect.right = rect.left + globalData.m_rectVirtual.Width () + 10; } CBCGPDrawManager dm (*pDC); dm.FillGradient (rect, m_clrBarGradientDark, m_clrBarGradientLight, FALSE, 0); }
//****************************************************************************** void CBCGPDragFrameImpl::PlaceTabPreDocking (CBCGPBaseTabbedBar* pTabbedBar, BOOL bFirstTime) { if (m_nInsertedTabID != -1) { return; } if (!bFirstTime) { EndDrawDragFrame (FALSE); } CString strLabel; if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMultiMiniFrameWnd))) { CBCGPMultiMiniFrameWnd* pMultiMiniFrame = DYNAMIC_DOWNCAST (CBCGPMultiMiniFrameWnd, m_pDraggedWnd); if (pMultiMiniFrame != NULL) { CWnd* pBar = pMultiMiniFrame->GetFirstVisibleBar (); ASSERT_VALID (pBar); if (pBar != NULL) { pBar->GetWindowText (strLabel); } } } else { m_pDraggedWnd->GetWindowText (strLabel); } if (m_pWndDummy == NULL) { m_pWndDummy = new CBCGPDummyDockingControlBar; m_pWndDummy->CreateEx (0, _T (""), BCGCBProGetTopLevelFrame (m_pDraggedWnd), CRect (0, 0, 0, 0), FALSE, BCGP_DUMMY_WND_ID, WS_CHILD); } pTabbedBar->GetUnderlinedWindow ()->AddTab (m_pWndDummy, strLabel); CBCGPSmartDockingManager* pSDManager = NULL; if ((pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL && pSDManager->IsStarted()) { m_pDraggedWnd->ShowWindow (SW_HIDE); } m_nInsertedTabID = pTabbedBar->GetUnderlinedWindow ()->GetTabFromHwnd (*m_pWndDummy); m_pOldTargetBar = pTabbedBar; }
//*********************************************************************************************** void CBCGPRecentFilesListBox::OnChooseRecentFile(UINT uiCmd) { CFrameWnd* pParentFrame = BCGCBProGetTopLevelFrame (this); if (pParentFrame != NULL) { pParentFrame->PostMessage(WM_COMMAND, uiCmd); } CWnd* pParentDlg = GetParent(); if (pParentDlg != NULL) { CBCGPRibbonBackstageView* pBackstageView = DYNAMIC_DOWNCAST(CBCGPRibbonBackstageView, pParentDlg->GetParent()); if (pBackstageView != NULL) { pBackstageView->SendMessage(WM_CLOSE); } } }
//********************************************************************************************************* void CBCGPVisualManagerVS2008::OnEraseTabsButton (CDC* pDC, CRect rect, CBCGPButton* pButton, CBCGPBaseTabWnd* pBaseTab) { ASSERT_VALID (pDC); ASSERT_VALID (pButton); ASSERT_VALID (pBaseTab); if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !pBaseTab->IsVS2005Style () || pBaseTab->IsDialogControl () || pButton->IsPressed () || pButton->IsHighlighted ()) { CBCGPVisualManagerVS2005::OnEraseTabsButton (pDC, rect, pButton, pBaseTab); return; } CRgn rgn; rgn.CreateRectRgnIndirect (rect); pDC->SelectClipRgn (&rgn); CFrameWnd* pMainFrame = BCGCBProGetTopLevelFrame (pButton); if (pMainFrame->GetSafeHwnd () != NULL) { CRect rectMain; pMainFrame->GetClientRect (rectMain); pMainFrame->MapWindowPoints (pButton, &rectMain); rect.top = rectMain.top; rect.left = rectMain.left; rect.right = rect.left + globalData.m_rectVirtual.Width () + 10; } CBCGPDrawManager dm (*pDC); dm.FillGradient (rect, m_clrBarGradientDark, m_clrBarGradientLight, FALSE, 0); pDC->SelectClipRgn (NULL); }
//**************************************************************************************** void CBCGPToolbarSystemMenuButton::OnAfterCreatePopupMenu () { if (m_pPopupMenu != NULL && ::IsWindow (m_pPopupMenu->m_hWnd)) { CFrameWnd* pParentFrame = BCGCBProGetTopLevelFrame (m_pPopupMenu); if(pParentFrame != NULL && pParentFrame->IsKindOf (RUNTIME_CLASS (CMiniDockFrameWnd))) { pParentFrame = (CFrameWnd*) pParentFrame->GetParent (); } CMDIFrameWnd* pMDIFrame = DYNAMIC_DOWNCAST (CMDIFrameWnd, pParentFrame); if (pMDIFrame != NULL) { CMDIChildWnd* pChild = pMDIFrame->MDIGetActive (); ASSERT_VALID (pChild); m_pPopupMenu->SetMessageWnd (pChild); } } }
//**************************************************************************************** BOOL CBCGPDialogBar::Create(LPCTSTR lpszWindowName, CWnd* pParentWnd, BOOL bHasGripper, LPCTSTR lpszTemplateName, UINT nStyle, UINT nID, DWORD dwTabbedStyle, DWORD dwBCGStyle) { m_lpszBarTemplateName = (LPTSTR) lpszTemplateName; if (!CBCGPDockingControlBar::Create(lpszWindowName, pParentWnd, CSize (0, 0), bHasGripper, nID, nStyle, dwTabbedStyle, dwBCGStyle)) { return FALSE; } m_lpszBarTemplateName = NULL; SetOwner (BCGCBProGetTopLevelFrame (this)); if (m_sizeDialog != CSize (0, 0)) { SetWindowPos (NULL, -1, -1, m_sizeDialog.cx, m_sizeDialog.cy, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); } return TRUE; }
//********************************************************************************************************* void CBCGPVisualManagerVS2008::OnDrawTabResizeBar (CDC* pDC, CBCGPBaseTabWnd* pWndTab, BOOL bIsVert, CRect rect, CBrush* pbrFace, CPen* pPen) { ASSERT_VALID (pDC); ASSERT_VALID (pbrFace); ASSERT_VALID (pPen); ASSERT_VALID (pWndTab); if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || pWndTab->IsFlatTab ()) { CBCGPVisualManagerVS2005::OnDrawTabResizeBar (pDC, pWndTab, bIsVert, rect, pbrFace, pPen); return; } CRgn rgn; rgn.CreateRectRgnIndirect (rect); pDC->SelectClipRgn (&rgn); CFrameWnd* pMainFrame = BCGCBProGetTopLevelFrame (pWndTab); if (pMainFrame->GetSafeHwnd () != NULL) { CRect rectMain; pMainFrame->GetClientRect (rectMain); pMainFrame->MapWindowPoints (pWndTab, &rectMain); rect.top = rectMain.top; rect.left = rectMain.left; rect.right = rect.left + globalData.m_rectVirtual.Width () + 10; } CBCGPDrawManager dm (*pDC); dm.FillGradient (rect, m_clrBarGradientDark, m_clrBarGradientLight, FALSE, 0); pDC->SelectClipRgn (NULL); }
//*********************************************************************************************** void CBCGPRecentFilesListBox::OnChooseRecentFolder(LPCTSTR lpszFolder) { ASSERT(lpszFolder != NULL); CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, NULL, BCGCBProGetTopLevelFrame(this)); CWnd* pParentDlg = GetParent(); if (pParentDlg != NULL) { CBCGPRibbonBackstageView* pBackstageView = DYNAMIC_DOWNCAST(CBCGPRibbonBackstageView, pParentDlg->GetParent()); if (pBackstageView != NULL) { pBackstageView->SendMessage(WM_CLOSE); } } if (AfxGetApp() == NULL) { ASSERT(FALSE); return; } CString title; VERIFY(title.LoadString(AFX_IDS_OPENFILE)); CString strFilter; CString strDefault; CDocManager* pDocManager = AfxGetApp()->m_pDocManager; if (pDocManager != NULL) { BOOL bFirst = TRUE; for (POSITION pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;) { CDocTemplate* pTemplate = pDocManager->GetNextDocTemplate (pos); ASSERT_VALID (pTemplate); _BCGPAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, bFirst ? &strDefault : NULL); bFirst = FALSE; } } CString fileName; // append the "*.*" all files filter CString allFilter; VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER)); strFilter += allFilter; strFilter += (TCHAR)'\0'; // next string please strFilter += _T("*.*"); strFilter += (TCHAR)'\0'; // last string dlgFile.m_ofn.nMaxCustFilter++; dlgFile.m_ofn.lpstrFilter = strFilter; dlgFile.m_ofn.lpstrTitle = title; dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); dlgFile.m_ofn.lpstrInitialDir = lpszFolder; if (dlgFile.DoModal() == IDOK) { AfxGetApp()->OpenDocumentFile(fileName); } fileName.ReleaseBuffer(); }
//--------------------------------------------------------------------------------------// void CBCGPDragFrameImpl::MoveDragFrame (BOOL bForceMove) { ASSERT_VALID (m_pDraggedWnd); m_pFinalTargetBar = NULL; if (m_pDraggedWnd == NULL || m_pDockManager == NULL) { return; } if (m_pWndDummy == NULL) { m_pWndDummy = new CBCGPDummyDockingControlBar; m_pWndDummy->CreateEx (0, _T (""), BCGCBProGetTopLevelFrame (m_pDraggedWnd), CRect (0, 0, 0, 0), FALSE, BCGP_DUMMY_WND_ID, WS_CHILD); } CSize szSencitivity = CBCGPDockingControlBar::GetDragSencitivity (); CPoint ptMouse; GetCursorPos (&ptMouse); CPoint ptOffset = ptMouse - m_ptHot; if (abs (ptOffset.x) < szSencitivity.cx && abs (ptOffset.y) < szSencitivity.cy && m_rectDrag.IsRectEmpty () && !bForceMove) { return; } m_bDragStarted = TRUE; m_pDockManager->LockUpdate (TRUE); CRect rectOld = m_rectExpectedDocked.IsRectEmpty () ? m_rectDrag : m_rectExpectedDocked; BOOL bFirstTime = FALSE; if (m_rectDrag.IsRectEmpty ()) { if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd))) { m_pDraggedWnd->GetWindowRect (m_rectDrag); } else if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPControlBar))) { CBCGPControlBar* pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, m_pDraggedWnd); ASSERT_VALID (pBar); m_pDraggedWnd->GetWindowRect (m_rectDrag); // if the bar is docked then the floating rect has to be set to recent floating rect if (pBar->GetParentMiniFrame () == NULL) { m_rectDrag.right = m_rectDrag.left + pBar->m_recentDockInfo.m_rectRecentFloatingRect.Width (); m_rectDrag.bottom = m_rectDrag.top + pBar->m_recentDockInfo.m_rectRecentFloatingRect.Height (); } if (!m_rectDrag.PtInRect (m_ptHot)) { int nOffset = m_rectDrag.left - m_ptHot.x; m_rectDrag.OffsetRect (-nOffset - 5, 0); // offset of mouse pointer // from the drag rect bound } } bFirstTime = TRUE; } BOOL bDrawTab = FALSE; CBCGPDockingControlBar* pOldTargetBar = m_pTargetBar; CRect rectExpected; rectExpected.SetRectEmpty (); CBCGPSmartDockingManager* pSDManager = NULL; BOOL bSDockingIsOn = FALSE; if (m_pDockManager != NULL && (pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL && pSDManager->IsStarted()) { bSDockingIsOn = TRUE; } m_pDockManager->CalcExpectedDockedRect (m_pDraggedWnd, ptMouse, rectExpected, bDrawTab, &m_pTargetBar); if (pOldTargetBar != NULL && m_nInsertedTabID != -1 && (pOldTargetBar != m_pTargetBar || !bDrawTab)) { RemoveTabPreDocking (pOldTargetBar); bFirstTime = TRUE; } BOOL bCanBeAttached = TRUE; if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd))) { } else if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPControlBar))) { CBCGPControlBar* pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, m_pDraggedWnd); bCanBeAttached = pBar->CanBeAttached (); } if (m_pTargetBar != NULL && bCanBeAttached) { CBCGPBaseTabbedBar* pTabbedBar = DYNAMIC_DOWNCAST (CBCGPBaseTabbedBar, m_pTargetBar); if (pTabbedBar != NULL && bDrawTab && (pTabbedBar->GetVisibleTabsNum () > 1 && pTabbedBar->IsHideSingleTab () || pTabbedBar->GetVisibleTabsNum () > 0 && !pTabbedBar->IsHideSingleTab ())) { PlaceTabPreDocking (pTabbedBar, bFirstTime); return; } else if (bDrawTab) { if (m_nInsertedTabID != -1) { return; } if (!bFirstTime) { EndDrawDragFrame (FALSE); } DrawFrameTab (m_pTargetBar, FALSE); m_nInsertedTabID = 1; return; } } m_rectDrag.OffsetRect (ptOffset); m_ptHot = ptMouse; m_rectExpectedDocked = rectExpected; int nNewThickness = m_rectExpectedDocked.IsRectEmpty ()? globalData.m_nDragFrameThiknessFloat : globalData.m_nDragFrameThiknessDock; CRect rectDocked; if (m_rectExpectedDocked.IsRectEmpty ()) { if (!m_rectDrag.PtInRect (ptMouse)) { CPoint ptMiddleRect (m_rectDrag.TopLeft ().x + m_rectDrag.Width () / 2, m_rectDrag.top + 5); CPoint ptOffset = ptMouse - ptMiddleRect; m_rectDrag.OffsetRect (ptOffset); } rectDocked = m_rectDrag; } else { rectDocked = m_rectExpectedDocked; } if (!bSDockingIsOn || !m_rectExpectedDocked.IsRectEmpty ()) { DrawDragFrame (rectOld, rectDocked, bFirstTime, nNewThickness, m_nOldThikness); m_nOldThikness = nNewThickness; } }