//******************************************************************************
void CBCGPRibbonSlider::NotifyCommand ()
{
	ASSERT_VALID (this);

	if (m_nID == 0 || m_nID == (UINT)-1)
	{
		return;
	}

	CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
	if (pRibbonBar == NULL)
	{
		return;
	}

	ASSERT_VALID (pRibbonBar);

	CWnd* pWndParent = pRibbonBar->GetParent ();
	if (pWndParent == NULL)
	{
		return;
	}

	pWndParent->SendMessage (WM_COMMAND, m_nID);
}
//*****************************************************************************
BOOL CBCGPFrameWnd::AddControlBar (CBCGPBaseControlBar* pControlBar, BOOL bTail)
{
    ASSERT_VALID (this);

#ifndef BCGP_EXCLUDE_RIBBON
    CBCGPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST (CBCGPRibbonBar, pControlBar);
    if (pRibbonBar != NULL)
    {
        ASSERT_VALID (pRibbonBar);

        if (pRibbonBar->IsMainRibbonBar ())
        {
            m_Impl.m_pRibbonBar = pRibbonBar;
        }
    }

    CBCGPRibbonStatusBar* pRibbonStatusBar = DYNAMIC_DOWNCAST (CBCGPRibbonStatusBar, pControlBar);
    if (pRibbonStatusBar != NULL)
    {
        ASSERT_VALID (pRibbonStatusBar);
        m_Impl.m_pRibbonStatusBar = pRibbonStatusBar;
    }
#endif

    return m_dockManager.AddControlBar (pControlBar, bTail);
}
void CBCGPMSOffice2007DemoView::OnFontname() 
{
	USES_CONVERSION;

	CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	CBCGPRibbonFontComboBox* pFontCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonFontComboBox, pRibbon->FindByID (ID_FONT_FONT));
	if (pFontCombo == NULL)
	{
		return;
	}

	CCharFormat cf;
	cf.szFaceName[0] = NULL;
	cf.dwMask = CFM_FACE | CFM_CHARSET;

	const CBCGPFontDesc* pDesc = pFontCombo->GetFontDesc ();
	ASSERT_VALID (pDesc);
	ASSERT(pDesc->m_strName.GetLength() < LF_FACESIZE);

#if _MSC_VER >= 1300
	lstrcpyn(cf.szFaceName, pDesc->m_strName, LF_FACESIZE);
#else
	lstrcpynA(cf.szFaceName,
		T2A((LPTSTR) (LPCTSTR) pDesc->m_strName), LF_FACESIZE);
#endif

	cf.bCharSet = pDesc->m_nCharSet;
	cf.bPitchAndFamily = pDesc->m_nPitchAndFamily;

	SetCharFormat (cf);
}
Beispiel #4
0
void CEditFrameView::OnFontSize ()
{
	CBCGPRibbonBar* pRibbon = ((CEditFrameDialog*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	CBCGPRibbonComboBox* pSizeCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonComboBox, pRibbon->FindByID (ID_FONT_SIZE));
	if (pSizeCombo == NULL)
	{
		return;
	}

	int nSize = GetTwipSize (pSizeCombo->GetItem (-1));

	if (nSize == -2)
	{
		return;
	}

	if ((nSize >= 0 && nSize < 20) || nSize > 32760)
	{
		return;
	}

	if (nSize > 0)
	{
		CCharFormat cf;
		cf.dwMask = CFM_SIZE;
		cf.yHeight = nSize;

		SetCharFormat (cf);
	}
}
//**************************************************************************
BOOL CBCGPRibbonComboBox::SelectItem (int iIndex)
{
	ASSERT_VALID (this);

	if (iIndex >= m_lstItems.GetCount ())
	{
		return FALSE;
	}

	m_iSelIndex = max (-1, iIndex);
	
	LPCTSTR lpszText = GetItem (m_iSelIndex);

	m_strEdit = lpszText == NULL ? _T("") : lpszText;

	if (m_pWndEdit->GetSafeHwnd () != NULL)
	{
		m_pWndEdit->SetWindowText (m_strEdit);
	}

	if (!m_bDontNotify)
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		if (pRibbonBar != NULL)
		{
			ASSERT_VALID (pRibbonBar);

			CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*> arButtons;
			pRibbonBar->GetElementsByID (m_nID, arButtons, TRUE);

			for (int i = 0; i < arButtons.GetSize (); i++)
			{
				CBCGPRibbonComboBox* pOther =
					DYNAMIC_DOWNCAST (CBCGPRibbonComboBox, arButtons [i]);

				if (pOther != NULL && pOther != this)
				{
					ASSERT_VALID (pOther);

					pOther->m_bDontNotify = TRUE;
					pOther->SelectItem (iIndex);
					pOther->m_bDontNotify = FALSE;
					pOther->m_RecentChangeEvt = m_RecentChangeEvt;
				}
			}
		}
	}

	Redraw ();
	return TRUE;
}
void CBCGPMSOffice2007DemoView::OnFontColor() 
{
	CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	CBCGPRibbonColorButton* pFontColorBtn = DYNAMIC_DOWNCAST (
		CBCGPRibbonColorButton, pRibbon->FindByID (ID_FONT_COLOR));

	if (pFontColorBtn != NULL)
	{
		COLORREF color = pFontColorBtn->GetColor ();
		CRichEditView::OnColorPick (color == -1 ? ::GetSysColor (COLOR_WINDOWTEXT) : color);
	}
}
void CSynBCGPEditView::ReSetLangLabel()
{
	CBCGPRibbonBar *pRibbonBar = ((CMainFrame*)GetTopLevelFrame())->GetRibbonBar();
	ASSERT_VALID(pRibbonBar);

	CMyBCGPRibbonLabel *pRibbonLabel = DYNAMIC_DOWNCAST(CMyBCGPRibbonLabel, pRibbonBar->FindByID(ID_NOW_LANG));
	if (pRibbonLabel)
	{
		CString strLabelText;
		strLabelText.Format(_T("%16s"), m_pEdit->GetSelectLangString());
		pRibbonLabel->SetTextEx(strLabelText);
		pRibbonLabel->Redraw();
	}
}
void CBCGPMSOffice2007DemoView::OnPagelayoutIndentRight() 
{
	CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	CBCGPRibbonEdit* pEdit = DYNAMIC_DOWNCAST (
		CBCGPRibbonEdit, pRibbon->FindByID (ID_PAGELAYOUT_INDENT_RIGHT));

	WPD_PARAFORMAT pf;
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_RIGHTINDENT;
	pf.dxRightIndent = _ttol (pEdit->GetEditText ()) * 10;

	SetParaFormat (pf);
}
void CBCGPRibbonConstructor::ConstructCategoryBackstage (CBCGPRibbonBar& bar, const CBCGPRibbonInfo::XCategoryBackstage& info) const
{
	CBCGPRibbonBackstageViewPanel* pPanel = CreateCategoryBackstage (bar, info);
	ASSERT_VALID (pPanel);

	CBCGPRibbonCategory* pCategory = bar.GetBackstageCategory ();
	ASSERT_VALID (pCategory);

	const_cast<CBCGPToolBarImages&>(info.m_SmallImages.m_Image).CopyTo (pCategory->GetSmallImages ());

	int i = 0;
	for (i = 0; i < info.m_arElements.GetSize (); i++)
	{
		if (info.m_arElements[i]->GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Command) == 0)
		{
			CBCGPBaseRibbonElement* pElement = 
				CreateElement (*(const CBCGPRibbonInfo::XElement*)info.m_arElements[i]);

			if (pElement != NULL)
			{
				ASSERT_VALID (pElement);

				pElement->SetBackstageViewMode ();
				pPanel->CBCGPRibbonMainPanel::Add (pElement);
			}
		}
	}
}
//*********************************************************************************
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 CBCGPMSOffice2007DemoView::SyncFont ()
{
	USES_CONVERSION;

	CString strFontName;

	// get the current font from the view and update
	WPD_CHARFORMAT cf = GetCharFormatSelection ();

	CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	// sync font name:
	CBCGPRibbonFontComboBox* pFontCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonFontComboBox, pRibbon->FindByID (ID_FONT_FONT));

	if (pFontCombo != NULL && !pFontCombo->HasFocus ())
	{
		if ((cf.dwMask & (CFM_FACE|CFM_CHARSET)) == (CFM_FACE|CFM_CHARSET))
		{
#if _MSC_VER >= 1300
			strFontName = cf.szFaceName;
#else
			strFontName = A2T(cf.szFaceName);
#endif
			pFontCombo->SetFont (strFontName, DEFAULT_CHARSET, TRUE);
		}
		else
		{
			pFontCombo->SetText(_T(""));
		}
	}

	// sync font size:
	CBCGPRibbonComboBox* pFontSizeCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonComboBox, pRibbon->FindByID (ID_FONT_FONTSIZE));

	if (pFontSizeCombo != NULL && !pFontSizeCombo->HasFocus ())
	{
		pFontSizeCombo->SetEditText (TwipsToPointString (cf.yHeight));
	}

	SetFocus ();
}
Beispiel #12
0
void CRibbonListButton::OnShowPopupMenu ()
{
	ASSERT_VALID (this);

	CBCGPBaseRibbonElement::OnShowPopupMenu ();

	if (m_sizeMaxText == CSize (0, 0))
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		ASSERT_VALID (pRibbonBar);

		CClientDC dc (pRibbonBar);

		CFont* pOldFont = dc.SelectObject (pRibbonBar->GetFont ());
		ASSERT (pOldFont != NULL);

		int i = 0;

		for (i = 0; i < m_arLabels.GetSize (); i++)
		{
			CSize szText = dc.GetTextExtent (m_arLabels [i]);

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx);
			m_sizeMaxText.cy = max (m_sizeMaxText.cy, szText.cy);
		}

		const int cxImage = m_listImages.GetImageSize ().cx;

		for (i = 0; i < m_arSubItems.GetSize (); i++)
		{
			CBCGPBaseRibbonElement* pButton = m_arSubItems [i];
			ASSERT_VALID (pButton);

			CString strText = pButton->GetText ();
			CSize szText = dc.GetTextExtent (strText);

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx - cxImage);
		}

		dc.SelectObject (pOldFont);
	}

	CBCGPRibbonPaletteButton::OnShowPopupMenu ();
}
void CBCGPMSOffice2007DemoView::OnEditUndo() 
{
	CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	CBCGPRibbonUndoButton* pUndoBtn = DYNAMIC_DOWNCAST (
		CBCGPRibbonUndoButton, pRibbon->FindByID (ID_EDIT_UNDO));

	if (pUndoBtn != NULL && pUndoBtn->GetActionNumber () > 0)
	{
		CString str;
		str.Format (_T("Demo: undo %d action(s)"), pUndoBtn->GetActionNumber ());

		MessageBox (str);
		return;
	}

	CRichEditView::OnEditUndo ();
}
Beispiel #14
0
void CEditFrameView::OnFontSizeDecrease()
{
	CBCGPRibbonBar* pRibbon = ((CEditFrameDialog*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	CBCGPRibbonComboBox* pSizeCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonComboBox, pRibbon->FindByID (ID_FONT_SIZE));
	if (pSizeCombo == NULL)
	{
		return;
	}

	int nItem = pSizeCombo->GetCurSel ();
	if (nItem > 0)
	{
		pSizeCombo->SelectItem (nItem - 1);

		OnFontSize ();
	}
}
void CBCGPRibbonConstructor::ConstructQATElements (CBCGPRibbonBar& bar, const CBCGPRibbonInfo::XRibbonBar& info) const
{
	const CBCGPRibbonInfo::XQAT::XArrayQATItem& items = info.m_QAT.m_arItems;

	int count = (int)items.GetSize ();
	if (count == 0)
	{
		return;
	}

	CBCGPRibbonQATDefaultState qatState;

	for (int i = 0; i < count; i++)
	{
		qatState.AddCommand (items[i].m_ID.m_Value, items[i].m_bVisible);
	}

	bar.SetQuickAccessDefaultState (qatState);
	bar.SetQuickAccessToolbarOnTop (info.m_QAT.m_bOnTop);
}
//*****************************************************************************
void CBCGPRibbonSlider::SetPos (int nPos, BOOL bRedraw)
{
	ASSERT_VALID (this);

	m_nPos = min (max (m_nMin, nPos), m_nMax);
	SetThumbRect ();

	if (!m_bDontNotify)
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		if (pRibbonBar != NULL)
		{
			ASSERT_VALID (pRibbonBar);

			CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*> arButtons;
			pRibbonBar->GetElementsByID (m_nID, arButtons);

			for (int i = 0; i < arButtons.GetSize (); i++)
			{
				CBCGPRibbonSlider* pOther =
					DYNAMIC_DOWNCAST (CBCGPRibbonSlider, arButtons [i]);

				if (pOther != NULL && pOther != this)
				{
					ASSERT_VALID (pOther);

					pOther->m_bDontNotify = TRUE;
					pOther->SetPos (nPos);
					pOther->m_bDontNotify = FALSE;
				}
			}
		}
	}

	if (bRedraw)
	{
		Redraw ();
	}
}
Beispiel #17
0
void CEditFrameView::OnFontColor() 
{
	CBCGPRibbonBar* pRibbon = ((CEditFrameDialog*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	CBCGPRibbonColorButton* pColorBtn = DYNAMIC_DOWNCAST (
		CBCGPRibbonColorButton, pRibbon->FindByID (ID_FONT_COLOR));

	if (pColorBtn != NULL)
	{
		COLORREF color = pColorBtn->GetColor ();

		if (color == -1)
		{
			CRichEditView::OnColorDefault ();
		}
		else
		{
			CRichEditView::OnColorPick (color);
		}	
	}
}
void CBCGPMSOffice2007DemoView::OnFontsize ()
{
	CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	CBCGPRibbonComboBox* pSizeCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonComboBox, pRibbon->FindByID (ID_FONT_FONTSIZE));
	if (pSizeCombo == NULL)
	{
		return;
	}

	int nSize = GetTwipSize (pSizeCombo->GetEditText ());

	if (nSize == -2)
	{
		// Restore current size:
		pSizeCombo->SetEditText (TwipsToPointString (GetCharFormatSelection ().yHeight));

		MessageBox (_T("This is not a valid number"));
		return;
	}

	if ((nSize >= 0 && nSize < 20) || nSize > 32760)
	{
		return;
	}

	if (nSize > 0)
	{
		CCharFormat cf;
		cf.dwMask = CFM_SIZE;
		cf.yHeight = nSize;

		SetCharFormat (cf);
	}
}
Beispiel #19
0
void CSynBCGPEditView::OnEditUndo()
{
	 CBCGPRibbonBar *pRibbon = ((CMainFrame*) GetTopLevelFrame())->GetRibbonBar();
	 ASSERT_VALID(pRibbon);

	 CBCGPRibbonUndoButton *pEditUndo = DYNAMIC_DOWNCAST(CBCGPRibbonUndoButton, pRibbon->FindByID(ID_EDIT_UNDO));
	 ASSERT_VALID(pEditUndo);

	 int nActionNumber = pEditUndo->GetActionNumber();

	 if (-1 == nActionNumber)
	 {
		 m_pEdit->OnUndo();
		 return;
	 }

	 for (int i = 0; i < nActionNumber; i++)
	 {
		 if (!m_pEdit->OnUndo())
		 {
			 break;
		 }
	 }
}
	virtual void OnClick (CPoint /*point*/)
	{
		CBCGPBaseRibbonElement* pElement = (CBCGPBaseRibbonElement*) m_dwData;
		ASSERT_VALID (pElement);

		pElement->SetVisible (!pElement->IsVisible ());
		Redraw ();

		CBCGPRibbonBar* pRibbonStatusBar = pElement->GetParentRibbonBar ();
		ASSERT_VALID (pRibbonStatusBar);

		pRibbonStatusBar->RecalcLayout ();
		pRibbonStatusBar->RedrawWindow ();

		CFrameWnd* pParentFrame = pRibbonStatusBar->GetParentFrame ();
		ASSERT_VALID (pParentFrame);

		pParentFrame->RedrawWindow (NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);

		CRect rectScreen;
		pRibbonStatusBar->GetWindowRect (&rectScreen);

		CBCGPPopupMenu::UpdateAllShadows (rectScreen);
	}
void CBCGPRibbonConstructor::ConstructCategoryMain (CBCGPRibbonBar& bar, const CBCGPRibbonInfo::XCategoryMain& info) const
{
	CBCGPRibbonMainPanel* pPanel = CreateCategoryMain (bar, info);
	ASSERT_VALID (pPanel);

	CBCGPRibbonCategory* pCategory = bar.GetMainCategory ();
	ASSERT_VALID (pCategory);

	const_cast<CBCGPToolBarImages&>(info.m_SmallImages.m_Image).CopyTo (pCategory->GetSmallImages ());
	const_cast<CBCGPToolBarImages&>(info.m_LargeImages.m_Image).CopyTo (pCategory->GetLargeImages ());

	if (info.m_bSearchEnable)
	{
		pPanel->EnableCommandSearch (info.m_bSearchEnable, info.m_strSearchLabel, info.m_strSearchKeys, info.m_nSearchWidth);
	}

	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);

			if (info.m_arElements[i]->GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_MainPanel) == 0)
			{
				pPanel->AddToBottom ((CBCGPRibbonMainPanelButton*)pElement);
			}
			else
			{
				pPanel->Add (pElement);
			}
		}
	}

	if (info.m_bRecentListEnable)
	{
		pPanel->AddRecentFilesList (info.m_strRecentListLabel, info.m_nRecentListWidth, info.m_bRecentListShowPins);
	}
}
void CBCGPRibbonConstructor::ConstructTabElements (CBCGPRibbonBar& bar, const CBCGPRibbonInfo::XRibbonBar& info) const
{
	int i = 0;
	for (i = 0; i < info.m_TabElements.m_arButtons.GetSize (); i++)
	{
		CBCGPBaseRibbonElement* pElement = 
			CreateElement (*(const CBCGPRibbonInfo::XElement*)info.m_TabElements.m_arButtons[i]);
		if (pElement != NULL)
		{
			CBCGPRibbonButton* pButton = DYNAMIC_DOWNCAST (CBCGPRibbonButton, pElement);
			if (pButton != NULL && pButton->GetImageIndex (FALSE) != -1)
			{
				SetIcon (*pButton, CBCGPBaseRibbonElement::RibbonImageLarge, 
					GetInfo().GetRibbonBar ().m_Images.m_Image, FALSE);
			}

			ASSERT_VALID (pElement);
			bar.AddToTabs (pElement);
		}
	}
}
//******************************************************************************
void CBCGPRadialMenuItem::OnDrawIcon(CBCGPGraphicsManager* pGM, BOOL bIsCtrlDisabled, CBCGPImage& icons, CBCGPSize sizeIcon)
{
	ASSERT_VALID(pGM);

	if (m_ptCenter == CBCGPPoint(-1, -1))
	{
		return;
	}

	BOOL bIsDisabled = bIsCtrlDisabled || m_bIsDisabled;
	HICON hIcon = NULL;

	if (m_hIcon != NULL)
	{
		hIcon = m_hIcon;
	}
	else if (m_nImageIndex >= 0)
	{
		CBCGPPoint ptImage = m_ptCenter;
		ptImage.x -= .5 * sizeIcon.cx;
		ptImage.y -= .5 * sizeIcon.cy;

		pGM->DrawImage(icons, ptImage, sizeIcon, bIsDisabled ? .4 : 1., CBCGPImage::BCGP_IMAGE_INTERPOLATION_MODE_LINEAR,
			CBCGPRect(CBCGPPoint(sizeIcon.cx * m_nImageIndex, 0), sizeIcon));
	}
	else
	{
		// Try to obtain icon from ribbon/toolbars:
#ifndef _BCGSUITE_
#ifndef BCGP_EXCLUDE_RIBBON
		CFrameWnd* pParentFrame = DYNAMIC_DOWNCAST (CFrameWnd, AfxGetMainWnd());
		CBCGPRibbonBar* pRibbonBar = NULL;

		CBCGPMDIFrameWnd* pMainFrame = DYNAMIC_DOWNCAST (CBCGPMDIFrameWnd, pParentFrame);
		if (pMainFrame != NULL)
		{
			pRibbonBar = pMainFrame->GetRibbonBar();
		}
		else	// Maybe, SDI frame...
		{
			CBCGPFrameWnd* pFrame = DYNAMIC_DOWNCAST (CBCGPFrameWnd, pParentFrame);
			if (pFrame != NULL)
			{
				pRibbonBar = pFrame->GetRibbonBar();
			}
		}

		if (pRibbonBar != NULL)
		{
			ASSERT_VALID(pRibbonBar);

			hIcon = pRibbonBar->ExportImageToIcon(m_nID, FALSE);
		}
		else
#endif
#endif
		{
#ifndef _BCGSUITE_
			int nImage = CImageHash::GetImageOfCommand(m_nID, FALSE);
#else
			int nImage = GetCmdMgr ()->GetCmdImage(m_nID, FALSE);
#endif
			CBCGPToolBarImages* pImages = CBCGPToolBar::GetImages();
			if (pImages != NULL && nImage >= 0)
			{
				hIcon = pImages->ExtractIcon(nImage);
			}
		}

		if (hIcon != NULL)
		{
			m_hIcon = hIcon;
			m_bDestroyIcon = TRUE;
		}
	}

	if (hIcon != NULL)
	{
		CBCGPImage image(hIcon);

		sizeIcon = pGM->GetImageSize(image);
		
		CBCGPPoint ptImage = m_ptCenter;
		ptImage.x -= .5 * sizeIcon.cx;
		ptImage.y -= .5 * sizeIcon.cy;

		pGM->DrawImage(image, ptImage, CBCGPSize(), bIsDisabled ? .4 : 1);
	}
}
Beispiel #24
0
//**********************************************************************
void CBCGPToolTipCtrl::OnShow(NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
	*pResult = 0;

	if (m_Params.m_bVislManagerTheme)
	{
		CBCGPVisualManager::GetInstance ()->GetToolTipParams (m_Params);
		m_Params.m_bVislManagerTheme = TRUE;
	}

	if (m_Params.m_bBallonTooltip)
	{
		return;
	}

	CPoint ptCursor;
	::GetCursorPos (&ptCursor);

	GetHotButton ();

	m_sizeImage = m_Params.m_bDrawIcon ? GetIconSize () : CSize (0, 0);
	m_ptMargin = CPoint (6, 4);

	m_ptMargin.x += m_Params.m_nPaddingX;
	m_ptMargin.y += m_Params.m_nPaddingY;

	CRect rectMargin;
	GetMargin (rectMargin);

	CRect rectText;
	GetClientRect (rectText);

	CClientDC dc (this);
	CSize sizeText = OnDrawLabel (&dc, rectText, TRUE);
	
	int cx = sizeText.cx;
	int cy = sizeText.cy;

	CSize sizeDescr (0, 0);
	
	if (!m_Params.m_bDrawDescription || m_strDescription.IsEmpty ())
	{
		cy = max (cy, m_sizeImage.cy);
	}
	else
	{
		sizeDescr = OnDrawDescription (&dc, rectText, TRUE);

		cy += sizeDescr.cy + 2 * m_ptMargin.y;
		cx = max (cx, sizeDescr.cx);

		cy = max (cy, m_sizeImage.cy);
	}

	if (m_sizeImage.cx > 0 && m_Params.m_bDrawIcon)
	{
		cx += m_sizeImage.cx + m_ptMargin.x;
	}

	cx += 2 * m_ptMargin.x;
	cy += 2 * m_ptMargin.y;

	int nFixedWidth = GetFixedWidth ();
	if (nFixedWidth > 0 && sizeDescr != CSize (0, 0))
	{
		cx = max (cx, nFixedWidth);
	}

	CRect rectWindow;
	GetWindowRect (rectWindow);

	int x = rectWindow.left;
	int y = rectWindow.top;

	if (m_ptLocation != CPoint (-1, -1))
	{
		x = m_ptLocation.x;
		y = m_ptLocation.y;

		*pResult = 1;
	}

	CRect rectScreen;

	MONITORINFO mi;
	mi.cbSize = sizeof (MONITORINFO);
	if (GetMonitorInfo (MonitorFromPoint (rectWindow.TopLeft (), MONITOR_DEFAULTTONEAREST),
		&mi))
	{
		rectScreen = mi.rcWork;
	}
	else
	{
		::SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0);
	}

	int nBottom = max (
		ptCursor.y + cy + ::GetSystemMetrics (SM_CYCURSOR),
		y + cy + 2);

	if (nBottom > rectScreen.bottom)
	{
		y = ptCursor.y - cy - 1;

#ifndef BCGP_EXCLUDE_RIBBON
		if (m_pRibbonButton != NULL && m_ptLocation != CPoint (-1, -1))
		{
			ASSERT_VALID (m_pRibbonButton);

			CBCGPRibbonBar* pRibbon = m_pRibbonButton->GetTopLevelRibbonBar ();
			if (pRibbon->GetSafeHwnd () != NULL)
			{
				CRect rectRibbon;
				pRibbon->GetWindowRect (rectRibbon);

				y = rectRibbon.top - cy;
			}
		}
#endif

		*pResult = 1;
	}

	if (x + cx + 2 > rectScreen.right)
	{
		if ((*pResult) == 1)	// Y has been changed
		{
			x = ptCursor.x - cx - 1;
		}
		else
		{
			x = rectScreen.right - cx - 1;
			*pResult = 1;
		}
	}

	if ((*pResult) == 1)
	{
		SetWindowPos (NULL, x, y, cx, cy, SWP_NOZORDER | SWP_NOACTIVATE);
	}
	else
	{
		SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
	}

	m_sizeCornerRadius = CBCGPVisualManager::GetInstance()->GetSystemToolTipCornerRadius(this);
	
	SetWindowPos (&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE | SWP_DRAWFRAME);
}
void CBCGPRibbonConstructor::ConstructRibbonBar (CBCGPRibbonBar& bar) const
{
	const CBCGPRibbonInfo::XRibbonBar& infoBar = GetInfo ().GetRibbonBar ();

	CBCGPRibbonPanel::m_nNextPanelID = (UINT)-10;

	bar.m_VersionStamp = GetInfo ().GetVersionStamp ();
	bar.EnableToolTips     (infoBar.m_bToolTip, infoBar.m_bToolTipDescr);
	bar.EnableKeyTips      (infoBar.m_bKeyTips);
	bar.EnablePrintPreview (infoBar.m_bPrintPreview);
	bar.SetBackstageMode   (infoBar.m_bBackstageMode);

	CBCGPRibbonFontComboBox::m_bDrawUsingFont = infoBar.m_bDrawUsingFont;

	const_cast<CBCGPToolBarImages&>(infoBar.m_Images.m_Image).CopyTo (bar.m_PanelIcons);

	if (infoBar.m_btnMain != NULL)
	{
		CBCGPRibbonMainButton* btnMain = bar.GetMainButton ();
		if (btnMain == NULL)
		{
			btnMain = CreateMainButton (bar);
		}

		if (btnMain != NULL)
		{
			ConstructElement (*btnMain, *infoBar.m_btnMain);
		}
	}

	if (infoBar.m_MainCategory != NULL)
	{
		ConstructCategoryMain (bar, *infoBar.m_MainCategory);
	}

	if (infoBar.m_BackstageCategory != NULL)
	{
		ConstructCategoryBackstage (bar, *infoBar.m_BackstageCategory);
	}

	ConstructTabElements (bar, infoBar);

	int i = 0;
	for (i = 0; i < infoBar.m_arCategories.GetSize (); i++)
	{
		const CBCGPRibbonInfo::XCategory& infoCategory = 
			*(const CBCGPRibbonInfo::XCategory*)infoBar.m_arCategories[i];

		CBCGPRibbonCategory* pCategory = CreateCategory (bar, infoCategory);
		if (pCategory != NULL)
		{
			ASSERT_VALID (pCategory);
			ConstructCategory (*pCategory, infoCategory);
		}
	}

	for (i = 0; i < infoBar.m_arContexts.GetSize (); i++)
	{
		const CBCGPRibbonInfo::XContext* context = infoBar.m_arContexts[i];
		for (int j = 0; j < context->m_arCategories.GetSize (); j++)
		{
			const CBCGPRibbonInfo::XCategory& infoCategory = 
				*(const CBCGPRibbonInfo::XCategory*)context->m_arCategories[j];

			CBCGPRibbonCategory* pCategory = CreateCategoryContext (bar, *context, infoCategory);
			if (pCategory != NULL)
			{
				ASSERT_VALID (pCategory);
				ConstructCategory (*pCategory, infoCategory);
			}
		}
	}

	ConstructQATElements (bar, infoBar);
}