コード例 #1
0
//*******************************************************************************
void CBCGPRibbonStatusBarPane::OnDraw (CDC* pDC)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pDC);

	if (m_AnimImages.GetCount () == 0)
	{
		CBCGPRibbonButton::OnDraw (pDC);
		return;
	}

	if (m_rect.IsRectEmpty ())
	{
		return;
	}

	OnFillBackground (pDC);

	if (m_nAnimationIndex < 0)
	{
		CString strText = m_strText;
		m_strText.Empty ();

		CBCGPRibbonButton::OnDraw (pDC);
		m_strText = strText;
	}
	else
	{
		m_AnimImages.DrawEx (pDC, m_rect, m_nAnimationIndex,
			CBCGPToolBarImages::ImageAlignHorzCenter, CBCGPToolBarImages::ImageAlignVertCenter);
	}

	OnDrawBorder (pDC);
}
コード例 #2
0
//***************************************************************************************
void CBCGPToolBoxButton::OnDraw (CDC* pDC)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pDC);
	ASSERT_VALID (m_pPage);

	if (m_Rect.IsRectEmpty ())
	{
		return;
	}

	OnFillBackground (pDC, m_Rect);
	OnDrawBorder (pDC, m_Rect, 0);

	CRect rectText = m_Rect;

	if (m_pPage->GetMode () != CBCGPToolBoxPage::ToolBoxPageMode_Images)
	{
		rectText.left += rectText.Height();
	}

	if (m_pImages != NULL && m_iImageIndex >= 0)
	{
		ASSERT_VALID (m_pImages);

		CSize sizeImage = m_pImages->GetImageSize ();
		if (globalData.GetRibbonImageScale () != 1.)
		{
			double dblImageScale = globalData.GetRibbonImageScale ();
			sizeImage = CSize ((int)(.5 + sizeImage.cx * dblImageScale), (int)(.5 + sizeImage.cy * dblImageScale));
		}

		CRect rectImage = rectText;

		if (m_pPage->GetMode () != CBCGPToolBoxPage::ToolBoxPageMode_Images)
		{
			rectImage.right = rectImage.left + sizeImage.cx + 4;
		}

		m_pImages->Draw (pDC,
				rectImage.left + (rectImage.Width () - sizeImage.cx) / 2,
				rectImage.top + (rectImage.Height () - sizeImage.cy) / 2,
				m_iImageIndex);

		rectText.left = rectImage.right;
	}

	if (m_pPage->GetMode () == CBCGPToolBoxPage::ToolBoxPageMode_Images)
	{
		return;
	}

	rectText.DeflateRect(6, 0);

	pDC->SetTextColor (CBCGPVisualManager::GetInstance ()->GetToolBoxButtonTextColor (this));
	pDC->DrawText (m_strLabel, rectText, DT_SINGLELINE | DT_VCENTER | DT_LEFT);
}
コード例 #3
0
//**********************************************************************
BOOL CBCGPToolTipCtrl::OnEraseBkgnd(CDC* pDC) 
{
	CRect rect;
	GetClientRect (rect);

	COLORREF clrDummy;

	OnFillBackground (pDC, rect, clrDummy, clrDummy);
	return TRUE;
}
コード例 #4
0
ファイル: ToolBoxCtrl.cpp プロジェクト: DayDayUpCQ/misc
void CToolBoxCtrl::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CWnd::OnPaint()
	CMemDC memDC(dc, this);
	CDC* pDC = &memDC.GetDC();

	CRect rectClient;
	GetClientRect(rectClient);
	OnFillBackground(pDC, rectClient);

	HFONT hfontOld = SetCurrFont(pDC);
	pDC->SetBkMode(TRANSPARENT);
	OnDrawList(pDC);
	::SelectObject(pDC->GetSafeHdc(), hfontOld);
}
コード例 #5
0
void CBCGPToolTipCtrl::OnPaint() 
{
	if (m_Params.m_bBallonTooltip)
	{
		CToolTipCtrl::OnPaint ();
		return;
	}

	CPaintDC dcPaint(this); // device context for painting
	
	CBCGPMemDC memDC (dcPaint, this);
	CDC* pDC = &memDC.GetDC ();

	CRect rect;
	GetClientRect (rect);

	CRect rectMargin;
	GetMargin (rectMargin);

	CRect rectText = rect;

	rectText.DeflateRect (rectMargin);
	rectText.DeflateRect (m_ptMargin.x, m_ptMargin.y);

	COLORREF clrLine = m_Params.m_clrBorder == (COLORREF)-1 ?
		::GetSysColor (COLOR_INFOTEXT) : m_Params.m_clrBorder;

	COLORREF clrText = m_Params.m_clrText == (COLORREF)-1 ?
		::GetSysColor (COLOR_INFOTEXT) : m_Params.m_clrText;

	//-----------------
	// Fill background:
	//-----------------
	OnFillBackground (pDC, rect, clrText, clrLine);

	CPen penLine (PS_SOLID, 1, clrLine);
	CPen* pOldPen = pDC->SelectObject (&penLine);

	//-------------
	// Draw border:
	//-------------
	OnDrawBorder (pDC, rect, clrLine);

	//-----------
	// Draw icon:
	//-----------
	if (m_sizeImage != CSize (0, 0) && m_Params.m_bDrawIcon)
	{
		CRect rectImage = rectText;
		rectImage.right = rectImage.left + m_sizeImage.cx;
		rectImage.bottom = rectImage.top + m_sizeImage.cy;

		OnDrawIcon (pDC, rectImage);

		rectText.left += m_sizeImage.cx + m_ptMargin.x;
	}

	pDC->SetBkMode (TRANSPARENT);
	pDC->SetTextColor (clrText);

	//------------
	// Draw label:
	//------------
	int nTextHeight = OnDrawLabel (pDC, rectText, FALSE).cy;

	//------------------------------
	// Draw separator + description:
	//------------------------------
	if (!m_strDescription.IsEmpty () && m_Params.m_bDrawDescription)
	{
		CRect rectDescr = rectText;
		rectDescr.top += nTextHeight + 3 * m_ptMargin.y / 2;

		if (m_Params.m_bDrawSeparator)
		{
			OnDrawSeparator (pDC, rectDescr.left,
				rectDescr.right, rectDescr.top - m_ptMargin.y / 2);
		}

		OnDrawDescription (pDC, rectDescr, FALSE);
	}

	pDC->SelectObject (pOldPen);
}
コード例 #6
0
	virtual void OnDraw (CDC* pDC)
	{
		ASSERT_VALID (this);
		ASSERT_VALID (pDC);
		ASSERT_VALID (m_pColorButton);

		if (m_rect.IsRectEmpty ())
		{
			return;
		}

		const int cxImageBar = CBCGPToolBar::GetMenuImageSize ().cx + 
			2 * CBCGPVisualManager::GetInstance ()->GetMenuImageMargin () + 2;

		COLORREF clrText = OnFillBackground (pDC);
		COLORREF clrTextOld = (COLORREF)-1;

		if (m_bIsDisabled)
		{
			clrTextOld = pDC->SetTextColor (
				clrText == (COLORREF)-1 ? 
					CBCGPVisualManager::GetInstance ()->GetToolbarDisabledTextColor () : clrText);
		}
		else if (clrText != (COLORREF)-1)
		{
			clrTextOld = pDC->SetTextColor (clrText);
		}

		CRect rectText = m_rect;
		rectText.left += cxImageBar + TEXT_MARGIN;
		rectText.DeflateRect (m_szMargin.cx, m_szMargin.cx);

		pDC->DrawText (m_strText, rectText, DT_SINGLELINE | DT_END_ELLIPSIS | DT_VCENTER);

		if (clrTextOld != (COLORREF)-1)
		{
			pDC->SetTextColor (clrTextOld);
		}

		if (m_nType == nMenuButtonOther)
		{
			CRect rectImage = m_rect;
			rectImage.right = rectImage.left + cxImageBar;

			const int nIconSize = 16;

			if (globalData.m_hiconColors == NULL)
			{
				CBCGPLocalResource locaRes;

				globalData.m_hiconColors = (HICON) ::LoadImage (
					AfxGetResourceHandle (),
					MAKEINTRESOURCE (IDI_BCGRES_COLORS),
					IMAGE_ICON,
					16,
					16,
					LR_SHARED);
			}

			::DrawIconEx (pDC->GetSafeHdc (), 
				rectImage.left + (rectImage.Width () - nIconSize) / 2, 
				rectImage.top + (rectImage.Height () - nIconSize) / 2,
				globalData.m_hiconColors, 
				nIconSize, nIconSize, 0, NULL,
				DI_NORMAL);
		}
		else if (m_nType == nMenuButtonAuto)
		{
			CRect rectColorBox = m_rect;
			rectColorBox.right = rectColorBox.left + cxImageBar;
			rectColorBox.DeflateRect (2, 2);

			int nBoxSize = min (rectColorBox.Width (), rectColorBox.Height ());

			rectColorBox = CRect (CPoint (
				rectColorBox.left + (rectColorBox.Width () - nBoxSize) / 2,
				rectColorBox.top + (rectColorBox.Height () - nBoxSize) / 2),
							CSize (nBoxSize, nBoxSize));

			m_pColorButton->OnDrawPaletteIcon (pDC, rectColorBox, -1, NULL, (COLORREF)-1);
		}
	}
コード例 #7
0
//**********************************************************************************//
void CBCGPAutoHideButton::OnDraw (CDC* pDC)
{
	ASSERT_VALID (this);

	const BOOL bIsOverlapped = 
		(CBCGPVisualManager::GetInstance ()->HasOverlappedAutoHideButtons ()) || m_bOverlappingTabs;
	const int nTextMargin = bIsOverlapped ? (IsHorizontal () ? 5 : 7) : 
							m_nTextMargin;

	CSize size = GetSize ();
	m_rect.SetRect (0, 0, size.cx, size.cy);

	// calculate border size and draw the border
	CRect rectBorderSize (m_nBorderSize, 0, m_nBorderSize, m_nBorderSize);

	switch (m_dwAlignment & CBRS_ALIGN_ANY)
	{
	case CBRS_ALIGN_RIGHT:
		globalUtils.FlipRect (rectBorderSize, 90);
		break;
	case CBRS_ALIGN_BOTTOM:
		globalUtils.FlipRect (rectBorderSize, 180);
		break;
	case CBRS_ALIGN_LEFT:
		globalUtils.FlipRect (rectBorderSize, -90);
		break;
	}

	if (bIsOverlapped && !m_pParentBar->m_bFirstInGroup)
	{
		CRect rectPrev = m_rect;

		switch (m_dwAlignment & CBRS_ALIGN_ANY)
		{
		case CBRS_ALIGN_RIGHT:
		case CBRS_ALIGN_LEFT:
			rectPrev.OffsetRect (0, -m_rect.Height () + size.cx / 2);
			break;

		case CBRS_ALIGN_TOP:
		case CBRS_ALIGN_BOTTOM:
			rectPrev.OffsetRect (-m_rect.Width () + size.cy / 2, 0);
			break;
		}

		OnFillBackground (pDC, rectPrev);
		OnDrawBorder (pDC, rectPrev, rectBorderSize);
	}

	OnFillBackground (pDC, m_rect);
	OnDrawBorder (pDC, m_rect, rectBorderSize);

	if (m_pAutoHideWindow == NULL)
	{
		return;
	}

	ASSERT_VALID (m_pAutoHideWindow);

	CRect rectDraw = m_rect;

	if (!bIsOverlapped)
	{
		rectDraw.DeflateRect (rectBorderSize);
	}

	rectDraw.DeflateRect (m_nMarginSize, m_nMarginSize);

	if (m_pAutoHideWindow != NULL)
	{
		// draw the icon (if any)
		HICON hIcon = m_pAutoHideWindow->GetBarIcon (FALSE);
		if (hIcon != NULL || bIsOverlapped)
		{
			CSize sizeIcon (globalData.m_sizeSmallIcon);

			int dx = IsHorizontal () ? 0 : (rectDraw.Width () - sizeIcon.cx) / 2;
			int dy = IsHorizontal () ? (rectDraw.Height () - sizeIcon.cy) / 2 : 0;

			if (bIsOverlapped && !m_bOverlappingTabs)
			{
				if (IsHorizontal ()	)
				{
					dx += rectDraw.Height () / 2 + 1;
				}
				else
				{
					dy += rectDraw.Width () / 2 + 1;
				}
			}

			if (hIcon != NULL)
			{
				::DrawIconEx (pDC->GetSafeHdc (), 
							rectDraw.left + dx, rectDraw.top + dy, hIcon,
							sizeIcon.cx, sizeIcon.cy, 0, NULL, DI_NORMAL);
			}
			else
			{
				#ifndef BCGP_EXCLUDE_RIBBON
					CBCGPVisualManager::GetInstance ()->
						OnDrawDefaultRibbonImage (pDC, 
							CRect (CPoint (rectDraw.left + dx, rectDraw.top + dy), sizeIcon));
				#endif
			}
			if (IsHorizontal ())
			{
				rectDraw.left += nTextMargin + sizeIcon.cx + dx;
			}
			else
			{
				rectDraw.top += nTextMargin + sizeIcon.cy + dy;
			}
		}
		else
		{
			if (IsHorizontal ())
			{
				rectDraw.left += m_nMarginSize;
			}
			else
			{
				rectDraw.top += m_nMarginSize;
			}
		}

		// Draw text:
		CString strText;
		m_pAutoHideWindow->GetWindowText (strText);

		if (!strText.IsEmpty () && m_pParentBar->m_bActiveInGroup || !m_bOverlappingTabs)
		{
			int nOldMode = pDC->SetBkMode (TRANSPARENT);

			CFont* pFontOld = (CFont*) pDC->SelectObject (IsHorizontal () ? 
										&globalData.fontRegular : &globalData.fontVert);
			ASSERT(pFontOld != NULL);

			pDC->SetTextColor (
				CBCGPVisualManager::GetInstance ()->GetAutoHideButtonTextColor (this));

			if (IsHorizontal ())
			{
				pDC->DrawText (strText, &rectDraw, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			}
			else
			{
				TEXTMETRIC tm;
				pDC->GetTextMetrics (&tm);

				CRect rectText = rectDraw;

				rectText.left = rectText.right - (rectDraw.Width () - tm.tmHeight + 1) / 2;
				rectText.bottom = rectDraw.top + nTextMargin;

				pDC->DrawText (strText, &rectText, DT_SINGLELINE | DT_NOCLIP);
			}

			pDC->SelectObject (pFontOld);
			pDC->SetBkMode (nOldMode);
		}
	}
}
コード例 #8
0
//***************************************************************************************
void CBCGPHeaderCtrl::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    CBCGPMemDC memDC (dc, this);
    CDC* pDC = &memDC.GetDC ();

    CRect rectClip;
    dc.GetClipBox (rectClip);

    CRect rectClient;
    GetClientRect (rectClient);

    OnFillBackground (pDC);

    CFont* pOldFont = SelectFont (pDC);
    ASSERT_VALID (pOldFont);

    pDC->SetTextColor (globalData.clrBtnText);
    pDC->SetBkMode (TRANSPARENT);

    CRect rect;
    GetClientRect(rect);

    CRect rectItem;
    int nCount = GetItemCount ();

    int xMax = 0;

    for (int i = 0; i < nCount; i++)
    {
        //------------------
        // Is item pressed?
        //------------------
        CPoint ptCursor;
        ::GetCursorPos (&ptCursor);
        ScreenToClient (&ptCursor);

        HDHITTESTINFO hdHitTestInfo;
        hdHitTestInfo.pt = ptCursor;

        int iHit = (int) SendMessage (HDM_HITTEST, 0, (LPARAM) &hdHitTestInfo);

        BOOL bIsHighlighted = iHit == i && (hdHitTestInfo.flags & HHT_ONHEADER);
        BOOL bIsPressed = m_bIsMousePressed && bIsHighlighted;

        GetItemRect (i, rectItem);

        CRgn rgnClip;
        rgnClip.CreateRectRgnIndirect (&rectItem);
        pDC->SelectClipRgn (&rgnClip);

        //-----------
        // Draw item:
        //-----------
        OnDrawItem (pDC, i, rectItem, bIsPressed, m_nHighlightedItem == i);

        pDC->SelectClipRgn (NULL);

        xMax = max (xMax, rectItem.right);
    }

    //--------------------
    // Draw "tail border":
    //--------------------
    if (nCount == 0)
    {
        rectItem = rect;
        rectItem.right++;
    }
    else
    {
        rectItem.left = xMax;
        rectItem.right = rect.right + 1;
    }

    OnDrawItem (pDC, -1, rectItem, FALSE, FALSE);

    pDC->SelectObject (pOldFont);
}