⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bcgpvisualmanager.cpp

📁 远程网络监视程序的源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	if (!m_bMenuFlatLook || !pButton->IsDroppedDown ())
	{
		OnDrawButtonBorder (pDC, pButton, rect, state);
	}
}
//*************************************************************************************
void CBCGPVisualManager::OnDrawSeparator (CDC* pDC, CBCGPBaseControlBar* pBar,
										 CRect rect, BOOL bHorz)
{
	ASSERT_VALID (pBar);
	ASSERT_VALID (pDC);

	CRect rectSeparator = rect;

	if (bHorz)
	{
		rectSeparator.left += rectSeparator.Width () / 2 - 1;
		rectSeparator.right = rectSeparator.left + 2;
	}
	else
	{
		rectSeparator.top += rectSeparator.Height () / 2 - 1;
		rectSeparator.bottom = rectSeparator.top + 2;
	}

	const COLORREF clrHilite = pBar->IsDialogControl () ?
		globalData.clrBtnHilite : globalData.clrBarHilite;
	const COLORREF clrShadow = pBar->IsDialogControl () ?
		globalData.clrBtnShadow : globalData.clrBarShadow;

	pDC->Draw3dRect (rectSeparator, clrShadow,
									clrHilite);
}
//***************************************************************************************
COLORREF CBCGPVisualManager::OnDrawControlBarCaption (CDC* pDC, CBCGPDockingControlBar* /*pBar*/, 
			BOOL bActive, CRect rectCaption, CRect /*rectButtons*/)
{
	ASSERT_VALID (pDC);

	CBrush br (bActive ? globalData.clrActiveCaption : globalData.clrInactiveCaption);
	pDC->FillRect (rectCaption, &br);

    // get the text color
	return globalData.clrCaptionText;
}
//****************************************************************************************
void CBCGPVisualManager::OnDrawCaptionButton (
						CDC* pDC, CBCGPCaptionButton* pButton, BOOL bActive,
						BOOL bHorz, BOOL bMaximized, BOOL bDisabled, 
						int nImageID /*= -1*/)
{
	ASSERT_VALID (pDC);
    CRect rc = pButton->GetRect ();

	CMenuImages::IMAGES_IDS id = (CMenuImages::IMAGES_IDS)-1;
	
	if (nImageID != -1)
	{
		id = (CMenuImages::IMAGES_IDS)nImageID;
	}
	else
	{
		switch (pButton->GetHit ())
		{
		case HTCLOSE:
		case HTCLOSE_BCG:
			id = CMenuImages::IdClose;
			break;

		case HTMINBUTTON:
			id = bHorz ? 
				bMaximized ? CMenuImages::IdArowLeft : CMenuImages::IdArowRight : 
				bMaximized ? CMenuImages::IdArowDown :  CMenuImages::IdArowUp;
			break;

		case HTMAXBUTTON:
			id = bMaximized ? CMenuImages::IdPinHorz : CMenuImages::IdPinVert;
			break;

		case HTLEFTBUTTON_BCG:
			id = CMenuImages::IdArowBack;
			break;

		case HTRIGHTBUTTON_BCG:
			id = CMenuImages::IdArowForward;
			break;

		case HTMENU_BCG:
			id = CMenuImages::IdArowDown;
			break;
			
		default:
			ASSERT(FALSE);
		}
	}

	CSize sizeImage = CMenuImages::Size ();
	CPoint ptImage (rc.left + (rc.Width () - sizeImage.cx) / 2,
					rc.top + (rc.Height () - sizeImage.cy) / 2);

	if (pButton->m_bPushed && pButton->m_bFocused)
	{
		ptImage.Offset (1, 1);
	}

	CMenuImages::IMAGE_STATE imageState;
	
	if (bDisabled)
	{
		imageState = CMenuImages::ImageGray;
	}
	else if (pButton->m_clrForeground == (COLORREF)-1)
	{
		imageState = bActive ? CMenuImages::ImageWhite : CMenuImages::ImageBlack;
	}
	else
	{
		if (GetRValue (pButton->m_clrForeground) > 128 &&
			GetGValue (pButton->m_clrForeground) > 128 &&
			GetBValue (pButton->m_clrForeground) > 128)
		{
			imageState = CMenuImages::ImageWhite;
		}
		else
		{
			imageState = CMenuImages::ImageBlack;
		}
	}

	CMenuImages::Draw (pDC, id, ptImage, imageState);

	if (!bDisabled)
	{
		if (pButton->m_bPushed && pButton->m_bFocused)
		{
			pDC->Draw3dRect (rc, globalData.clrBarDkShadow, globalData.clrBarLight);
			rc.DeflateRect (1, 1);
			pDC->Draw3dRect (rc, globalData.clrBarDkShadow, globalData.clrBarHilite);
		}
		else if (!m_bLook2000)
		{
			pDC->Draw3dRect (rc, globalData.clrBarLight, globalData.clrBarDkShadow);
			rc.DeflateRect (1, 1);
			pDC->Draw3dRect (rc, globalData.clrBarHilite, globalData.clrBarShadow);
		}
		else if (pButton->m_bFocused || pButton->m_bPushed)
		{
			pDC->Draw3dRect (rc, globalData.clrBarHilite, globalData.clrBarShadow);
		}
	}
}
//***********************************************************************************
void CBCGPVisualManager::OnEraseTabsArea (CDC* pDC, CRect rect, 
										 const CBCGPBaseTabWnd* pTabWnd)
{
	ASSERT_VALID (pDC);
	ASSERT_VALID (pTabWnd);

	pDC->FillRect (rect, &globalData.brBarFace);

	COLORREF clrActiveTab = pTabWnd->GetTabBkColor (pTabWnd->GetActiveTab ());

	if (pTabWnd->IsOneNoteStyle () && clrActiveTab != (COLORREF)-1)
	{
		rect.top = rect.bottom - 2;
		pDC->FillSolidRect (rect, clrActiveTab);
	}
}
//***********************************************************************************
void CBCGPVisualManager::OnDrawTab (CDC* pDC, CRect rectTab,
						int iTab, BOOL bIsActive, const CBCGPBaseTabWnd* pTabWnd)
{
	ASSERT_VALID (pTabWnd);
	ASSERT_VALID (pDC);

	COLORREF clrTab = pTabWnd->GetTabBkColor (iTab);

	if (pTabWnd->IsFlatTab ())
	{
		//----------------
		// Draw tab edges:
		//----------------
		#define FLAT_POINTS_NUM	4
		POINT pts [FLAT_POINTS_NUM];

		const int nHalfHeight = pTabWnd->GetTabsHeight () / 2;

		if (pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM)
		{
			rectTab.bottom --;

			pts [0].x = rectTab.left;
			pts [0].y = rectTab.top;

			pts [1].x = rectTab.left + nHalfHeight;
			pts [1].y = rectTab.bottom;

			pts [2].x = rectTab.right - nHalfHeight;
			pts [2].y = rectTab.bottom;

			pts [3].x = rectTab.right;
			pts [3].y = rectTab.top;
		}
		else
		{
			rectTab.top ++;

			pts [0].x = rectTab.left + nHalfHeight;
			pts [0].y = rectTab.top;

			pts [1].x = rectTab.left;
			pts [1].y = rectTab.bottom;

			pts [2].x = rectTab.right;
			pts [2].y = rectTab.bottom;

			pts [3].x = rectTab.right - nHalfHeight;
			pts [3].y = rectTab.top;

			rectTab.left += 2;
		}

		CBrush* pOldBrush = NULL;
		CBrush br (clrTab);

		if (!bIsActive && clrTab != (COLORREF)-1)
		{
			pOldBrush = pDC->SelectObject (&br);
		}

		pDC->Polygon (pts, FLAT_POINTS_NUM);

		if (pOldBrush != NULL)
		{
			pDC->SelectObject (pOldBrush);
		}
	}
	else
	{
		CRect rectClip;
		pTabWnd->GetTabsRect (rectClip);

		BOOL bIsCutted = FALSE;

		const BOOL bIsOneNote = pTabWnd->IsOneNoteStyle ();
		if (bIsOneNote)
		{
			const int nExtra = (iTab == 0 || bIsActive) ? 0 : rectTab.Height ();

			if (rectTab.left + nExtra + 10 > rectClip.right ||
				rectTab.right - 10 <= rectClip.left)
			{
				return;
			}
		}

		const int iVertOffset = 2;
		const int iHorzOffset = 2;

		#define POINTS_NUM	8
		POINT pts [POINTS_NUM];

		if (!bIsActive || bIsOneNote)
		{
			if (!bIsOneNote)
			{
				if (pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM)
				{
					rectTab.bottom -= iVertOffset;
				}
				else
				{
					rectTab.top += iVertOffset;
				}
			}

			if (clrTab != (COLORREF)-1 || bIsOneNote)
			{
				CRgn rgn;
				CBrush br (clrTab == (COLORREF)-1 ? globalData.clrBtnFace : clrTab);

				CRect rectFill = rectTab;

				if (bIsOneNote)
				{
					CRect rectFill = rectTab;

					const int nHeight = rectFill.Height ();

					pts [0].x = rectFill.left;
					pts [0].y = rectFill.bottom;

					pts [1].x = rectFill.left + 2;
					pts [1].y = rectFill.bottom - 1;

					pts [2].x = rectFill.left + 4;
					pts [2].y = rectFill.bottom - 2;
					
					pts [3].x = rectFill.left + nHeight;
					pts [3].y = rectFill.top + 2;
					
					pts [4].x = rectFill.left + nHeight + 4;
					pts [4].y = rectFill.top;
					
					pts [5].x = rectFill.right - 2;
					pts [5].y = rectFill.top;
					
					pts [6].x = rectFill.right;
					pts [6].y = rectFill.top + 2;

					pts [7].x = rectFill.right;
					pts [7].y = rectFill.bottom;

					for (int i = 0; i < POINTS_NUM; i++)
					{
						if (pts [i].x > rectClip.right)
						{
							pts [i].x = rectClip.right;
							bIsCutted = TRUE;
						}

						if (pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM)
						{
							pts [i].y = rectFill.bottom - pts [i].y + rectFill.top - 1;
						}
					}

					rgn.CreatePolygonRgn (pts, POINTS_NUM, WINDING);
					pDC->SelectClipRgn (&rgn);
				}
				else
				{
					rectFill.DeflateRect (1, 1);
				}

				pDC->FillRect (rectFill, &br);
				pDC->SelectClipRgn (NULL);

				if (bIsOneNote)
				{
					CRect rectLeft;
					pTabWnd->GetClientRect (rectLeft);
					rectLeft.right = rectClip.left - 1;

					pDC->ExcludeClipRect (rectLeft);

					if (iTab > 0 && !bIsActive && iTab != pTabWnd->GetFirstVisibleTabNum ())
					{
						CRect rectLeftTab = rectClip;
						rectLeftTab.right = rectFill.left + rectFill.Height () - 10;

						if (pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM)
						{
							rectLeftTab.top--;
						}
						else
						{
							rectLeftTab.bottom++;
						}

						pDC->ExcludeClipRect (rectLeftTab);
					}

					pDC->Polyline (pts, POINTS_NUM);

					if (bIsCutted)
					{
						pDC->MoveTo (rectClip.right, rectTab.top);
						pDC->LineTo (rectClip.right, rectTab.bottom);
					}

					CRect rectRight = rectClip;
					rectRight.left = rectFill.right;

					pDC->ExcludeClipRect (rectRight);
				}
			}
		}

		CPen penLight (PS_SOLID, 1, globalData.clrBarHilite);
		CPen penShadow (PS_SOLID, 1, globalData.clrBarShadow);

		CPen* pOldPen = NULL;

		if (bIsOneNote)
		{
			pOldPen = (CPen*) pDC->SelectObject (&penLight);
			ASSERT(pOldPen != NULL);

			if (pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM)
			{
				if (!bIsCutted)
				{
					int yTop = bIsActive ? pts [7].y - 1 : pts [7].y;

					pDC->MoveTo (pts [6].x - 1, pts [6].y);
					pDC->LineTo (pts [7].x - 1, yTop);
				}
			}
			else
			{
				pDC->MoveTo (pts [2].x, pts [2].y + 1);
				pDC->LineTo (pts [3].x + 1, pts [3].y);

				pDC->MoveTo (pts [3].x + 1, pts [3].y + 1);
				pDC->LineTo (pts [3].x + 2, pts [3].y + 1);

				pDC->MoveTo (pts [3].x + 2, pts [3].y);
				pDC->LineTo (pts [3].x + 4, pts [3].y);

				pDC->MoveTo (pts [4].x, pts [4].y + 1);
				pDC->LineTo (pts [5].x + 1, pts [5].y + 1);

				if (!bIsActive && !bIsCutted)
				{
					pDC->SelectObject (&penShadow);

					pDC->MoveTo (pts [6].x - 2, pts [6].y - 1);
					pDC->LineTo (pts [6].x - 1, pts [6].y - 1);
				}

				pDC->MoveTo (pts [6].x - 1, pts [6].y);
				pDC->LineTo (pts [7].x - 1, pts [7].y);
			}
		}
		else
		{
			if (pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM)
			{
				pOldPen = (CPen*) pDC->SelectObject (&penLight);
				ASSERT(pOldPen != NULL);

				pDC->MoveTo (rectTab.left, rectTab.top);
				pDC->LineTo (rectTab.left, rectTab.bottom - iVertOffset);

				pDC->SelectStockObject (BLACK_PEN);

				pDC->LineTo (rectTab.left + iHorzOffset, rectTab.bottom);
				pDC->LineTo (rectTab.right - iHorzOffset, rectTab.bottom);
				pDC->LineTo (rectTab.right, rectTab.bottom - iVertOffset);
				pDC->LineTo (rectTab.right, rectTab.top - 1);

				pDC->SelectObject(&penShadow);

				pDC->MoveTo (rectTab.left + iHorzOffset + 1, rectTab.bottom - 1);
				pDC->LineTo (rectTab.right - iHorzOffset, rectTab.bottom - 1);
				pDC->LineTo (rectTab.right - 1, rectTab.bottom - iVertOffset);
				pDC->LineTo (rectTab.right - 1, rectTab.top - 1);
			}
			else
			{
				pOldPen = (CPen*) pDC->SelectStockObject (BLACK_PEN);
				ASSERT(pOldPen != NULL);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -