//************************************************************************************ LRESULT CBCGPRadialMenu::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM) { CFrameWnd* pTarget = (CFrameWnd*)GetOwner(); if (pTarget == NULL || !pTarget->IsFrameWnd()) pTarget = BCGPGetParentFrame(this); if (pTarget != NULL) OnUpdateCmdUI(pTarget, (BOOL)wParam); return 0L; }
//**************************************************************************************** void CBCGPToolbarSystemMenuButton::OnDblClick (CWnd* pWnd) { if (CBCGPToolBar::IsCustomizeMode ()) { return; } ASSERT (pWnd != NULL); ////////////////////////////////////////////// // Make sure to close the popup menu and // find the MDI frame correctly. //-------------------------------------------- OnCancelMode (); CFrameWnd* pParentFrame = BCGPGetParentFrame (pWnd); 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); BOOL bCloseIsDisabled = FALSE; CMenu* pSysMenu = pChild->GetSystemMenu (FALSE); if (pSysMenu != NULL) { MENUITEMINFO menuInfo; ZeroMemory(&menuInfo,sizeof(MENUITEMINFO)); menuInfo.cbSize = sizeof(MENUITEMINFO); menuInfo.fMask = MIIM_STATE; pSysMenu->GetMenuItemInfo (SC_CLOSE, &menuInfo); bCloseIsDisabled = ((menuInfo.fState & MFS_GRAYED) || (menuInfo.fState & MFS_DISABLED)); } if (!bCloseIsDisabled) { pChild->SendMessage (WM_SYSCOMMAND, SC_CLOSE); } } //-------------------------------------------- ////////////////////////////////////////////// }
void CBCGPPrintPreviewToolBar::OnDestroy() { CFrameWnd* pParentFrame = BCGPGetParentFrame (this); ASSERT_VALID (pParentFrame); CBCGPDockManager* pDockManager = globalUtils.GetDockManager (pParentFrame); if (pDockManager != NULL) { pDockManager->RemoveControlBarFromDockManager (this, FALSE, FALSE, FALSE, NULL); } CBCGPToolBar::OnDestroy(); }
//*************************************************************************************** void CBCGPCaptionBar::AdjustLayout () { if (GetSafeHwnd () == NULL) { return; } CFrameWnd* pParent = BCGPGetParentFrame (this); if (pParent != NULL && pParent->GetSafeHwnd () != NULL) { pParent->RecalcLayout (); } RecalcLayout (); }
//************************************************************************** void CBCGPRibbonComboBox::OnSelectItem (int nItem) { ASSERT_VALID (this); SelectItem (nItem); m_RecentChangeEvt = CBCGPRibbonEdit::BCGPRIBBON_EDIT_CHANGED_FROM_DROPDOWN; NotifyCommand (TRUE); if (m_pParentMenu != NULL) { ASSERT_VALID (m_pParentMenu); if (m_pParentMenu->IsFloaty ()) { CBCGPRibbonFloaty* pFloaty = DYNAMIC_DOWNCAST ( CBCGPRibbonFloaty, m_pParentMenu->GetParent ()); if (pFloaty != NULL && !pFloaty->IsContextMenuMode ()) { if (m_pWndEdit->GetSafeHwnd () != NULL && m_pWndEdit->GetTopLevelFrame () != NULL) { m_pWndEdit->GetTopLevelFrame ()->SetFocus (); } Redraw (); return; } } CFrameWnd* pParentFrame = BCGPGetParentFrame (m_pParentMenu); ASSERT_VALID (pParentFrame); pParentFrame->PostMessage (WM_CLOSE); } else { if (m_pWndEdit->GetSafeHwnd () != NULL && m_pWndEdit->GetTopLevelFrame () != NULL) { m_bNotifyCommand = FALSE; m_pWndEdit->GetTopLevelFrame ()->SetFocus (); } Redraw (); } }
//****************************************************************************** void CBCGPPrintPreviewView::SetToolbarSize () { if (m_wndToolBar.GetSafeHwnd () == NULL) { return; } ASSERT_VALID (m_pToolBar); CSize szSize = m_wndToolBar.CalcFixedLayout (TRUE, TRUE); //---------------------------------------------------------------------- // Print toolbar should occupy the whole width of the mainframe (Win9x): //---------------------------------------------------------------------- CFrameWnd* pParent = BCGPGetParentFrame (this); ASSERT_VALID (pParent); CRect rectParent; pParent->GetClientRect (rectParent); szSize.cx = rectParent.Width (); CRect rectToolBar; m_wndToolBar.GetWindowRect (rectToolBar); pParent->ScreenToClient (rectToolBar); m_pToolBar->SetWindowPos (NULL, rectToolBar.left, rectToolBar.top, szSize.cx, szSize.cy, SWP_NOACTIVATE|SWP_SHOWWINDOW|SWP_NOZORDER); m_wndToolBar.SetWindowPos (NULL, 0, 0, szSize.cx, szSize.cy, SWP_NOACTIVATE|SWP_SHOWWINDOW|SWP_NOZORDER); //---------------------------------------------------- // Adjust parent toolbar (actually - dialog bar) size: //---------------------------------------------------- m_pToolBar->m_sizeDefault.cy = szSize.cy; if (m_recentToolbarSize == szSize) { return; } m_recentToolbarSize = szSize; pParent->RecalcLayout(); // position and size everything pParent->UpdateWindow(); }
//********************************************************************************* BCGCBPRODLLEXPORT void BCGPPrintPreview (CView* pView) { ASSERT_VALID (pView); #ifndef BCGP_EXCLUDE_RIBBON CFrameWnd* pParentFrame = BCGPGetParentFrame (pView); ASSERT_VALID (pParentFrame); CFrameWnd* pToplevelFrame = pParentFrame; if (pToplevelFrame->IsKindOf (RUNTIME_CLASS (CBCGPMDIChildWnd))) { pToplevelFrame = pToplevelFrame->GetTopLevelFrame (); } CBCGPRibbonBar* pWndRibbonBar = DYNAMIC_DOWNCAST (CBCGPRibbonBar, pToplevelFrame->GetDlgItem (AFX_IDW_RIBBON_BAR)); if (pWndRibbonBar != NULL && pWndRibbonBar->ShowBackstagePrintView()) { return; } #endif if (g_pActivePrintPreview != NULL && CWnd::FromHandlePermanent (g_pActivePrintPreview->GetSafeHwnd ()) != NULL) { return; } CPrintPreviewState *pState= new CPrintPreviewState; ASSERT (g_pPrintPreviewlocaRes == NULL); g_pPrintPreviewlocaRes = new CBCGPLocalResource; if (!pView->DoPrintPreview (IDD_BCGBAR_RES_PRINT_PREVIEW, pView, RUNTIME_CLASS (CBCGPPrintPreviewView), pState)) { TRACE0("Error: OnFilePrintPreview failed.\n"); AfxMessageBox (AFX_IDP_COMMAND_FAILURE); delete pState; // preview failed to initialize, delete State now } ASSERT (g_pPrintPreviewlocaRes == NULL); }
//********************************************************************************* void CBCGPPrintPreviewView::OnDisplayPageNumber (UINT nPage, UINT nPagesDisplayed) { ASSERT (m_pPreviewInfo != NULL); CFrameWnd* pParentFrame = BCGPGetParentFrame (this); ASSERT_VALID (pParentFrame); int nSubString = (nPagesDisplayed == 1) ? 0 : 1; CString s; if (AfxExtractSubString (s, m_pPreviewInfo->m_strPageDesc, nSubString)) { CString strPage; if (nSubString == 0) { strPage.Format (s, nPage); } else { UINT nEndPage = nPage + nPagesDisplayed - 1; strPage.Format (s, nPage, nEndPage); } if (m_pWndStatusBar != NULL) { m_pWndStatusBar->SetPaneText (iSimplePaneIndex, strPage); } else { pParentFrame->SendMessage (WM_SETMESSAGESTRING, 0, (LPARAM)(LPCTSTR) strPage); } } else { TRACE1("Malformed Page Description string. Could not get string %d.\n", nSubString); } }
BOOL CBCGPReBar::_AddBar(CWnd* pBar, REBARBANDINFO* pRBBI) { ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); ASSERT(pBar != NULL); ASSERT(::IsWindow(pBar->m_hWnd)); pRBBI->cbSize = globalData.GetRebarBandInfoSize (); pRBBI->fMask |= RBBIM_CHILD | RBBIM_CHILDSIZE; pRBBI->hwndChild = pBar->m_hWnd; CSize size; CBCGPControlBar* pTemp = DYNAMIC_DOWNCAST(CBCGPControlBar, pBar); if (pTemp != NULL) { size = pTemp->CalcFixedLayout(FALSE, m_dwStyle & CBRS_ORIENT_HORZ); pTemp->SetBCGStyle(pTemp->GetBCGStyle () & ~(CBRS_BCGP_AUTOHIDE | CBRS_BCGP_FLOAT)); pTemp->m_bIsRebarPane = TRUE; } else { CRect rect; pBar->GetWindowRect(&rect); size = rect.Size(); } //WINBUG: COMCTL32.DLL is off by 4 pixels in its sizing logic. Whatever // is specified as the minimum size, the system rebar will allow that band // to be 4 actual pixels smaller! That's why we add 4 to the size here. pRBBI->cxMinChild = size.cx; pRBBI->cyMinChild = size.cy; BOOL bResult = (BOOL)DefWindowProc(RB_INSERTBAND, (WPARAM)-1, (LPARAM)pRBBI); CFrameWnd* pFrameWnd = BCGPGetParentFrame(this); if (pFrameWnd != NULL) pFrameWnd->RecalcLayout(); return bResult; }
int CBCGPPrintPreviewView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CPreviewView::OnCreate(lpCreateStruct) == -1) { if (g_pPrintPreviewlocaRes != NULL) { delete g_pPrintPreviewlocaRes; g_pPrintPreviewlocaRes = NULL; } return -1; } g_pActivePrintPreview = this; ASSERT_VALID (m_pToolBar); CFrameWnd* pParentFrame = BCGPGetParentFrame (this); ASSERT_VALID (pParentFrame); CFrameWnd* pToplevelFrame = pParentFrame; if (pToplevelFrame->IsKindOf (RUNTIME_CLASS (CBCGPMDIChildWnd))) { pToplevelFrame = pToplevelFrame->GetTopLevelFrame (); } #ifndef BCGP_EXCLUDE_RIBBON m_pWndRibbonBar = DYNAMIC_DOWNCAST (CBCGPRibbonBar, pToplevelFrame->GetDlgItem (AFX_IDW_RIBBON_BAR)); if (m_pWndRibbonBar != NULL && m_pWndRibbonBar->IsVisible()) { m_pWndRibbonBar->SetPrintPreviewMode (); } else #endif { const UINT uiToolbarHotID = globalData.Is32BitIcons () ? IDR_BCGRES_PRINT_PREVIEW32 : 0; if (!m_wndToolBar.Create (m_pToolBar) || !m_wndToolBar.LoadToolBar( IDR_BCGRES_PRINT_PREVIEW, 0, 0, TRUE /* Locked */, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create print preview toolbar\n"); return FALSE; // fail to create } m_wndToolBar.SetOwner (this); //------------------------------------------- // Remember One Page/Two pages image indexes: //------------------------------------------- m_iPagesBtnIndex = m_wndToolBar.CommandToIndex (AFX_ID_PREVIEW_NUMPAGE); ASSERT (m_iPagesBtnIndex >= 0); CBCGPToolbarButton* pButton= m_wndToolBar.GetButton (m_iPagesBtnIndex); ASSERT_VALID (pButton); m_iOnePageImageIndex = pButton->GetImage (); int iIndex = m_wndToolBar.CommandToIndex (ID_BCGRES_TWO_PAGES_DUMMY); ASSERT (iIndex >= 0); pButton= m_wndToolBar.GetButton (iIndex); ASSERT_VALID (pButton); m_iTwoPageImageIndex = pButton->GetImage (); //--------------------------------- // Remove dummy "Two pages" button: //--------------------------------- m_wndToolBar.RemoveButton (iIndex); //------------------------------------ // Set "Print" button to image + text: //------------------------------------ m_wndToolBar.SetToolBarBtnText (m_wndToolBar.CommandToIndex (AFX_ID_PREVIEW_PRINT)); //--------------------------------- // Set "Close" button to text only: //--------------------------------- m_wndToolBar.SetToolBarBtnText (m_wndToolBar.CommandToIndex (AFX_ID_PREVIEW_CLOSE), NULL, TRUE, FALSE); CBCGPDockManager* pDockManager = globalUtils.GetDockManager (pParentFrame); ASSERT_VALID (pDockManager); pDockManager->AddControlBar (&m_wndToolBar, FALSE); //------------------------- // Change the Toolbar size: //------------------------- if (!m_bScaleLargeImages && m_wndToolBar.m_bLargeIcons) { m_wndToolBar.m_sizeCurButtonLocked = m_wndToolBar.m_sizeButtonLocked; m_wndToolBar.m_sizeCurImageLocked = m_wndToolBar.m_sizeImageLocked; } SetToolbarSize (); } //------------------------------------------- // Set Application Status Bar to Simple Text: //------------------------------------------- m_pWndStatusBar = DYNAMIC_DOWNCAST (CBCGPStatusBar, pToplevelFrame->GetDlgItem (AFX_IDW_STATUS_BAR)); if (m_pWndStatusBar != NULL) { //------------------------------------- // Set Simple Pane Style to No Borders: //------------------------------------- m_pWndStatusBar->SetPaneText (iSimplePaneIndex, NULL); } if (g_pPrintPreviewlocaRes != NULL) { delete g_pPrintPreviewlocaRes; g_pPrintPreviewlocaRes = NULL; } return 0; }
//******************************************************************************** void CBCGPRibbonBackstageViewPanel::Repos (CDC* pDC, const CRect& rect) { CBCGPRibbonMainPanel::Repos(pDC, rect); if (m_pSelected == NULL && !m_bIsCalcWidth) { CBCGPRibbonPanelMenuBar* pMenuBar = DYNAMIC_DOWNCAST(CBCGPRibbonPanelMenuBar, GetParentWnd()); if (pMenuBar != NULL) { CFrameWnd* pTarget = (CFrameWnd*) pMenuBar->GetCommandTarget (); if (pTarget == NULL || !pTarget->IsFrameWnd()) { pTarget = BCGPGetParentFrame(pMenuBar); } if (pTarget != NULL) { pMenuBar->OnUpdateCmdUI(pTarget, TRUE); } } if (m_pMainButton != NULL) { ASSERT_VALID(m_pMainButton); if (m_pMainButton->GetParentRibbonBar () != NULL) { ASSERT_VALID (m_pMainButton->GetParentRibbonBar ()); int nInitialPage = m_pMainButton->GetParentRibbonBar ()->GetInitialBackstagePage(); int nDefaultPage = m_pMainButton->GetParentRibbonBar ()->GetDefaultBackstagePage(); int nStartPage = (nInitialPage == -1) ? nDefaultPage : nInitialPage; if (nStartPage >= 0) { int nPage = 0; for (int i = 0; i < m_arElements.GetSize (); i++) { CBCGPBaseRibbonElement* pElem = m_arElements [i]; ASSERT_VALID (pElem); if (pElem->GetBackstageAttachedView() != NULL) { if (nPage == nStartPage) { if (!pElem->IsDisabled()) { m_pSelected = pElem; m_pSelected->m_bIsChecked = TRUE; } break; } nPage++; } } } } } if (m_pSelected == NULL) { for (int i = 0; i < m_arElements.GetSize (); i++) { CBCGPBaseRibbonElement* pElem = m_arElements [i]; ASSERT_VALID (pElem); if (!pElem->IsDisabled() && pElem->GetBackstageAttachedView() != NULL) { m_pSelected = pElem; m_pSelected->m_bIsChecked = TRUE; break; } } } if (m_pHighlighted == NULL) { m_pHighlighted = m_pSelected; } } m_rectRight = rect; m_rectRight.left = m_rectMenuElements.right; m_rectRight.top -= m_nScrollOffset; if (m_bIsCalcWidth) { return; } AdjustScrollBars(); ReposActiveForm(); }
void CBCGPReBar::OnRecalcParent() { CFrameWnd* pFrameWnd = BCGPGetParentFrame(this); ASSERT(pFrameWnd != NULL); pFrameWnd->RecalcLayout(); }