//********************************************************************** void CBCGPRibbonCustomizeRibbonPage::OnToolbarReset() { #ifndef BCGP_EXCLUDE_GRID_CTRL ASSERT_VALID (m_pRibbonBar); CBCGPLocalResource locaRes; if (AfxMessageBox (IDS_BCGBARRES_RESET_RIBBON, MB_YESNO | MB_ICONWARNING) != IDYES) { return; } // Mark all custom data as "to be deleted": for (int i = 0; i < m_wndRibbonTreeDest.GetRowCount(); i++) { CBCGPGridRow* pRow = m_wndRibbonTreeDest.GetRow(i); if (pRow == NULL) { continue; } CObject* lpData = (CObject*)pRow->GetData(); if (lpData == NULL) { continue; } CBCGPRibbonCategory* pCategory = DYNAMIC_DOWNCAST(CBCGPRibbonCategory, lpData); if (pCategory != NULL && pCategory->IsCustom()) { pCategory->m_bToBeDeleted = TRUE; } else { CBCGPRibbonPanel* pPanel = DYNAMIC_DOWNCAST(CBCGPRibbonPanel, lpData); if (pPanel != NULL && pPanel->IsCustom()) { pPanel->m_bToBeDeleted = TRUE; } } } m_CustomizationData.ResetAll(m_pRibbonBar); RebuildDestTree(); #endif }
void CBCGPRibbonConstructor::ConstructPanel (CBCGPRibbonPanel& panel, const CBCGPRibbonInfo::XPanel& info) const { panel.SetKeys (info.m_strKeys); panel.SetJustifyColumns (info.m_bJustifyColumns); panel.SetCenterColumnVert (info.m_bCenterColumnVert); ConstructElement (panel.GetLaunchButton (), info.m_btnLaunch); int i = 0; for (i = 0; i < info.m_arElements.GetSize (); i++) { CBCGPBaseRibbonElement* pElement = CreateElement (*(const CBCGPRibbonInfo::XElement*)info.m_arElements[i]); if (pElement != NULL) { ASSERT_VALID (pElement); CBCGPRibbonSeparator* pSeparator = DYNAMIC_DOWNCAST (CBCGPRibbonSeparator, pElement); if (pSeparator) { panel.AddSeparator (); delete pSeparator; } else { panel.Add (pElement); } } } }
//************************************************************************** void CBCGPRibbonBackstageViewItemForm::OnAfterChangeRect (CDC* pDC) { SetLayoutReady(FALSE); CBCGPBaseRibbonElement::OnAfterChangeRect(pDC); if (m_rect.IsRectEmpty ()) { if (m_pWndForm->GetSafeHwnd () != NULL) { m_pWndForm->ShowWindow (SW_HIDE); } return; } BOOL bForceAdjustLocations = FALSE; if (m_pWndForm == NULL) { if ((m_pWndForm = OnCreateFormWnd()) == NULL) { return; } SetLayoutReady(FALSE); bForceAdjustLocations = TRUE; if (m_Watermark.GetImageWell() != NULL) { BOOL bMirror = FALSE; if (GetParentWnd()->GetExStyle () & WS_EX_LAYOUTRTL) { if (!m_bImageMirror) { m_bImageMirror = TRUE; bMirror = TRUE; } } else if (m_bImageMirror) { m_bImageMirror = FALSE; bMirror = TRUE; } if (bMirror) { m_Watermark.Mirror(); OnChangeVisualManager(); } } } CRect rectWindow = m_rect; CRect rectWatermark(0, 0, 0, 0); if (m_sizeWaterMark != CSize(0, 0)) { int xWatermark = max(rectWindow.Width(), m_sizeDlg.cx) - m_sizeWaterMark.cx; int yWatermark = max(rectWindow.Height(), m_sizeDlg.cy) - m_sizeWaterMark.cy; rectWatermark = CRect(CPoint(xWatermark, yWatermark), m_sizeWaterMark); } OnSetBackstageWatermarkRect(rectWatermark); m_pWndForm->SetWindowPos (NULL, rectWindow.left, rectWindow.top, rectWindow.Width (), rectWindow.Height () + 1, SWP_NOZORDER | SWP_NOACTIVATE); if (!m_pWndForm->IsWindowVisible()) { m_pWndForm->ShowWindow (SW_SHOWNOACTIVATE); } SetLayoutReady(); if (bForceAdjustLocations) { CBCGPRibbonPanel* pParentPanel = GetParentPanel(); if (pParentPanel != NULL && pParentPanel->GetParentMenuBar()->GetSafeHwnd() != NULL) { CRect rectPanel; pParentPanel->GetParentMenuBar()->GetClientRect(rectPanel); pParentPanel->GetParentMenuBar()->PostMessage(WM_SIZE, MAKEWPARAM(rectPanel.Width(), rectPanel.Height())); } } m_pWndForm->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN); }
//********************************************************************** LRESULT CBCGPRibbonCustomizeRibbonPage::OnSelChangeRibbonTree(WPARAM, LPARAM lp) { #ifndef BCGP_EXCLUDE_GRID_CTRL if (m_bDontProcessSelChanged) { return 0; } m_wndAdd.EnableWindow(FALSE); CBCGPGridCtrl* pGrid = (CBCGPGridCtrl*)lp; if (pGrid->GetSafeHwnd() == m_wndRibbonTreeDest.GetSafeHwnd()) { m_wndRename.EnableWindow(FALSE); m_wndNewTab.EnableWindow(FALSE); m_wndNewGroup.EnableWindow(FALSE); m_wndRemove.EnableWindow(FALSE); m_wndUp.EnableWindow(FALSE); m_wndDown.EnableWindow(FALSE); m_pSelCategoryDest = NULL; m_pSelPanelDest = NULL; m_pSelElemDest = NULL; CBCGPGridRow* pRow = m_wndRibbonTreeDest.GetCurSel(); if (pRow == NULL) { return 0; } ASSERT_VALID(pRow); CObject* lpData = (CObject*)pRow->GetData(); if (lpData != NULL) { m_wndNewTab.EnableWindow(); m_pSelCategoryDest = DYNAMIC_DOWNCAST(CBCGPRibbonCategory, lpData); if (m_pSelCategoryDest != NULL) { m_wndRename.EnableWindow(); m_wndNewGroup.EnableWindow(); if (m_pSelCategoryDest->IsCustom()) { m_wndRemove.EnableWindow(); } m_wndUp.EnableWindow(!m_wndRibbonTreeDest.IsSelFirstInGroup()); m_wndDown.EnableWindow(!m_wndRibbonTreeDest.IsSelLastInGroup()); } else { m_pSelPanelDest = DYNAMIC_DOWNCAST(CBCGPRibbonPanel, lpData); if (m_pSelPanelDest != NULL) { m_wndRename.EnableWindow(); m_wndNewGroup.EnableWindow(); m_wndRemove.EnableWindow(); m_wndUp.EnableWindow(!m_wndRibbonTreeDest.IsSelFirstInGroup()); m_wndDown.EnableWindow(!m_wndRibbonTreeDest.IsSelLastInGroup()); } else { m_pSelElemDest = DYNAMIC_DOWNCAST(CBCGPBaseRibbonElement, lpData); if (m_pSelElemDest != NULL) { m_wndNewGroup.EnableWindow(); if (m_pSelElemDest->IsCustom() && m_pSelElemDest->GetParentPanel() != NULL) { m_wndRename.EnableWindow(); m_wndRemove.EnableWindow(); m_wndUp.EnableWindow(!m_wndRibbonTreeDest.IsSelFirstInGroup()); m_wndDown.EnableWindow(!m_wndRibbonTreeDest.IsSelLastInGroup()); } } } } } } else if (pGrid->GetSafeHwnd() == m_wndRibbonTreeSrc.GetSafeHwnd()) { m_pSelCategorySrc = NULL; m_pSelPanelSrc = NULL; m_pSelElemSrc = NULL; CBCGPGridRow* pRow = m_wndRibbonTreeSrc.GetCurSel(); if (pRow == NULL) { return 0; } ASSERT_VALID(pRow); CObject* lpData = (CObject*)pRow->GetData(); if (lpData != NULL) { m_pSelCategorySrc = DYNAMIC_DOWNCAST(CBCGPRibbonCategory, lpData); m_pSelPanelSrc = DYNAMIC_DOWNCAST(CBCGPRibbonPanel, lpData); m_pSelElemSrc = DYNAMIC_DOWNCAST(CBCGPBaseRibbonElement, lpData); } } if (m_pSelCategorySrc != NULL) { m_wndAdd.EnableWindow(); } else if (m_pSelPanelSrc != NULL) { ASSERT_VALID(m_pSelPanelSrc); CBCGPRibbonCategory* pCategory = m_pSelCategoryDest; if (pCategory == NULL) { if (m_pSelPanelDest != NULL) { pCategory = m_pSelPanelDest->GetParentCategory(); } else if (m_pSelElemDest != NULL) { pCategory = m_pSelElemDest->GetParentCategory(); } } if (pCategory != NULL) { m_wndAdd.EnableWindow(pCategory != NULL && pCategory->FindPanelByOriginal(m_pSelPanelSrc) == NULL); } } else if (m_pSelElemSrc != NULL) { ASSERT_VALID(m_pSelElemSrc); CBCGPRibbonPanel* pPanel = m_pSelPanelDest; if (pPanel == NULL && m_pSelElemDest != NULL) { pPanel = m_pSelElemDest->GetParentPanel(); } BOOL bCanAdd = FALSE; if (pPanel != NULL && pPanel->IsCustom() && pPanel->m_pOriginal == NULL) { CBCGPRibbonCustomPanel* pCustomPanel = m_CustomizationData.FindCustomPanel(pPanel); if (pCustomPanel != NULL) { ASSERT_VALID(pCustomPanel); if (pCustomPanel->FindByID(m_pSelElemSrc->GetID()) == NULL && m_wndRibbonTreeDest.FindElementInPanel(pPanel, m_pSelElemSrc->GetID()) == NULL) { bCanAdd = TRUE; } } } m_wndAdd.EnableWindow(bCanAdd); } #endif return 0; }
//********************************************************************** void CBCGPRibbonCustomizeRibbonPage::OnRemove() { #ifndef BCGP_EXCLUDE_GRID_CTRL CBCGPGridRow* pRow = m_wndRibbonTreeDest.GetCurSel(); if (pRow == NULL) { ASSERT(FALSE); return; } m_bDontProcessSelChanged = TRUE; ASSERT_VALID(pRow); CBCGPGridRow* pParentRow = pRow->GetParent(); if (m_pSelCategoryDest != NULL) { ASSERT_VALID(m_pSelCategoryDest); ASSERT(m_pSelCategoryDest->IsCustom()); m_pSelCategoryDest->m_bToBeDeleted = TRUE; m_CustomizationData.RemoveCustomTab(*m_pSelCategoryDest); } else if (m_pSelPanelDest != NULL) { ASSERT_VALID(m_pSelPanelDest); if (m_pSelPanelDest->IsCustom()) { m_pSelPanelDest->m_bToBeDeleted = TRUE; m_CustomizationData.RemoveCustomPanel(*m_pSelPanelDest); } else { m_CustomizationData.ShowPanel(m_pSelPanelDest, FALSE); } } else if (m_pSelElemDest != NULL) { ASSERT_VALID(m_pSelElemDest); m_CustomizationData.RemoveCustomElement(*m_pSelElemDest); if (m_pSelElemDest->m_bIsNew) { CBCGPRibbonPanel* pPanel = m_pSelElemDest->GetParentPanel(); ASSERT_VALID(pPanel); int nIndex = pPanel->GetIndex(m_pSelElemDest); ASSERT(nIndex >= 0); pPanel->Remove(nIndex); } } else { ASSERT(FALSE); m_bDontProcessSelChanged = FALSE; return; } int id = pRow->GetRowId(); BOOL bDisableDown = FALSE; BOOL bDisableUp = FALSE; m_wndRibbonTreeDest.SetRedraw(FALSE); if (!m_wndRibbonTreeDest.MoveSelection(TRUE)) { bDisableDown = TRUE; bDisableUp = !m_wndRibbonTreeDest.MoveSelection(FALSE); } CBCGPGridRow* pSelRow = m_wndRibbonTreeDest.GetCurSel(); m_wndRibbonTreeDest.SetCurSel(NULL, FALSE); m_wndRibbonTreeDest.RemoveRow(id); m_wndRibbonTreeDest.AdjustLayout (); m_bDontProcessSelChanged = FALSE; if (bDisableDown && bDisableUp) { m_wndRibbonTreeDest.SetCurSel(pParentRow); } else { m_wndRibbonTreeDest.SetCurSel(pSelRow); } m_wndRibbonTreeDest.SetRedraw(); m_wndRibbonTreeDest.RedrawWindow(); #endif }
//********************************************************************** void CBCGPRibbonCustomizeRibbonPage::OnAdd() { ASSERT_VALID (m_pRibbonBar); if (m_pSelCategorySrc != NULL) { ASSERT_VALID(m_pSelCategorySrc); UINT nContextID = GetNewTabContextID(); CBCGPRibbonCategory* pNewTab = m_pSelCategorySrc->CreateCustomCopy(m_pRibbonBar); ASSERT_VALID(pNewTab); pNewTab->m_uiContextID = nContextID; pNewTab->m_bIsVisible = nContextID == 0; if (nContextID != 0) { pNewTab->SetTabColor(m_pRibbonBar->GetContextColor(nContextID)); } m_pRibbonBar->AddCustomCategory(pNewTab, TRUE); m_CustomizationData.AddCustomTab(*pNewTab, GetNewTabIndex(), nContextID); RebuildDestTree((DWORD_PTR)pNewTab, TRUE); m_wndRibbonTreeSrc.MoveSelection(TRUE); return; } if (m_pSelPanelSrc != NULL) { ASSERT_VALID(m_pSelPanelSrc); CBCGPRibbonCategory* pParentCategory = m_pSelCategoryDest; if (pParentCategory == NULL) { if (m_pSelPanelDest != NULL) { ASSERT_VALID(m_pSelPanelDest); pParentCategory = m_pSelPanelDest->GetParentCategory(); } else if (m_pSelElemDest != NULL) { ASSERT_VALID(m_pSelElemDest); pParentCategory = m_pSelElemDest->GetParentCategory(); } } if (pParentCategory == NULL) { ASSERT(FALSE); return; } ASSERT_VALID(pParentCategory); if (pParentCategory->HasPanel(m_pSelPanelSrc)) { if (m_CustomizationData.IsPanelHidden(m_pSelPanelSrc)) { m_CustomizationData.ShowPanel(m_pSelPanelSrc, TRUE); RebuildDestTree((DWORD_PTR)m_pSelPanelSrc, TRUE); } } else { CBCGPRibbonPanel* pNewPanel = m_pSelPanelSrc->CreateCustomCopy(pParentCategory); ASSERT_VALID(pNewPanel); pNewPanel->m_bIsNew = TRUE; int nIndex = GetNewPanelIndex(); pParentCategory->AddCustomPanel(pNewPanel, nIndex); m_CustomizationData.AddCustomPanel(*pNewPanel, nIndex); RebuildDestTree((DWORD_PTR)pNewPanel, TRUE); m_wndRibbonTreeSrc.MoveSelection(TRUE); } return; } if (m_pSelElemSrc != NULL) { ASSERT_VALID(m_pSelElemSrc); CBCGPRibbonPanel* pPanel = m_pSelPanelDest; if (pPanel == NULL) { if (m_pSelElemDest != NULL) { pPanel = m_pSelElemDest->GetParentPanel(); } } if (pPanel == NULL) { ASSERT(FALSE); return; } ASSERT_VALID(pPanel); CBCGPBaseRibbonElement* pElem = m_pSelElemSrc->CreateCustomCopy(); ASSERT_VALID (pElem); pElem->SetParentCategory(pPanel->GetParentCategory()); pElem->m_bIsNew = TRUE; pPanel->Add(pElem); m_CustomizationData.AddCustomElement(*pPanel, *pElem); m_wndRibbonTreeSrc.MoveSelection(TRUE); RebuildDestTree((DWORD_PTR)pElem); return; } }
void CEditFrameDialog::AddTab_Format () { CBCGPRibbonCategory* pCategory = m_wndRibbonBar.AddCategory ( _T("Format Text\no"), IDB_EDITCTRL_SMALL, IDB_EDITCTRL_LARGE); CBCGPRibbonPanel* pPanelClipboard = pCategory->AddPanel (_T("Clipboard"), m_PanelImages.ExtractIcon (0)); pPanelClipboard->Add (new CBCGPRibbonButton (ID_EDIT_PASTE, _T("Paste"), 0, 0)); pPanelClipboard->Add (new CBCGPRibbonButton (ID_EDIT_CUT, _T("Cut"), 1, -1)); pPanelClipboard->Add (new CBCGPRibbonButton (ID_EDIT_COPY, _T("Copy"), 2, -1)); CBCGPRibbonFontComboBox::m_bDrawUsingFont = TRUE; CBCGPRibbonPanel* pPanelFont = pCategory->AddPanel (_T("Font"), m_PanelImages.ExtractIcon (1)); CBCGPRibbonButtonsGroup* pFontGroup = new CBCGPRibbonButtonsGroup; CBCGPRibbonFontComboBox* pFontCombo = new CBCGPRibbonFontComboBox (ID_FONT_FONT); pFontCombo->SelectItem (_T("Arial")); pFontGroup->AddButton (pFontCombo); CBCGPRibbonComboBox* pFontSizeCombo = new CBCGPRibbonComboBox (ID_FONT_SIZE, TRUE, 20); pFontSizeCombo->AddItem (_T("8")); pFontSizeCombo->AddItem (_T("9")); pFontSizeCombo->AddItem (_T("10")); pFontSizeCombo->AddItem (_T("11")); pFontSizeCombo->AddItem (_T("12")); pFontSizeCombo->AddItem (_T("14")); pFontSizeCombo->AddItem (_T("16")); pFontSizeCombo->AddItem (_T("18")); pFontSizeCombo->AddItem (_T("20")); pFontSizeCombo->AddItem (_T("22")); pFontSizeCombo->AddItem (_T("24")); pFontSizeCombo->AddItem (_T("26")); pFontSizeCombo->AddItem (_T("28")); pFontSizeCombo->AddItem (_T("36")); pFontSizeCombo->AddItem (_T("48")); pFontSizeCombo->AddItem (_T("72")); pFontSizeCombo->SelectItem (4); pFontGroup->AddButton (pFontSizeCombo); pPanelFont->Add (pFontGroup); pPanelFont->AddToolBar (IDR_EDITCTRL_FONT); CBCGPRibbonColorButton* pFontColorHighlightBtn = new CBCGPRibbonColorButton (); pFontColorHighlightBtn->EnableOtherButton (_T("Other...")); pFontColorHighlightBtn->SetColor (RGB (255, 255, 255)); pPanelFont->ReplaceByID (ID_FONT_TEXTHIGHLIGHT, pFontColorHighlightBtn); CBCGPRibbonColorButton* pFontColorBtn = new CBCGPRibbonColorButton (); pFontColorBtn->SetDefaultCommand (FALSE); pFontColorBtn->EnableAutomaticButton (_T("&Automatic"), RGB (0, 0, 0)); pFontColorBtn->EnableOtherButton (_T("&More Colors..."), _T("More Colors")); pFontColorBtn->SetColumns (10); pFontColorBtn->SetColorBoxSize (CSize (17, 17)); pFontColorBtn->AddColorsGroup (_T("Theme Colors"), m_lstMainColors); pFontColorBtn->AddColorsGroup (_T(""), m_lstAdditionalColors, TRUE); pFontColorBtn->AddColorsGroup (_T("Standard Colors"), m_lstStandardColors); pPanelFont->ReplaceByID (ID_FONT_COLOR, pFontColorBtn); //pPanelFont->EnableLaunchButton (ID_FONT_BOX); CBCGPRibbonPanel* pPanelEditing = pCategory->AddPanel (_T("Editing"), m_PanelImages.ExtractIcon (2)); pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_UNDO, _T("Undo"), 3, -1)); pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_REDO, _T("Redo"), 5, -1)); pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_REPEAT, _T("Repeat"), 4, -1)); pPanelEditing->Add (new CBCGPRibbonSeparator ()); pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_FIND, _T("Find"), 6, -1)); pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_REPLACE, _T("Replace"), 7, -1)); pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_SELECT_ALL, _T("Select All"), 8, -1)); }