Example #1
0
CBCGPKeyMapDlg::CBCGPKeyMapDlg(CFrameWnd* pWndParentFrame,
							 BOOL bEnablePrint /* = FALSE */,
							 BOOL bShowCommandsWithKeyOnly /* = FALSE */)
	:	CBCGPDialog(CBCGPKeyMapDlg::IDD, pWndParentFrame),
		m_bEnablePrint (bEnablePrint),
		m_bShowCommandsWithKeyOnly(bShowCommandsWithKeyOnly)
{
	m_pWndParentFrame = pWndParentFrame;

	//{{AFX_DATA_INIT(CBCGPKeyMapDlg)
	//}}AFX_DATA_INIT

	m_hAccelTable	= NULL;
	m_lpAccel		= NULL;
	m_nAccelSize	= 0;

	m_pDlgCust		= NULL;

	m_nSortedCol = 0;
	m_bSortAscending = TRUE;
	m_hInstDefault = NULL;

	m_bIsLocal = TRUE;

	m_pWndRibbonBar = NULL;
	m_bItemWasAdded = FALSE;

#ifndef BCGP_EXCLUDE_RIBBON
	CBCGPFrameWnd* pFrameWnd = DYNAMIC_DOWNCAST(CBCGPFrameWnd, m_pWndParentFrame);
	if (pFrameWnd != NULL)
	{
		if (pFrameWnd->GetRibbonBar()->GetSafeHwnd() != NULL && pFrameWnd->GetRibbonBar()->IsWindowVisible())
		{
			m_pWndRibbonBar = pFrameWnd->GetRibbonBar();
		}
	}
	else
	{
		CBCGPMDIFrameWnd* pMDIFrameWnd = DYNAMIC_DOWNCAST(CBCGPMDIFrameWnd, m_pWndParentFrame);
		if (pMDIFrameWnd != NULL)
		{
			if (pMDIFrameWnd->GetRibbonBar()->GetSafeHwnd() != NULL && pMDIFrameWnd->GetRibbonBar()->IsWindowVisible())
			{
				m_pWndRibbonBar = pMDIFrameWnd->GetRibbonBar();
			}
		}
	}
#endif

	EnableVisualManagerStyle (globalData.m_bUseVisualManagerInBuiltInDialogs, TRUE);
}
//******************************************************************************
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);
	}
}