Exemplo n.º 1
0
//***********************************************************************
// Method:	CColorButton::DrawItem()
// Notes:	None.
//***********************************************************************
void CColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	ASSERT(lpDrawItemStruct);

	CDC*    pDC      = CDC::FromHandle(lpDrawItemStruct->hDC);
	UINT    state    = lpDrawItemStruct->itemState;
    CRect   rDraw    = lpDrawItemStruct->rcItem;
	CRect	rArrow;

	if (m_bPopupActive)
		state |= ODS_SELECTED|ODS_FOCUS;

	//******************************************************
	//**                  Draw Outer Edge
	//******************************************************
	UINT uFrameState = DFCS_BUTTONPUSH|DFCS_ADJUSTRECT;

	if (state & ODS_SELECTED)
		uFrameState |= DFCS_PUSHED;

	if (state & ODS_DISABLED)
		uFrameState |= DFCS_INACTIVE;
	
	pDC->DrawFrameControl(&rDraw,
						  DFC_BUTTON,
						  uFrameState);


	if (state & ODS_SELECTED)
		rDraw.OffsetRect(1,1);

	//******************************************************
	//**                     Draw Focus
	//******************************************************
	if (state & ODS_FOCUS) 
    {
		RECT rFocus = {rDraw.left,
					   rDraw.top,
					   rDraw.right - 1,
					   rDraw.bottom};
  
        pDC->DrawFocusRect(&rFocus);
    }

	rDraw.DeflateRect(::GetSystemMetrics(SM_CXEDGE),
					  ::GetSystemMetrics(SM_CYEDGE));

	//******************************************************
	//**                     Draw Arrow
	//******************************************************
	rArrow.left		= rDraw.right - g_ciArrowSizeX - ::GetSystemMetrics(SM_CXEDGE) /2;
	rArrow.right	= rArrow.left + g_ciArrowSizeX;
	rArrow.top		= (rDraw.bottom + rDraw.top)/2 - g_ciArrowSizeY / 2;
	rArrow.bottom	= (rDraw.bottom + rDraw.top)/2 + g_ciArrowSizeY / 2;

	DrawArrow(pDC,
			  &rArrow,
			  0,
			  (state & ODS_DISABLED) 
			  ? ::GetSysColor(COLOR_GRAYTEXT) 
			  : RGB(0,0,0));


	rDraw.right = rArrow.left - ::GetSystemMetrics(SM_CXEDGE)/2;

	//******************************************************
	//**                   Draw Separator
	//******************************************************
	pDC->DrawEdge(&rDraw,
				  EDGE_ETCHED,
				  BF_RIGHT);

	rDraw.right -= (::GetSystemMetrics(SM_CXEDGE) * 2) + 1 ;
				  
	//******************************************************
	//**                     Draw Color
	//******************************************************
	if ((state & ODS_DISABLED) == 0)
	{
		pDC->FillSolidRect(&rDraw,
						   (m_Color == CLR_DEFAULT)
						   ? m_DefaultColor
						   : m_Color);

		::FrameRect(pDC->m_hDC,
					&rDraw,
					(HBRUSH)::GetStockObject(BLACK_BRUSH));
	}
}
Exemplo n.º 2
0
void CColourPopup::DrawCell(CDC* pDC, int nIndex)
{
    // For the Custom Text area
    if (m_strCustomText.GetLength() && nIndex == CUSTOM_BOX_VALUE)
    {
        // The extent of the actual text button
        CRect TextButtonRect = m_CustomTextRect;
        TextButtonRect.top += 2*m_nMargin;

        // Fill background
        pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DFACE));

        // Draw horizontal line
        pDC->FillSolidRect(m_CustomTextRect.left+2*m_nMargin, m_CustomTextRect.top,
                           m_CustomTextRect.Width()-4*m_nMargin, 1, ::GetSysColor(COLOR_3DSHADOW));
        pDC->FillSolidRect(m_CustomTextRect.left+2*m_nMargin, m_CustomTextRect.top+1,
                           m_CustomTextRect.Width()-4*m_nMargin, 1, ::GetSysColor(COLOR_3DHILIGHT));

        TextButtonRect.DeflateRect(1,1);

        // fill background
        if (m_nChosenColourSel == nIndex && m_nCurrentSel != nIndex)
            pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DLIGHT));
        else
            pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DFACE));

        // Draw button
        if (m_nCurrentSel == nIndex) 
            pDC->DrawEdge(TextButtonRect, BDR_RAISEDINNER, BF_RECT);
        else if (m_nChosenColourSel == nIndex)
            pDC->DrawEdge(TextButtonRect, BDR_SUNKENOUTER, BF_RECT);

        // Draw custom text
        CFont *pOldFont = (CFont*) pDC->SelectObject(&m_Font);
        pDC->SetBkMode(TRANSPARENT);
        pDC->DrawText(m_strCustomText, TextButtonRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
        pDC->SelectObject(pOldFont);

        return;
    }        

    // For the Default Text area
    if (m_strDefaultText.GetLength() && nIndex == DEFAULT_BOX_VALUE)
    {
        // Fill background
        pDC->FillSolidRect(m_DefaultTextRect, ::GetSysColor(COLOR_3DFACE));

        // The extent of the actual text button
        CRect TextButtonRect = m_DefaultTextRect;
        TextButtonRect.DeflateRect(1,1);

        // fill background
        if (m_nChosenColourSel == nIndex && m_nCurrentSel != nIndex)
            pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DLIGHT));
        else
            pDC->FillSolidRect(TextButtonRect, ::GetSysColor(COLOR_3DFACE));

        // Draw thin line around text
        CRect LineRect = TextButtonRect;
        LineRect.DeflateRect(2*m_nMargin,2*m_nMargin);
        CPen pen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW));
        CPen* pOldPen = pDC->SelectObject(&pen);
        pDC->SelectStockObject(NULL_BRUSH);
        pDC->Rectangle(LineRect);
        pDC->SelectObject(pOldPen);

        // Draw button
        if (m_nCurrentSel == nIndex) 
            pDC->DrawEdge(TextButtonRect, BDR_RAISEDINNER, BF_RECT);
        else if (m_nChosenColourSel == nIndex)
            pDC->DrawEdge(TextButtonRect, BDR_SUNKENOUTER, BF_RECT);

        // Draw custom text
        CFont *pOldFont = (CFont*) pDC->SelectObject(&m_Font);
        pDC->SetBkMode(TRANSPARENT);
        pDC->DrawText(m_strDefaultText, TextButtonRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
        pDC->SelectObject(pOldFont);

        return;
    }        

    CRect rect;
    if (!GetCellRect(nIndex, rect)) return;

    // Select and realize the palette
    CPalette* pOldPalette = NULL;
    if (pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE)
    {
        pOldPalette = pDC->SelectPalette(&m_Palette, FALSE);
        pDC->RealizePalette();
    }

    // fill background
    if (m_nChosenColourSel == nIndex && m_nCurrentSel != nIndex)
        pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DHILIGHT));
    else
        pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE));

    // Draw button
    if (m_nCurrentSel == nIndex) 
        pDC->DrawEdge(rect, BDR_RAISEDINNER, BF_RECT);
    else if (m_nChosenColourSel == nIndex)
        pDC->DrawEdge(rect, BDR_SUNKENOUTER, BF_RECT);

    CBrush brush(PALETTERGB(GetRValue(GetColour(nIndex)), 
                            GetGValue(GetColour(nIndex)), 
                            GetBValue(GetColour(nIndex)) ));
    CPen   pen;
    pen.CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW));

    CBrush* pOldBrush = (CBrush*) pDC->SelectObject(&brush);
    CPen*   pOldPen   = (CPen*)   pDC->SelectObject(&pen);

    // Draw the cell colour
    rect.DeflateRect(m_nMargin+1, m_nMargin+1);
    pDC->Rectangle(rect);

    // restore DC and cleanup
    pDC->SelectObject(pOldBrush);
    pDC->SelectObject(pOldPen);
    brush.DeleteObject();
    pen.DeleteObject();

    if (pOldPalette && pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE)
        pDC->SelectPalette(pOldPalette, FALSE);
}
Exemplo n.º 3
0
void CGuiSliderCtrl::DrawVThumb(CDC* pDC,CRect rcClient)
{
	//------------------------------------------
	//prefiero todo a pulso
	//------------------------------------------
	CPen cpGreen(PS_SOLID,1,m_clrGreen);
	CPen cpOrange(PS_SOLID,1,m_clrOrange);
	CPen cp(PS_SOLID,1,m_dl.GetRGBPressBXP());
	CPen cpFondo(PS_SOLID,1,m_dl.GetRGBFondoXP());
	CPen cpSombra(PS_SOLID,1,RGB(225,225,225));
	CPen cpSombraDark(PS_SOLID,1,RGB(200,200,200));
	CPen* pOld;
	CBrush cb;
	int y;
	
	//se pinta arriba y luego por la derecha
	//vertice left,top
	pOld=pDC->SelectObject(&cp);
	int nMedio=rcClient.Height()-7;
	//------------------------------------------
	//pintar el fondo estilo  xp
	//------------------------------------------
	rcClient.right-=1;
	rcClient.bottom++;
	CRect m_rectTemp=rcClient;
	m_rectTemp.bottom-=5;
	m_rectTemp.DeflateRect(1,1);
	cb.CreateSolidBrush(m_dl.GetRGBColorXP());
	pDC->FillRect(&m_rectTemp,&cb);
	//*************************************************
	// -
	pDC->MoveTo(rcClient.left+1,rcClient.top);
	pDC->LineTo(rcClient.right,rcClient.top);
	// |
	pDC->MoveTo(rcClient.left,rcClient.top+1);
	pDC->LineTo(rcClient.left,rcClient.top+nMedio);

	// |
	pDC->MoveTo(rcClient.right,rcClient.top+1);
	pDC->LineTo(rcClient.right,rcClient.top+nMedio);
	//Algo de sombra
	pDC->SelectObject(&cpSombraDark);
	pDC->MoveTo(rcClient.right-1,rcClient.top+1);
	pDC->LineTo(rcClient.right-1,rcClient.top+nMedio+2);

	pDC->SelectObject(&cpSombra);
	pDC->MoveTo(rcClient.right-2,rcClient.top+1);
	pDC->LineTo(rcClient.right-2,rcClient.top+nMedio+2);
	pDC->MoveTo(rcClient.left+1,rcClient.top+1);
	pDC->LineTo(rcClient.left+1,rcClient.top+nMedio);

	//-----------------------------------------------------------
	//se pinta los colores de acuerdo al la seleccion del boton
	//naranja si se selecciona y verde normal, en la parte superior
	//-----------------------------------------------------------
	rcClient.DeflateRect(1,1);
	pDC->SelectObject(bSelected!=TRUE?&cpGreen:&cpOrange);
	for (int i=0; i<3;i++)
	{
		pDC->MoveTo(rcClient.left,rcClient.top+i);
		pDC->LineTo(rcClient.right+1,rcClient.top+i);
			
	}
	rcClient.InflateRect(1,1);
	pDC->SelectObject(&cp);
	//-------------------------------------------------------------
	//se pinta la punta
	//-------------------------------------------------------------
	for (y =0; y<5;y++)
	{
		pDC->SetPixel(rcClient.left+y,rcClient.top+nMedio+y,m_dl.GetRGBPressBXP());
		pDC->SetPixel(rcClient.right-y,rcClient.top+nMedio+y,m_dl.GetRGBPressBXP());
	}
	pDC->SetPixel(rcClient.right-y,rcClient.top+nMedio+y,m_dl.GetRGBPressBXP());
	//********************************************************
	
	//-----------------------------------------------------------
	//se pinta los colores de acuerdo al la seleccion del boton
	//naranja si se selecciona y verde normal
	//-----------------------------------------------------------
	pDC->SelectObject(bSelected!=TRUE?&cpGreen:&cpOrange);
	
	for (y =0; y<5;y++)
	{
		pDC->SetPixel((rcClient.left+y)+1,rcClient.top+nMedio+y,
			bSelected!=TRUE?m_clrGreen:m_clrOrange);
		pDC->SetPixel((rcClient.right-y)-1,(rcClient.top+nMedio+y),
			bSelected!=TRUE?m_clrGreen:m_clrOrange);
	}

	//-----------------------------------------------------------
	//se pinta sombra a la punta para dar un aspecto mas grueso 
	//al boton
	//-----------------------------------------------------------
	pDC->SelectObject(bSelected!=TRUE?&cpGreen:&cpOrange);
	
	for (y =0; y<4;y++)
	{
		pDC->SetPixel((rcClient.left+y)+2,rcClient.top+nMedio+y,
			RGB(225,225,225));
		pDC->SetPixel((rcClient.right-y)-2,rcClient.top+nMedio+y,
			RGB(200,200,200));
	}

	pDC->SelectObject(pOld);

	//uff!!!, que rutina tan aburridora de hacer!!!! 
}
Exemplo n.º 4
0
void ECommentPane::OnPaint()
{
	CRect   cr;
	GetClientRect(&cr);

	CPaintDC PaintDC(this);
	CDC* pDC = &PaintDC;

	//
	//
	//

//----------------
// flicker
//----------------
	CDC* pParsedDC = pDC;
	CDC     MemDC;
	CBitmap MemBM;
	MemBM.CreateCompatibleBitmap(pParsedDC,cr.Width(),cr.Height());
	MemDC.CreateCompatibleDC(pParsedDC);
	MemDC.SelectObject(&MemBM);
	pDC = &MemDC;
//----------------

	CRect r = cr;

	CFont f;

	pDC->SetBkColor(RGB(255,255,255));

	CRect rlef = r;
	CRect rrig = r;

	rlef.right = 17;
	rrig.left  = rlef.right;

	pDC->FillSolidRect( r , ::GetSysColor(COLOR_3DFACE  ));

	m_pPropWnd->DrawFrame( pDC , r , true , m_pPropWnd->GetColorPaneKey() );

	rrig.DeflateRect(2,2);
	r.DeflateRect(5,3);

	CRect TextAreaRect = r;

	//
	//
	//

	CString sTitle = "-";
	CString sNoComments = "-";

	//
	//
	//

	int nWeight = FW_MEDIUM;	//m_bMinimized ? FW_BOLD : FW_MEDIUM;

	f.CreateFont(13,0,0,0,nWeight,0,0,0,0,0,0,0,0, _T("tahoma") );
	pDC->SelectObject(&f);



	if( m_pCommentHost!=NULL )
	{
		CString sName;
		CString s = m_pCommentHost->GetCurrentComment( sName );

		UINT nFlags = DT_LEFT | DT_WORDBREAK;

		if( s.GetLength()==0 )
		{
			s = sNoComments;
			nFlags = DT_SINGLELINE | DT_CENTER | DT_VCENTER;
		}
		else
		{
			while( true )
			{
				CRect TrimmedTextRect = TextAreaRect;

				pDC->DrawText( s , TrimmedTextRect , DT_WORDBREAK | DT_CALCRECT );

				if( TrimmedTextRect.Height() <= TextAreaRect.Height() )
				{
					break;
				}

				if( s.GetLength() <= 4 )
				{
					s = "...";
					break;
				}

				s = s.Left( s.GetLength()-4 );
				s += "...";
			}

		}

		pDC->DrawText( s , TextAreaRect , nFlags );
	}

//--------------------------
// flicker
//--------------------------
	MemDC.SetViewportOrg(0,0);
	pParsedDC->BitBlt( 0 , 0 , cr.Width() , cr.Height() , &MemDC , 0 , 0 , SRCCOPY );
//--------------------------


}
Exemplo n.º 5
0
void CVierOpRijViewWnd::OnPaint()
{
	static CFont S_font;
	if(S_font.m_hObject == NULL)
//		S_font.CreatePointFont(80, L"MS Sans Serif");
		S_font.CreatePointFont(70, L"Courier New");
	CPaintDC dc(this);
	CFont* pOldFont = dc.SelectObject(&S_font);
	CRect rectClient;
	GetClientRect(&rectClient);
	dc.FillSolidRect(rectClient, RGB(255,255,255));

	// **** Stats

	CRect rectStats  = rectClient;
	rectStats.bottom = rectClient.top + 20;
	rectClient.top   = rectStats.bottom + 1;
	dc.Rectangle(rectStats);
	rectStats.DeflateRect(2,2);
	//rectStats.left  += 2;
	dc.DrawText(m_Stats.c_str(), rectStats, DT_LEFT);

	// **** Progress

//	static CFont sCourier;
//	if(sCourier.m_hObject == NULL)
//		sCourier.CreatePointFont(60, L"Courier New", &dc);

//	CFont * pOldFont2 = dc.SelectObject(&sCourier);
	
	CRect rectProgress = rectClient;
	rectProgress.right = rectProgress.left + 80;
	rectClient.left    = rectProgress.right + 1;

	dc.Rectangle(rectProgress);
	rectProgress.DeflateRect(2,2);
	dc.DrawText(m_Progress.c_str(), rectProgress, DT_TOP | DT_LEFT);

//	dc.SelectObject(pOldFont2);

	// **** Scores
	CRect rectScores  = rectClient;
	rectScores.bottom = rectClient.top + 20;
	rectClient.top    = rectScores.bottom + 1;

	dc.SetTextColor(RGB(0, 0, 0));
	dc.SetBkMode(TRANSPARENT);
	for(int x = 0; x < VierOpRijVeld::Sm_Breedte; ++x)
	{
		if(!m_Scores[x].m_bBekend)
			continue; //Score niet bekend. Dus maar niet tekenen...

		CRect rectVakje(
			(int)(rectScores.left   + x       * (1.0 * rectScores.Width() / VierOpRijVeld::Sm_Breedte)),
			rectScores.top,

			(int)(rectScores.left   + (x + 1) * (1.0 * rectScores.Width() / VierOpRijVeld::Sm_Breedte)),
			rectScores.bottom);

		std::wstringstream score;
		int waarde = m_Scores[x].m_Waarde;
		if     (waarde >= CZetBedenker::Sm_PlusMax) score << "Winst ("   << waarde - CZetBedenker::Sm_PlusMax << ")";
		else if(waarde <= CZetBedenker::Sm_MinMax)  score << "Verlies (" << CZetBedenker::Sm_MinMax - waarde << ")";
		else score << waarde;

//		switch(m_Scores[x].m_Waarde) 
//		{
//		case CZetBedenker::Sm_PlusMax:	score << "Winst"; break;
//		case CZetBedenker::Sm_MinMax:	score << "Verlies"; break;
//		default: score << m_Scores[x].m_Waarde;
//		}
		
		dc.DrawText(score.str().c_str(), rectVakje, DT_CENTER);
	}

	// *** Vakjes



	for(int x = 0; x < VierOpRijVeld::Sm_Breedte; ++x)
		for(int y = 0; y < VierOpRijVeld::Sm_Hoogte; ++y)
		{
			CRect rectVakje(
				(int)(rectClient.left   + x       * (1.0 * rectClient.Width() / VierOpRijVeld::Sm_Breedte)),
				(int)(rectClient.bottom - (y + 1) * (1.0 * rectClient.Height() / VierOpRijVeld::Sm_Hoogte)),

				(int)(rectClient.left   + (x + 1) * (1.0 * rectClient.Width() / VierOpRijVeld::Sm_Breedte)),
				(int)(rectClient.bottom - y       * (1.0 * rectClient.Height() / VierOpRijVeld::Sm_Hoogte)));
			
			rectVakje.DeflateRect(1,1);
			COLORREF kleur = RGB(150, 150, 150);
			switch(Veld().Wie(x, y))
			{
			case 1: kleur = RGB(255,0,0); break;
			case 2: kleur = RGB(255,255,0); break;
			}
			dc.FillSolidRect(rectVakje, kleur);
		}

	dc.SelectObject(pOldFont);
}
BOOL CDJWStatic::OnEraseBkgnd(CDC* pDC) 
{
	CDC dcMemory;
	CBitmap bmpTemp, *pOldBitmap;
	CRect rect;
	GetClientRect(rect);
	int nWidth  = rect.Width();		//宽
	int nHeight = rect.Height();	//高

	if (m_bCheck == TRUE)//鼠标在控件点击
	{
		//刷新背景
		if (m_unSideBmpID != 0)//有图
		{
			bmpTemp.LoadBitmap(m_unSideBmpID);
			dcMemory.CreateCompatibleDC(pDC);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dcMemory, 0, 0, SRCCOPY);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();
		}else//无图
		{

			//CRect rcTemp(rect);
			//ClientToScreen(&rcTemp);
			//CPoint pointTemp(rcTemp.left, rcTemp.top);
			//::ScreenToClient(GetParent()->GetSafeHwnd(), &pointTemp);
			//rcTemp.SetRect(pointTemp.x, pointTemp.y, pointTemp.x+rect.Width(), pointTemp.y+rect.Height());
			//GetParent()->InvalidateRect(rcTemp, TRUE);

			dcMemory.CreateCompatibleDC(pDC);
			bmpTemp.CreateCompatibleBitmap(pDC, nWidth, nHeight);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			dcMemory.FillSolidRect(0, 0, nWidth, nHeight, ::GetSysColor(COLOR_BTNFACE));
			BLENDFUNCTION bf;
			bf.BlendOp = AC_SRC_OVER;
			bf.BlendFlags = 0;
			bf.SourceConstantAlpha = 255;
			bf.AlphaFormat = 0;
			pDC->AlphaBlend(0, 0, nWidth, nHeight, &dcMemory, 0, 0, nWidth, nHeight, bf);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();

		}

		//刷新控件
		CPen pen(PS_SOLID, 1, RGB(255,255,255));
		CBrush* brush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
		CPen * pOldPen = pDC->SelectObject(&pen);
		CBrush* pOldBrush =pDC->SelectObject(brush);
		pDC->Rectangle(rect);

		if(pOldBrush != NULL)
			pDC->SelectObject(pOldPen);
		if(pOldBrush != NULL)
			pDC->SelectObject(pOldBrush);


		dcMemory.CreateCompatibleDC(pDC);
		bmpTemp.CreateCompatibleBitmap(pDC, nWidth, nHeight);
		pOldBitmap = dcMemory.SelectObject(&bmpTemp);
		dcMemory.FillSolidRect(0, 0, nWidth, nHeight, m_crSideColor);
		BLENDFUNCTION bf;
		bf.BlendOp = AC_SRC_OVER;
		bf.BlendFlags = 0;
		bf.SourceConstantAlpha = 80;//透明度
		bf.AlphaFormat = 0;
		pDC->AlphaBlend(0, 0, nWidth, nHeight, &dcMemory, 0, 0, nWidth, nHeight, bf);
		dcMemory.SelectObject(pOldBitmap);
		bmpTemp.DeleteObject();
		dcMemory.DeleteDC();


		//中心
		if (m_unCenterSelBmpID != 0)
		{
			bmpTemp.LoadBitmap(m_unCenterSelBmpID);
			dcMemory.CreateCompatibleDC(pDC);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			rect.DeflateRect(nWidth/5, nHeight/5);
			pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dcMemory, 0, 0, SRCCOPY);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();
		}
		else//无图
		{
			dcMemory.CreateCompatibleDC(pDC);
			bmpTemp.CreateCompatibleBitmap(pDC, nWidth, nHeight);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			rect.DeflateRect(nWidth/5, nHeight/5);
			dcMemory.FillSolidRect(rect.left, rect.top, rect.Width(), rect.Height(), ::GetSysColor(CTLCOLOR_BTN));
			BLENDFUNCTION bf;
			bf.BlendOp = AC_SRC_OVER;
			bf.BlendFlags = 0;
			bf.SourceConstantAlpha = 255;
			bf.AlphaFormat = 0;
			pDC->AlphaBlend(rect.left, rect.top, rect.Width(), rect.Height(), &dcMemory, rect.left, rect.top, rect.Width(), rect.Height(), bf);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();
		}

	}else if (m_bOverControl == TRUE)//鼠标在控件上
	{

		CPen pen(PS_SOLID, 1, RGB(255,255,255));
		CBrush* brush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
		CPen * pOldPen = pDC->SelectObject(&pen);
		CBrush* pOldBrush =pDC->SelectObject(brush);
		pDC->Rectangle(rect);

		if(pOldBrush != NULL)
			pDC->SelectObject(pOldPen);
		if(pOldBrush != NULL)
			pDC->SelectObject(pOldBrush);


		//边框
		dcMemory.CreateCompatibleDC(pDC);
		bmpTemp.CreateCompatibleBitmap(pDC, nWidth, nHeight);
		pOldBitmap = dcMemory.SelectObject(&bmpTemp);
		dcMemory.FillSolidRect(0, 0, nWidth, nHeight, m_crSideColor);
		BLENDFUNCTION bf;
		bf.BlendOp = AC_SRC_OVER;
		bf.BlendFlags = 0;
		bf.SourceConstantAlpha = 38;
		bf.AlphaFormat = 0;
		pDC->AlphaBlend(0, 0, nWidth, nHeight, &dcMemory, 0, 0, nWidth, nHeight, bf);
		dcMemory.SelectObject(pOldBitmap);
		bmpTemp.DeleteObject();
		dcMemory.DeleteDC();

		//中心
		if (m_unCenterSelBmpID != 0)
		{
			bmpTemp.LoadBitmap(m_unCenterSelBmpID);
			dcMemory.CreateCompatibleDC(pDC);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			rect.DeflateRect(nWidth/5, nHeight/5);
			pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dcMemory, 0, 0, SRCCOPY);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();
		}else//无图
		{
			dcMemory.CreateCompatibleDC(pDC);
			bmpTemp.CreateCompatibleBitmap(pDC, nWidth, nHeight);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			rect.DeflateRect(nWidth/5, nHeight/5);
			dcMemory.FillSolidRect(rect.left, rect.top, rect.Width(), rect.Height(), ::GetSysColor(CTLCOLOR_BTN));
			BLENDFUNCTION bf;
			bf.BlendOp = AC_SRC_OVER;
			bf.BlendFlags = 0;
			bf.SourceConstantAlpha = 255;
			bf.AlphaFormat = 0;
			pDC->AlphaBlend(rect.left, rect.top, rect.Width(), rect.Height(), &dcMemory, rect.left, rect.top, rect.Width(), rect.Height(), bf);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();
		}


	}else//普通状态
	{

		//边框
		if (m_unSideBmpID != 0)//有图
		{
			bmpTemp.LoadBitmap(m_unSideBmpID);
			dcMemory.CreateCompatibleDC(pDC);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dcMemory, 0, 0, SRCCOPY);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();
		}else//无图
		{
			dcMemory.CreateCompatibleDC(pDC);
			bmpTemp.CreateCompatibleBitmap(pDC, nWidth, nHeight);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			dcMemory.FillSolidRect(0, 0, nWidth, nHeight, ::GetSysColor(COLOR_BTNFACE));
			BLENDFUNCTION bf;
			bf.BlendOp = AC_SRC_OVER;
			bf.BlendFlags = 0;
			bf.SourceConstantAlpha = 255;
			bf.AlphaFormat = 0;
			pDC->AlphaBlend(0, 0, nWidth, nHeight, &dcMemory, 0, 0, nWidth, nHeight, bf);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();

		}

		//中心
		if (m_unCenterBmpID != 0)
		{
			bmpTemp.LoadBitmap(m_unCenterBmpID);
			dcMemory.CreateCompatibleDC(pDC);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			rect.DeflateRect(/*nWidth/4*/nWidth, nHeight/*nHeight/4*/);
			pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dcMemory, 0, 0, SRCCOPY);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();
		}else//无图
		{
			dcMemory.CreateCompatibleDC(pDC);
			bmpTemp.CreateCompatibleBitmap(pDC, nWidth, nHeight);
			pOldBitmap = dcMemory.SelectObject(&bmpTemp);
			rect.DeflateRect(nWidth/4, nHeight/4);
			dcMemory.FillSolidRect(rect.left, rect.top, rect.Width(), rect.Height(), ::GetSysColor(CTLCOLOR_BTN));
			BLENDFUNCTION bf;
			bf.BlendOp = AC_SRC_OVER;
			bf.BlendFlags = 0;
			bf.SourceConstantAlpha = 255;
			bf.AlphaFormat = 0;
			pDC->AlphaBlend(rect.left, rect.top, rect.Width(), rect.Height(), &dcMemory, rect.left, rect.top, rect.Width(), rect.Height(), bf);
			dcMemory.SelectObject(pOldBitmap);
			bmpTemp.DeleteObject();
			dcMemory.DeleteDC();
		}

	}
	return TRUE;
}
Exemplo n.º 7
0
void CCalendarCtrl::DrawCells(CDC* pDC)
{
	CRect rc;
	GetClientRect(&rc);
	int ncHeight = (rc.Height()-CALENDAR_HEADER_HEIGHT)/CALENDAR_ROWS;
	int ncWidth = rc.Width()/CALENDAR_COLUMNS;

	CPen whitePen(PS_SOLID, 1, RGB(255,255,255));
	CPen blackPen(PS_SOLID, 1, RGB(0,0,0));

	CFont* pOldFont = pDC->SelectObject(&m_DefaultFont);
	CPen* pOldPen = pDC->SelectObject(&blackPen);

	for(int i=0; i<CALENDAR_ROWS ; i++)
	{
		for(int u=0; u<CALENDAR_COLUMNS ; u++)
		{
			CRect rect;
			if(GetRectFromCell(i, u, rect))
			{
				if(u == CALENDAR_COLUMNS-1) rect.right = rc.right;
				if(i == CALENDAR_ROWS-1) rect.bottom = rc.bottom;

				if((m_bMonthIsOdd &&  !(m_dayCells[i][u].date.GetMonth()%2))
					|| (!m_bMonthIsOdd && (m_dayCells[i][u].date.GetMonth()%2)))
				{
					CBrush br;
					br.CreateSolidBrush(CALENDAR_LIGHTGREY);
					pDC->FillRect(&rect ,&br);
				}

				COleDateTime today(time(NULL));
				bool btoday = false;
				if(today.GetDay() == m_dayCells[i][u].date.GetDay()	&& today.GetMonth() == m_dayCells[i][u].date.GetMonth()	&& today.GetYear() == m_dayCells[i][u].date.GetYear())
				{
					// Draw the frame 
					CRect rcLine(rect);
					rcLine.bottom = rcLine.top+15;
					rcLine.top = rcLine.bottom-1;
					for(int c=0; c<15; c++)
					{
						pDC->FillSolidRect(rcLine, GetFadedBlue(c*6));
						rcLine.bottom--;
						rcLine.top = rcLine.bottom-1;
					}
					btoday = true;
				}

				// Draw the selection
				bool bSelected = false;
				time_t tmax = max(m_SelectionRange[0], m_SelectionRange[1]);
				time_t tmin = min(m_SelectionRange[0], m_SelectionRange[1]);			
				time_t tcur = DateToSeconds(m_dayCells[i][u].date);				
				if(m_RandomSelection.GetCount())
				{	
					POSITION pos = m_RandomSelection.GetStartPosition();	 
					while (pos){
						void* p; DWORD date;
						m_RandomSelection.GetNextAssoc(pos, (void*&)date, p);
						if(date == (DWORD)tcur)
						{							
							CBrush br;
							br.CreateSolidBrush(GetFadedBlue(70));
							CRect selRect(rect);
							if(btoday)	selRect.top += 15;
							pDC->FillRect(&selRect, &br);
							bSelected = true;
						}
					}

					if(m_SelectionRange[2] == tcur)
					{
						rect.left+=2;	rect.right -=1;
						rect.top+=2;	rect.bottom -=1;
						pDC->DrawFocusRect(rect);
					}
				}
				else if((tmax >= tcur) && (tcur >= tmin))
				{						
					CRect selRect(rect);
					CBrush br;
					br.CreateSolidBrush(GetFadedBlue(70));
					if(btoday)	selRect.top += 15;
					pDC->FillRect(&selRect, &br);
					bSelected = true;
				}

				// Out of range
				if( (m_dayCells[i][u].date >= m_BoundUp) || 
					(m_dayCells[i][u].date <= m_BoundDown) )	
				{
					CRect selRect(rect);
					CBrush br;
					br.CreateSolidBrush(RGB(255,225,225));
					pDC->FillRect(&selRect, &br);
				}

				if(m_dayCells[i][u].bMark)
				{
					CBrush br;
					br.CreateSolidBrush(RGB(255,104,4));
					CRect rcMark(rect);
					rcMark.DeflateRect(3,3);
					rcMark.right = rcMark.left +6;
					rcMark.bottom = rcMark.top +6;
					pDC->FillRect(&rcMark, &br);
				}

				// draw inside...
				rect.DeflateRect(1,1);		
				CString csDay;
				int nDay = m_dayCells[i][u].date.GetDay();
				if(nDay == 1 || (i==0 && u==0))
				{
					csDay.Format(_T("%s %d"), m_dayCells[i][u].date.Format(_T("%B")), nDay);
					CSize dtSize(pDC->GetTextExtent(csDay));
					if(dtSize.cx>rect.Width())
						csDay.Format(_T("%s %d"), m_dayCells[i][u].date.Format(_T("%b")), nDay);
				}
				else
					csDay.Format(_T("%d"), nDay);

				unsigned long nColor;
				if(bSelected && !btoday)
					nColor = pDC->SetTextColor(RGB(255,104,4));
				else
					nColor = pDC->SetTextColor(RGB(0,0,0));
				pDC->DrawText(csDay, rect, DT_RIGHT|DT_TOP);
				pDC->SetTextColor(nColor);

				// Draw the cell content if possible
				if(rect.Width() >= 15)
				{
					for (int j=0; j<m_dayCells[i][u].csaLines.GetSize(); j++)
					{
						CRect txtRect(rect);
						CRect dotRect(rect);

						txtRect.left += 9; //CALENDAR_LINE_HEIGHT;
						txtRect.right-= 2;
						txtRect.top += (j+1)*CALENDAR_LINE_HEIGHT; 

						dotRect.top += (j+1)*CALENDAR_LINE_HEIGHT+(CALENDAR_LINE_HEIGHT/2-1); 
						dotRect.bottom = dotRect.top + 3;
						dotRect.left += 3;
						dotRect.right = dotRect.left +3;

						m_dayCells[i][u].bPartial = false;
						if(!m_dayCells[i][u].csaLines[j].IsEmpty() && txtRect.Height() > CALENDAR_LINE_HEIGHT)
						{
							pDC->SetTextColor(RGB(0,0,0));
							pDC->DrawText(m_dayCells[i][u].csaLines[j], txtRect, DT_LEFT|DT_TOP);								
							CBrush br;
							br.CreateSolidBrush(RGB(125,175,255));
							pDC->FillRect(&dotRect, &br);
						}
						else if(!m_dayCells[i][u].csaLines[j].IsEmpty())
						{
							CPen dotPen(PS_SOLID, 1, RGB(170,170,170));
							pDC->SelectObject(&dotPen);
							// Draw a little arrow
							static int t[2][7] = {5,5,8,8,8,5,5,4,3,2,1,2,3,4};
							int n = 0;
							for(int r=7; r>0; r--){
								pDC->MoveTo(rect.right-9+r, rect.bottom-t[0][n]);
								pDC->LineTo(rect.right-9+r, rect.bottom-t[1][n]);
								n++;
							}
							m_dayCells[i][u].bPartial = true;
							break;
						}
					}
				}
			}
		}
	}

	pDC->SelectObject(pOldFont);
	pDC->SelectObject(pOldPen);
}
Exemplo n.º 8
0
//////////////////////////////////////////
//
// 绘制标题栏
//
// pDC[in]	设备上下文
//
void CDialogBarEx::PaintTitle(CDC *pDC)
{
	CString strText;
	CRect	TextRect;
	COLORREF	OldColor;
	int			OldBkMode;
	CPen	Pen,*OldPen;
	CFont * pFont;

	CRect   gripper;
	gripper = m_TitleRect;
	gripper.left += 50;
	gripper.right -= 30;
	gripper.top += 6;
	gripper.bottom = gripper.top + 3;
	pDC->Draw3dRect(&gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
        ::GetSysColor(COLOR_BTNSHADOW));
	gripper.OffsetRect(0, 3);
	pDC->Draw3dRect(&gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
        ::GetSysColor(COLOR_BTNSHADOW));

	//刷标题栏 
//	pDC->FillRect(&m_TitleRect,&m_TitleBarBrush);

	//保存先前设置
	OldBkMode=pDC->SetBkMode(TRANSPARENT);
	OldColor=pDC->SetTextColor(RGB(0,0,0));
	pFont = pDC->SelectObject(GetFont());

	this->GetWindowText(strText);
	TextRect=m_TitleRect;

	TextRect.left+=3;
	TextRect.OffsetRect(0, 3);
	pDC->DrawText(strText,&TextRect,DT_LEFT);

	// 恢复先前设置
	pDC->SetTextColor(OldColor);
	pDC->SetBkMode(OldBkMode);
	pDC->SelectObject(pFont);

	//
	// 绘制关闭按钮
	// 如果鼠标在按钮内就用红色画笔
	//
	if(this->m_IsInCloseButton)
	{
		Pen.CreatePen(PS_SOLID,0,RGB(255,0,0));
		OldPen=pDC->SelectObject(&Pen);

	}

	CRect rClose;
	rClose = m_CloseButtonRect;
	rClose.DeflateRect(2, 2);
	
	pDC->MoveTo(rClose.left,rClose.top);
	pDC->LineTo(rClose.right,rClose.bottom);
	pDC->MoveTo(rClose.right,rClose.top);
	pDC->LineTo(rClose.left,rClose.bottom);

	if(this->m_IsInCloseButton)
	{
		pDC->SelectObject(OldPen);
	}
}
Exemplo n.º 9
0
void CCJFlatHeaderCtrl::DrawFlatBorder()
{
	CDC* pDC = GetDC();

	CRect rci;
	GetWindowRect(&rci);
	ScreenToClient(&rci);

	// Cover up thick 3D border.
	pDC->Draw3dRect(rci, ::GetSysColor(COLOR_3DFACE),
		::GetSysColor(COLOR_3DFACE));
	rci.DeflateRect(1,1);
	pDC->Draw3dRect(rci, ::GetSysColor(COLOR_3DFACE),
		::GetSysColor(COLOR_3DFACE));

	// Draw flat style border around entire header.
	rci.InflateRect(1,1);
	pDC->Draw3dRect(rci, ::GetSysColor(COLOR_3DHILIGHT),
		::GetSysColor(COLOR_3DSHADOW));

	// Create the pens for further cover-up.
	CPen penLite(PS_SOLID, 1, ::GetSysColor(COLOR_3DHILIGHT));
	CPen penShad(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW));
	CPen penFace(PS_SOLID, 1, ::GetSysColor(COLOR_3DFACE));
	CPen *pOldPen = pDC->SelectObject( &penLite );

	pDC->SelectObject(&penFace);
	pDC->MoveTo(rci.right-1, 2);
	pDC->LineTo(rci.right-1, rci.bottom-2);

	// Set up the header item struct.
	HD_ITEM hdi;
	memset (&hdi, 0, sizeof(HD_ITEM));
	hdi.fmt  = HDF_STRING | HDF_LEFT | HDF_OWNERDRAW;
	hdi.mask = HDI_WIDTH | HDI_TEXT | HDI_FORMAT;
	int cx = 0;

	// For each header item found, do further cover up.
	for (int i = 0; i < GetItemCount(); ++i)
	{
		GetItem(i, &hdi);
		cx += hdi.cxy;

		pDC->SelectObject(&penShad);
		pDC->MoveTo(cx, 2);
		pDC->LineTo(cx, rci.bottom-2);

		pDC->SelectObject(&penLite);
		pDC->MoveTo(cx+1, 2);
		pDC->LineTo(cx+1, rci.bottom-2);

		pDC->SelectObject(&penFace);
		pDC->MoveTo(cx-1, 2);
		pDC->LineTo(cx-1, rci.bottom-2);

		pDC->SelectObject(&penFace);
		pDC->MoveTo(cx-2, 2);
		pDC->LineTo(cx-2, rci.bottom-2);
	}

	// Restore the pen and release device context.
	pDC->SelectObject( pOldPen );
	ReleaseDC(pDC);
}
Exemplo n.º 10
0
void CTabsDlg::DockWindow ( int ID , bool dock )
{
	DockedWindowInfo* info = NULL;
	m_Windows.Lookup ( (WORD)ID , (void*&)info );

	ASSERT ( info );
	ASSERT ( m_Tabs.GetSafeHwnd() );
	
	ShowAllWindows ( FALSE );

	if ( !dock )
	{		
		//make a containing window and assign the dialog to it
		CRect rect;
		CString classname = AfxRegisterWndClass ( CS_DBLCLKS , 0 , 0 , 0 );
		info->m_State = DockedWindowInfo::FLOATING;

		info->m_Window->GetWindowRect(rect);
		info->m_Container.CreateEx ( WS_EX_TOOLWINDOW , classname , info->m_Title , WS_THICKFRAME | WS_SYSMENU | WS_POPUP | WS_CAPTION, rect , this , 0 );		
		info->m_Window->SetParent ( &info->m_Container );
		info->m_Window->ShowWindow(TRUE);

		info->m_Container.SetDockManager(this);
		info->m_Container.ShowWindow(TRUE);
		info->m_Container.SetDialog ( info->m_Window , info->m_ID );

		if (info->m_TabControlIndex >= 0 )
		{
			m_Tabs.DeleteItem( info->m_TabControlIndex );
		}		

		if ( m_Tabs.GetItemCount() > 0 )
		{
			m_Tabs.SetCurFocus( 0 );
		}	

		CString placementName = info->m_Title + "Placement";
		LoadWindowPlacement(info->m_Container , placementName);
	}
	else
	{		
		info->m_State = DockedWindowInfo::DOCKED;		
	
		info->m_TabControlIndex = m_Tabs.InsertItem( TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM , 0 , info->m_Title , info->m_ImageID , (LPARAM)info);		

		info->m_Window->SetParent ( this );		
		info->m_Window->ShowWindow (TRUE);
		
		info->m_Container.SetDockManager( NULL );	//so it doesn't try to call back and redock this window
		info->m_Container.DestroyWindow ();

		CRect rect;
		GetWindowRect ( rect );

		//stupid hack to get the window reitself properly
		rect.DeflateRect(0,0,0,1);
		MoveWindow(rect);	
		rect.InflateRect(0,0,0,1);
		MoveWindow(rect);	
	}

	UpdateTabControlIndices ();
	FocusWindow ( ID );

	if ( info->m_DockCallback )
	{
		info->m_DockCallback ( dock , info->m_ID , info->m_Window );
	}
	SaveWindowPlacement ();
}
Exemplo n.º 11
0
void CPlayerSeekBar::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	bool fEnabled = m_fEnabled && m_start < m_stop;

	COLORREF
	white = GetSysColor(COLOR_WINDOW),
	shadow = GetSysColor(COLOR_3DSHADOW),
	light = GetSysColor(COLOR_3DHILIGHT),
	bkg = GetSysColor(COLOR_BTNFACE);

	// thumb
	{
		CRect r = GetThumbRect(), r2 = GetInnerThumbRect();
		CRect rt = r, rit = r2;

		dc.Draw3dRect(&r, light, 0);
		r.DeflateRect(0, 0, 1, 1);
		dc.Draw3dRect(&r, light, shadow);
		r.DeflateRect(1, 1, 1, 1);

		CBrush b(bkg);

		dc.FrameRect(&r, &b);
		r.DeflateRect(0, 1, 0, 1);
		dc.FrameRect(&r, &b);

		r.DeflateRect(1, 1, 0, 0);
		dc.Draw3dRect(&r, shadow, bkg);

		if(fEnabled)
		{
			r.DeflateRect(1, 1, 1, 2);
			CPen white(PS_INSIDEFRAME, 1, white);
			CPen* old = dc.SelectObject(&white);
			dc.MoveTo(r.left, r.top);
			dc.LineTo(r.right, r.top);
			dc.MoveTo(r.left, r.bottom);
			dc.LineTo(r.right, r.bottom);
			dc.SelectObject(old);
			dc.SetPixel(r.CenterPoint().x, r.top, 0);
			dc.SetPixel(r.CenterPoint().x, r.bottom, 0);
		}

		dc.SetPixel(r.CenterPoint().x+5, r.top-4, bkg);

		{
			CRgn rgn1, rgn2;
			rgn1.CreateRectRgnIndirect(&rt);
			rgn2.CreateRectRgnIndirect(&rit);
			ExtSelectClipRgn(dc, rgn1, RGN_DIFF);
			ExtSelectClipRgn(dc, rgn2, RGN_OR);
		}
	}

	// channel
	{
		CRect r = GetChannelRect();

		dc.FillSolidRect(&r, fEnabled ? white : bkg);
		r.InflateRect(1, 1);
		dc.Draw3dRect(&r, shadow, light);
		dc.ExcludeClipRect(&r);
	}

	// background
	{
		CRect r;
		GetClientRect(&r);
		CBrush b(bkg);
		dc.FillRect(&r, &b);
	}


	// Do not call CDialogBar::OnPaint() for painting messages
}
Exemplo n.º 12
0
void CPieView::Draw2DPie(CDC* pDc)
{

    /*if (pDiskLetter.IsEmpty())
    	return;*/

    CRect rectArea;

    GetClientRect(&rectArea);
    rectArea.DeflateRect(2, 2);
    pDc->FillSolidRect(&rectArea, WHITE_RGB);

    ULARGE_INTEGER Zero= {0};

    //if (pCapacity.QuadPart==Zero.QuadPart)
    //	return;

    rectArea.top = rectArea.top+DEFAULT_MARGIN;
    rectArea.right = rectArea.right - DEFAULT_MARGIN;
    rectArea.left = rectArea.left + DEFAULT_MARGIN;
    rectArea.bottom = rectArea.bottom - DEFAULT_MARGIN;

    COLORREF clr[2];
    clr[0]=USED_RGB;
    clr[1]=FREE_RGB;



    CPen* pOldPen;
    CBrush* pOldBrush;


    int CenterX, CenterY, radius, NewXLocation, NewYLocation,
        lastXLocation, lastYLocation;
    CenterX=rectArea.left + rectArea.Width()/2;
    CenterY=rectArea.top + rectArea.Height()/2;

    radius=min(rectArea.Height(), rectArea.Width())/2;

    lastXLocation = CenterX + radius;
    lastYLocation = CenterY;

    CRect pieRect;
    pieRect.top = CenterY - radius;
    pieRect.left = CenterX - radius;
    pieRect.bottom = CenterY + radius;
    pieRect.right = CenterX + radius;




    double Slice[2]= {0};
    Slice[0] = (double) (pUsed.QuadPart * 1.0 / pCapacity.QuadPart);
    Slice[1] = (double) (pFree.QuadPart * 1.0 / pCapacity.QuadPart);



    double degree=0, dataSum=0;

    for (int i=0; i<2; i++)
    {
        dataSum += Slice[i];
        degree = dataSum*2.0*3.141592;

        NewXLocation = CenterX + (int) ((double) radius*cos(degree));
        NewYLocation = CenterY - (int) ((double) radius*sin(degree));

        CPoint p1(lastXLocation, lastYLocation);
        CPoint p2(NewXLocation, NewYLocation);

        CBrush brush(clr[i]);
        CPen piePen(PS_SOLID, 1, clr[i]);
        pOldPen = pDc->SelectObject(&piePen);
        pOldBrush =pDc->SelectObject(&brush);

        pDc->Pie(pieRect, p1, p2);

        pDc->SelectObject(pOldBrush);
        pDc->SelectObject(pOldPen);

        lastXLocation = NewXLocation;
        lastYLocation = NewYLocation;
    }
}
Exemplo n.º 13
0
void CKofBCGPFontComboBox::OnPaint()
{
	if ((GetStyle () & 0x0003L) == CBS_SIMPLE)
	{
		Default ();
		return;
	}

	if (!m_bVisualManagerStyle && !m_bOnGlass)
	{
		Default ();
		return;
	}

	CPaintDC dc(this); // device context for painting
	BYTE alpha = 0;
	if (m_bOnGlass)
	{
		alpha = 255;
	}
	CBCGPMemDC memDC (dc, this, alpha);
	CDC* pDC = &memDC.GetDC ();

	CRect rectClient;
	GetClientRect (rectClient);

	CBCGPDrawManager dm (*pDC);
	dm.DrawRect (rectClient, globalData.clrWindow, (COLORREF)-1);
//  得注释掉这句话
// 	SendMessage (WM_PRINTCLIENT, (WPARAM) pDC->GetSafeHdc (), (LPARAM) PRF_CLIENT);
	const int cxDropDown = ::GetSystemMetrics (SM_CXVSCROLL) + 4;

	int nCurSel = GetCurSel();
	if (CB_ERR != nCurSel)
	{
		if (m_Images.GetSafeHandle () == NULL)
		{
			CBCGPLocalResource locaRes;
			m_Images.Create (IDB_BCGBARRES_FONT, nImageWidth, 0, RGB (255, 255, 255));
		}

		CFont fontSelected;
		CFont* pOldFont = NULL;
		CRect rc(rectClient);		
		rc.right -= cxDropDown;

		CBCGPFontDesc* pDesc = (CBCGPFontDesc*)GetItemDataPtr(nCurSel);
		if (pDesc != NULL)
		{			
			if (pDesc->m_nType & (DEVICE_FONTTYPE | TRUETYPE_FONTTYPE))
			{
				CPoint ptImage (rc.left + 3, rc.top + (rc.Height () - nImageHeight) / 2);
				m_Images.Draw (pDC, pDesc->GetImageIndex (), ptImage, ILD_NORMAL);
			}

			rc.left += nImageWidth + 9;

			if (m_bDrawUsingFont && pDesc->m_nCharSet != SYMBOL_CHARSET)
			{
				LOGFONT lf;
				globalData.fontRegular.GetLogFont (&lf);

				lstrcpy (lf.lfFaceName, pDesc->m_strName);

				if (pDesc->m_nCharSet != DEFAULT_CHARSET)
				{
					lf.lfCharSet = pDesc->m_nCharSet;
				}

				if (lf.lfHeight < 0)
				{
					lf.lfHeight -= 4;
				}
				else
				{
					lf.lfHeight += 4;
				}

				fontSelected.CreateFontIndirect (&lf);
				pOldFont = pDC->SelectObject (&fontSelected);
			}
		}

		CString strText;
		GetLBText (nCurSel, strText);

		pDC->DrawText (strText, rc, DT_SINGLELINE | DT_VCENTER);

		if (pOldFont != NULL)
		{
			pDC->SelectObject (pOldFont);
		}
	}

	m_rectBtn = rectClient;
	m_rectBtn.left = m_rectBtn.right - cxDropDown;

	m_rectBtn.DeflateRect (2, 2);

	CBCGPDrawOnGlass dog (m_bOnGlass);

	CKofBCGPToolbarComboBoxButton buttonDummy;
#ifndef _BCGSUITE_
	buttonDummy.m_bIsCtrl = TRUE;

	CBCGPVisualManager::GetInstance ()->OnDrawComboDropButton (
		pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown,
		m_bIsButtonHighlighted,
		&buttonDummy);
#else
	CMFCVisualManager::GetInstance ()->OnDrawComboDropButton (
		pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown,
		m_bIsButtonHighlighted,
		&buttonDummy);
#endif

	dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrBarShadow);
	rectClient.DeflateRect (1, 1);
	dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrWindow);
}
Exemplo n.º 14
0
/////////////////////////////////////////////////////////////////////////////
// CCSTMCombo message handlers
void CCSTMCombo::DrawBorder(CDC* pDC)
{
	CRect rcItem;
	DWORD dwExStyle = GetExStyle();
	int nBorderWidth = 0;

	GetWindowRect(&rcItem);
	ScreenToClient(&rcItem);

	if (dwExStyle & WS_EX_DLGMODALFRAME)
	{
		nBorderWidth += 3;
	}
	if (dwExStyle & WS_EX_CLIENTEDGE)
	{
		nBorderWidth += 2;
	}
	if (dwExStyle & WS_EX_STATICEDGE && !(dwExStyle & WS_EX_DLGMODALFRAME))
	{
		nBorderWidth ++;
	}
	if(m_bDrawOutline)
	{
		pDC->Draw3dRect(rcItem, m_clrOutLineColor,m_clrOutLineColor );
		rcItem.DeflateRect(1,1);
	}

	COLORREF	colorBoard = m_clr3DFace;
	if(m_bDrawFlat)
	{
		colorBoard = m_clrBackColor;

		nBorderWidth  = m_bDrawOutline ? 1 : 2;
	}

	if (m_bDrawFlat == FALSE) 
	{
	
		rcItem.InflateRect(1, 1);
		if (dwExStyle & WS_EX_CLIENTEDGE) {
			pDC->Draw3dRect(rcItem, m_clr3DDkShadow, m_clr3DLight);

			rcItem.InflateRect(1, 1);
			pDC->Draw3dRect(rcItem, m_clr3DShadow, m_clr3DHilight);
			rcItem.InflateRect(1, 1);
		}

		if (dwExStyle & WS_EX_STATICEDGE && !(dwExStyle & WS_EX_DLGMODALFRAME)) {
			pDC->Draw3dRect(rcItem, m_clr3DShadow, m_clr3DHilight);
			rcItem.InflateRect(1, 1);
		}

		if (dwExStyle & WS_EX_DLGMODALFRAME) {
			pDC->Draw3dRect(rcItem, m_clr3DFace, m_clr3DFace);
			rcItem.InflateRect(1, 1);
			pDC->Draw3dRect(rcItem, m_clr3DHilight, m_clr3DShadow);
			rcItem.InflateRect(1, 1);
			pDC->Draw3dRect(rcItem, m_clr3DLight, m_clr3DDkShadow);
		}
	}

	for (int nLoop = 0; nLoop < nBorderWidth; nLoop++) 
	{
		pDC->Draw3dRect(rcItem, colorBoard, colorBoard);
		rcItem.DeflateRect(1, 1);
	}

	//Button Draw
	rcItem.left = rcItem.right - ::GetSystemMetrics( SM_CXHTHUMB );

	m_rcButton = rcItem;
	BOOL bDropped = GetDroppedState();
	DrawBitmap(pDC,m_rcButton,bDropped);
}
Exemplo n.º 15
0
void CCJFlatComboBox::DrawCombo(DRAWSTATE eStyle, COLORREF clrTopLeft, COLORREF clrBottomRight)
{
	CRect rcItem;
	GetClientRect(&rcItem);
	CDC* pDC = GetDC();
	
	// Cover up dark 3D shadow.
	pDC->Draw3dRect(rcItem, clrTopLeft, clrBottomRight);
	rcItem.DeflateRect(1,1);
	
	if (!IsWindowEnabled()) {
		pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),
			::GetSysColor(COLOR_BTNHIGHLIGHT));
	}
	
	else {
		pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),
			::GetSysColor(COLOR_BTNFACE));
	}

	// Cover up dark 3D shadow on drop arrow.
	rcItem.DeflateRect(1,1);
	rcItem.left = rcItem.right-::GetSystemMetrics(SM_CXHTHUMB);;
	pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),
		::GetSysColor(COLOR_BTNFACE));
	
	// Cover up normal 3D shadow on drop arrow.
	rcItem.DeflateRect(1,1);
	pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),
		::GetSysColor(COLOR_BTNFACE));
	
	if (!IsWindowEnabled()) {
		return;
	}

	switch (eStyle)
	{
	case FC_DRAWNORMAL:
		rcItem.top -= 1;
		rcItem.bottom += 1;
		pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),
			::GetSysColor(COLOR_BTNHIGHLIGHT));
		rcItem.left -= 1;
		pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),
			::GetSysColor(COLOR_BTNHIGHLIGHT));
		break;

	case FC_DRAWRAISED:
		rcItem.top -= 1;
		rcItem.bottom += 1;
		pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),
			::GetSysColor(COLOR_BTNSHADOW));
		break;

	case FC_DRAWPRESSD:
		rcItem.top -= 1;
		rcItem.bottom += 1;
		rcItem.OffsetRect(1,1);
		pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNSHADOW),
			::GetSysColor(COLOR_BTNHIGHLIGHT));
		break;
	}

	ReleaseDC(pDC);
}
Exemplo n.º 16
0
VOID CRenoBuffer::OnPaint()
{
	CPaintDC dc(this);

	CRect clipRect;
	dc.GetClipBox(clipRect);

	CRect clientRect;
	GetClientRect(clientRect);

	// Start doublebuffering
	HDC hCompatibleDC = CreateCompatibleDC(dc.GetSafeHdc());
	HBITMAP hBackbuffer = CreateCompatibleBitmap(dc.GetSafeHdc(),clientRect.Width(),clientRect.Height());
	HBITMAP hOldBitmap  = (HBITMAP)SelectObject(hCompatibleDC,hBackbuffer);

	SetBoundsRect(hCompatibleDC,clipRect,NULL);

	FillRect(hCompatibleDC,clientRect,(HBRUSH)CBrush(BACKGROUND_COLOR).GetSafeHandle());

	HGDIOBJ hOldFont = SelectObject(hCompatibleDC,theApp.GetFont());
	SetBkMode(hCompatibleDC,TRANSPARENT);

	CRect boundsRect;
	GetClientRect(boundsRect);
	boundsRect.DeflateRect(RENO_BUFFER_MARGIN_HORIZONTAL,RENO_BUFFER_MARGIN_VERTICAL);

	COLORREF colorDefault = GetTextColor(hCompatibleDC);
	COLORREF colorSystem = RGB(44,88,222);

	SIZE size;
	TEXTMETRIC textmetrics;

	for(LONG i = m_BufferScrollLine; i < m_Buffer.GetCount(); ++i)
	{
		if(!m_Buffer[i].GetLength())
		{
			GetTextExtentPoint32(hCompatibleDC,TEXT(" "),1,&size);
			boundsRect.bottom -= size.cy;
			continue;
		}

		// Currently only color system messages
		if(m_Buffer[i].GetAt(0) == TEXT('*'))
			SetTextColor(hCompatibleDC,colorSystem);
		else
			SetTextColor(hCompatibleDC,colorDefault);

		// Set a fixed stack size
		ULONG stack[32];
		ULONG stackTop = 0;

		// Put the default font at the bottom of the stack
		stack[stackTop++] = RENO_FONT_NORMAL;

		LONG x = boundsRect.left;
		LONG index = 0;

		while(index < m_Buffer[i].GetLength())
		{
			LONG control = -1;

			// Find a control character
			for(LONG j = index + 1; j < m_Buffer[i].GetLength(); ++j)
			{
				if(m_Buffer[i].GetAt(j) == IRC_CONTROL_BOLD || 
					m_Buffer[i].GetAt(j) == IRC_CONTROL_UNDERLINE || 
					m_Buffer[i].GetAt(j) == IRC_CONTROL_ITALIC || 
					m_Buffer[i].GetAt(j) == IRC_CONTROL_NORMAL)
				{
					// Found one
					control = j;
					break;
				}
			}

			if(control == -1)
			{
				// We are going to the end of the line
				control = m_Buffer[i].GetLength();
			}

			// Colors

			// "black"			: "\x0301",
			// "dark blue"		: "\x0302",
			// "dark green"		: "\x0303",
			// "green"			: "\x0303",
			// "red"			: "\x0304",
			// "light red"		: "\x0304",
			// "dark red"		: "\x0305",
			// "purple"			: "\x0306",
			// "brown"			: "\x0307",	// On some clients this is orange, others it is brown
			// "orange"			: "\x0307",
			// "yellow"			: "\x0308",
			// "light green"	: "\x0309",
			// "aqua"			: "\x0310",
			// "light blue"		: "\x0311",
			// "blue"			: "\x0312",
			// "violet"			: "\x0313",
			// "grey"			: "\x0314",
			// "gray"			: "\x0314",
			// "light grey"		: "\x0315",
			// "light gray"		: "\x0315",
			// "white"			: "\x0316",

			// Other formatting

			// "normal"			: "\x0F",
			// "bold"			: "\x02",
			// "reverse"		: "\x16",
			// "underline"		: "\x1F",

			switch(m_Buffer[i].GetAt(index))
			{
			case IRC_CONTROL_BOLD:
				if(stack[stackTop-1] == RENO_FONT_BOLD)
					--stackTop;	// Pop the top
				else
					stack[stackTop++] = RENO_FONT_BOLD;	// Push

				++index;	// Skip the control character
				break;

			case IRC_CONTROL_ITALIC:
				if(stack[stackTop-1] ==RENO_FONT_ITALIC)
					--stackTop;	// Pop the top
				else
					stack[stackTop++] = RENO_FONT_ITALIC;	// Push

				++index;	// Skip the control character
				break;

			case IRC_CONTROL_UNDERLINE:
				if(stack[stackTop-1] == RENO_FONT_UNDERLINE)
					--stackTop;	// Pop the top
				else
					stack[stackTop++] = RENO_FONT_UNDERLINE;	// Push

				++index;	// Skip the control character
				break;

			case IRC_CONTROL_NORMAL:
				if(stack[stackTop-1] == RENO_FONT_NORMAL && stackTop > 1)
					--stackTop;	// Pop the top
				else
					stack[stackTop++] = RENO_FONT_NORMAL;	// Push

				++index;	// Skip the control character
				break;
			}

			if(control - index)
			{
				SelectObject(hCompatibleDC,theApp.GetFont(stack[stackTop-1]));

				GetTextExtentPoint32(hCompatibleDC,m_Buffer[i].GetBuffer() + index,control - index,&size);

				TextOut(hCompatibleDC,x,boundsRect.bottom - size.cy,m_Buffer[i].GetBuffer() + index,control - index);
				
				x += size.cx;

				// Retrieve the overhang value from the TEXTMETRIC structure and subtract it from the x-increment (This is only necessary for non-TrueType raster fonts)
				GetTextMetrics(hCompatibleDC,&textmetrics);
				x -= textmetrics.tmOverhang;
			}

			index = control;
		}

		GetTextExtentPoint32(hCompatibleDC,TEXT(" "),1,&size);	// TODO Maybe not necessary, the size struct will already be set from some above call
		boundsRect.bottom -= size.cy;

		if(boundsRect.bottom < -size.cy)
			break;	// No point in painting further cause everything would get clipped
	}

	// Update the scrollbar
	if(m_Buffer.GetCount() > 1)
	{
		SelectObject(hCompatibleDC,theApp.GetFont());
		GetTextMetrics(hCompatibleDC,&textmetrics);

		SCROLLINFO info;
		info.cbSize = sizeof(info);

		info.fMask = SIF_ALL;
		info.nMin = 0;
		info.nMax = m_Buffer.GetCount()-1 + clientRect.Height()/textmetrics.tmHeight-1;
		info.nPos = m_Buffer.GetCount()-1 - m_BufferScrollLine;
		info.nPage = clientRect.Height()/textmetrics.tmHeight;

		SetScrollInfo(SB_VERT,&info);
		EnableScrollBar(SB_VERT,ESB_ENABLE_BOTH);
	}
	else
	{
		EnableScrollBar(SB_VERT,ESB_DISABLE_BOTH);
	}

	SelectObject(hCompatibleDC,hOldFont);

	// End doublebuffering
	BitBlt(dc.GetSafeHdc(),0,0,clientRect.Width(),clientRect.Height(),hCompatibleDC,0,0,SRCCOPY);
	SelectObject(hCompatibleDC,hOldBitmap);
	DeleteObject(hBackbuffer);
	DeleteDC(hCompatibleDC);
}
Exemplo n.º 17
0
//рисует стрелку прибора
void CAnalogMeter::DrawNeedle()
{
 CPoint  pPoints[6];
 CString tempString;
 CPen*   pPenOld;
 CBrush* pBrushOld;
 CFont*  pFontOld;
 double  dAngleRad, dX, dY;
 double  dCosAngle, dSinAngle;
 bool    disable_value;
 bool    disable_tlpane;
 bool    disable_trpane;

 if (!m_dcNeedle.GetSafeHdc())
  return;

 if(m_boolUseBitmaps)
 {
  // new pen / brush
  pPenOld   = NULL;
  pBrushOld = NULL;
  if(m_PenN_BGround.m_hObject)
   pPenOld = m_dcNeedle.SelectObject(&m_PenN_BGround);

  if(m_BrushN_BGround.m_hObject)
   pBrushOld = m_dcNeedle.SelectObject(&m_BrushN_BGround);

  m_dcNeedle.Rectangle(m_rectDraw);

  // old pen / brush
  if(pPenOld)
   m_dcGrid.SelectObject(pPenOld);

  if(pBrushOld)
   m_dcGrid.SelectObject(pBrushOld);
 }

 ///////////////////////
 // check sizes       //
 ///////////////////////
 disable_value = false;
 disable_tlpane = false;
 disable_trpane = false;
 if((m_rectGfx.Height() < 50) || (m_rectGfx.Width() < 50))
 {
  disable_value = true;
  disable_tlpane = true;
  disable_trpane = true;
 }
 if((m_rectGfx.Height() < 20) || (m_rectGfx.Width() < 20))
  return;

 if(!disable_value && m_swValue)
 {
  pFontOld = m_dcNeedle.SelectObject(&m_fontValue);
  m_dcNeedle.SetTextAlign(TA_CENTER|TA_BASELINE);
  m_dcNeedle.SetTextColor(m_colorValue^m_colorBGround);
  m_dcNeedle.SetBkColor(RGB(0,0,0));
  tempString.Format(_T("%.*f"), m_nValueDecimals, m_dNeedlePos);

  m_dcNeedle.TextOut((m_rectValue.right+m_rectValue.left)/2,
      m_rectValue.bottom-m_nTextBaseSpacing, tempString);

  m_dcNeedle.SelectObject(pFontOld);
 }

 if (!disable_tlpane && m_swTLPane) //top-left pane
 {
  pFontOld = m_dcNeedle.SelectObject(&m_fontValue);
  m_dcNeedle.SetTextAlign(TA_LEFT | TA_TOP);
  m_dcNeedle.SetTextColor(m_colorTLPane^m_colorBGround);
  m_dcNeedle.SetBkColor(RGB(0,0,0)); 
  CRect rect = m_rectDraw;
  rect.DeflateRect(8,3);
  m_dcNeedle.TextOut(rect.left, rect.top, m_strTLPane);
  m_dcNeedle.SelectObject(pFontOld); 
 }

 if (!disable_trpane && m_swTRPane) //top-right pane
 {
  pFontOld = m_dcNeedle.SelectObject(&m_fontValue);
  m_dcNeedle.SetTextAlign(TA_RIGHT | TA_TOP);
  m_dcNeedle.SetTextColor(m_colorTRPane^m_colorBGround);
  m_dcNeedle.SetBkColor(RGB(0,0,0)); 
  CRect rect = m_rectDraw;
  rect.DeflateRect(8,3);
  m_dcNeedle.TextOut(rect.right, rect.top, m_strTRPane);
  m_dcNeedle.SelectObject(pFontOld);
 }

 dAngleRad = (m_dNeedlePos - m_dMinScale)*m_dRadiansPerValue - m_dLimitAngleRad;
 dAngleRad = std::max(dAngleRad, -m_dLimitAngleRad);
 dAngleRad = std::min(dAngleRad, m_dLimitAngleRad);
 dCosAngle = cos(dAngleRad);
 dSinAngle = sin(dAngleRad);

 // tip
 dX = m_nCXPix + m_nRadiusPix*dSinAngle;
 dY = m_nCYPix - m_nRadiusPix*dCosAngle;
 pPoints[0].x = ROUND(dX);
 pPoints[0].y = ROUND(dY);

 // left base
 dX = m_nCXPix - m_nHalfBaseWidth*dCosAngle;
 dY = m_nCYPix - m_nHalfBaseWidth*dSinAngle;
 pPoints[1].x = ROUND(dX);
 pPoints[1].y = ROUND(dY);

 // right base
 pPoints[2].x = m_nCXPix + (m_nCXPix-pPoints[1].x);
 pPoints[2].y = m_nCYPix + (m_nCYPix-pPoints[1].y);

 // tip
 pPoints[3].x = pPoints[0].x;
 pPoints[3].y = pPoints[0].y;

 // new pen / brush
 pPenOld   = NULL;
 pBrushOld = NULL;
 if(m_PenN_Needle.m_hObject)
  pPenOld = m_dcNeedle.SelectObject(&m_PenN_Needle);

 if(m_BrushN_Needle.m_hObject)
  pBrushOld = m_dcNeedle.SelectObject(&m_BrushN_Needle);

 if (m_swNeedle)
 {
  // draw the needle pointer
  m_dcNeedle.Polygon(pPoints, 4);

  // draw circle at the bottom
  int r = (m_nRadiusPix/20);
  m_dcNeedle.Ellipse (m_nCXPix-m_nHalfBaseWidth-r, m_nCYPix-m_nHalfBaseWidth-r,
  m_nCXPix+m_nHalfBaseWidth+1+r, m_nCYPix+m_nHalfBaseWidth+1+r);
 }

 // old pen / brush
 if(pPenOld)
  m_dcGrid.SelectObject(pPenOld);

 if(pBrushOld)
  m_dcGrid.SelectObject(pBrushOld);

} // end DrawNeedle
Exemplo n.º 18
0
void FW_SizingControlBar::OnNcCalcSize(BOOL bCalcValidRects,
                                     NCCALCSIZE_PARAMS FAR* lpncsp) 
{
    // compute the the client area
    CRect rcClient = lpncsp->rgrc[0];
    rcClient.DeflateRect(5, 5);

    m_dwSCBStyle &= ~SCBS_EDGEALL;

    switch(m_nDockBarID)
    {
    case AFX_IDW_DOCKBAR_TOP:
        m_dwSCBStyle |= SCBS_EDGEBOTTOM;
        rcClient.DeflateRect(m_cyGripper, 0, 0, 0);
        break;
    case AFX_IDW_DOCKBAR_BOTTOM:
        m_dwSCBStyle |= SCBS_EDGETOP;
        rcClient.DeflateRect(m_cyGripper, 0, 0, 0);
        break;
    case AFX_IDW_DOCKBAR_LEFT:
        m_dwSCBStyle |= SCBS_EDGERIGHT;
        rcClient.DeflateRect(0, m_cyGripper, 0, 0);
        break;
    case AFX_IDW_DOCKBAR_RIGHT:
        m_dwSCBStyle |= SCBS_EDGELEFT;
        rcClient.DeflateRect(0, m_cyGripper, 0, 0);
        break;
    default:
        break;
    }

    if (!IsFloating() && m_pDockBar != NULL)
    {
        CSCBArray arrSCBars;
        GetRowSizingBars(arrSCBars);

        for (int i = 0; i < arrSCBars.GetSize(); i++)
            if (arrSCBars[i] == this)
            {
                if (i > 0)
                    m_dwSCBStyle |= IsHorzDocked() ?
                        SCBS_EDGELEFT : SCBS_EDGETOP;
                if (i < arrSCBars.GetSize() - 1)
                    m_dwSCBStyle |= IsHorzDocked() ?
                        SCBS_EDGERIGHT : SCBS_EDGEBOTTOM;
            }
    }

    // make room for edges only if they will be painted
    if (m_dwSCBStyle & SCBS_SHOWEDGES)
        rcClient.DeflateRect(
            (m_dwSCBStyle & SCBS_EDGELEFT) ? m_cxEdge : 0,
            (m_dwSCBStyle & SCBS_EDGETOP) ? m_cxEdge : 0,
            (m_dwSCBStyle & SCBS_EDGERIGHT) ? m_cxEdge : 0,
            (m_dwSCBStyle & SCBS_EDGEBOTTOM) ? m_cxEdge : 0);

    // "hide" button positioning
    CPoint ptOrgBtn;
    if (IsHorzDocked())
        ptOrgBtn = CPoint(rcClient.left - m_cyGripper - 1,
            rcClient.top - 1);
    else
        ptOrgBtn = CPoint(rcClient.right - 11,
            rcClient.top - m_cyGripper - 1);

    m_biHide.Move(ptOrgBtn - CRect(lpncsp->rgrc[0]).TopLeft());

    lpncsp->rgrc[0] = rcClient;
}
Exemplo n.º 19
0
void CCalendarBar::OnPaint()
{
	CPaintDC dc(this); // 用于绘制的设备上下文

	CRect rectClient;
	GetClientRect(rectClient);

	dc.FillRect(rectClient, &afxGlobalData.brWindow);

	if (rectClient.bottom - m_nMyCalendarsY > 0)
	{
		CRect rectMyCalendarsCaption = rectClient;
		rectMyCalendarsCaption.top = m_nMyCalendarsY;
		rectMyCalendarsCaption.bottom = rectMyCalendarsCaption.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2;

		COLORREF clrText = CMFCVisualManager::GetInstance()->OnDrawPaneCaption(&dc, NULL, FALSE, rectMyCalendarsCaption, CRect(0, 0, 0, 0));

		CPen* pOldPen = dc.SelectObject(&afxGlobalData.penBarShadow);

		dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.top);
		dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.top);

		dc.SelectStockObject(BLACK_PEN);

		dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.bottom);
		dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.bottom);

		dc.SelectObject(pOldPen);

		CRect rectText = rectMyCalendarsCaption;
		rectText.DeflateRect(10, 0);

		dc.SetBkMode(TRANSPARENT);
		dc.SetTextColor(clrText);

		CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);

		BOOL bNameValid;
		CString str;

		bNameValid = str.LoadString(IDS_MYCALENDARS);
		ASSERT(bNameValid);
		dc.DrawText(str, rectText, DT_VCENTER | DT_LEFT | DT_SINGLELINE);

		CRect rectCalendar = rectClient;
		rectCalendar.top = rectMyCalendarsCaption.bottom + 5;
		rectCalendar.bottom = rectCalendar.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2 - 5;

		dc.FillSolidRect(rectCalendar, RGB(255, 255, 213));

		rectCalendar.DeflateRect(20, 0);
		m_Images.Draw(&dc, 3, rectCalendar.TopLeft(), 0);

		rectCalendar.left += 20;

		bNameValid = str.LoadString(IDS_CALENDAR);
		ASSERT(bNameValid);

		dc.SetTextColor(afxGlobalData.clrHotLinkNormalText);
		dc.DrawText(str, rectCalendar, DT_VCENTER | DT_LEFT | DT_SINGLELINE);

		dc.SelectObject(pOldFont);
	}
}
Exemplo n.º 20
0
void CXInfoTip::OnPaint() 
{
	CPaintDC dc( this ); 

	CRect	rc;
	CBrush	WindowBrush;
	CBrush	FrameBrush;
	CBrush	InnerFrameBrush;
	HRGN	hRegion;
	CRgn	*pRegion;
	CFont	*pSysFont;

	
	GetClientRect(rc);

	
	InnerFrameBrush.CreateSolidBrush(::GetSysColor(COLOR_SCROLLBAR));
	FrameBrush.CreateSolidBrush(::GetSysColor(COLOR_WINDOWTEXT));
	WindowBrush.CreateSolidBrush(::GetSysColor(COLOR_WINDOW));

	
	GetWindowRegion(&dc, &hRegion);
	pRegion = CRgn::FromHandle(hRegion);

	
	dc.FillRgn(pRegion, &WindowBrush);
	dc.FrameRgn(pRegion, &InnerFrameBrush, 3, 3);
	dc.FrameRgn(pRegion, &FrameBrush, 1, 1);

	
	rc.DeflateRect(CX_ROUNDED, CY_ROUNDED, 0, 0);
	if (m_hIcon != NULL)
		rc.left = rc.left + m_IconSize.cx + CX_ICON_MARGIN;
	
	
	pSysFont = (CFont *)dc.SelectObject(&m_fntBold);
	
	dc.SetBkMode( TRANSPARENT );

	dc.DrawText (m_strCaption, &rc, DT_TOP | DT_LEFT);

	dc.SelectObject(m_pFont);

	CRect rc2 = rc;
	rc2.top += m_nCaptionHeight;
	dc.DrawText(m_szText, &rc2, DT_TOP | DT_LEFT);

	if (m_bShowDSA && m_bPlaced == false)
	{
		m_bPlaced = true;
		m_btnDSA.MoveWindow (rc.left, m_yDSA, m_cxDSA + 10 + 20, 20);
	}

	
	if (m_hIcon != NULL)
		DrawIconEx(dc.m_hDC, CX_ROUNDED, CY_ROUNDED, m_hIcon, m_IconSize.cx, m_IconSize.cy, 0, NULL, DI_NORMAL);

	
	::DeleteObject(hRegion);
	dc.SelectObject(pSysFont);

}                                        
Exemplo n.º 21
0
void CCoolBarItem::Paint(CDC* pDC, CRect& rc, BOOL bDown, BOOL bHot, BOOL bMenuGray, BOOL bTransparent)
{
	COLORREF crBackground;

	if ( m_nID == ID_SEPARATOR )
	{
		if ( ! bTransparent ) pDC->FillSolidRect( rc.left, rc.top, 3, rc.Height(), CoolInterface.m_crMidtone );
		pDC->Draw3dRect( rc.left + 3, rc.top, 1, rc.Height(), CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
		if ( ! bTransparent ) pDC->FillSolidRect( rc.left + 4, rc.top, 3, rc.Height(), CoolInterface.m_crMidtone );
		return;
	}

	if ( m_nCtrlID )
	{
		for ( int nShrink = rc.Height() - m_nCtrlHeight ; nShrink > 0 ; nShrink -= 2 )
		{
			if ( ! bTransparent ) pDC->Draw3dRect( &rc, CoolInterface.m_crMidtone, CoolInterface.m_crMidtone );
			rc.DeflateRect( 0, 1 );
		}
		rc.DeflateRect( 1, 0 );
	}
	else
	{
		if ( ! bTransparent ) pDC->Draw3dRect( &rc, CoolInterface.m_crMidtone, CoolInterface.m_crMidtone );
		rc.DeflateRect( 1, 1 );
	}

//	if ( ( m_bEnabled || m_nCtrlID ) && ( bHot || bDown || m_bChecked ) )
	if ( m_bEnabled && ( bHot || bDown || m_bChecked ) )
	{
		if ( bMenuGray && bDown )
		{
			pDC->Draw3dRect( &rc, CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
		}
		else
		{
			pDC->Draw3dRect( &rc, CoolInterface.m_crBorder, CoolInterface.m_crBorder );
		}

		rc.DeflateRect( 1, 1 );

		if ( bMenuGray && bDown )
		{
			crBackground = CoolInterface.m_crBackNormal;
		}
		else if ( m_bChecked )
		{
			crBackground = bHot ? CoolInterface.m_crBackCheckSel : CoolInterface.m_crBackCheck;
		}
		else
		{
			crBackground = bDown && bHot ? CoolInterface.m_crBackCheckSel : CoolInterface.m_crBackSel;
		}
	}
	else
	{
		if ( bTransparent )
		{
			crBackground = CLR_NONE;
		}
		else
		{
			crBackground = CoolInterface.m_crMidtone;
			pDC->Draw3dRect( &rc, crBackground, crBackground );
		}

		rc.DeflateRect( 1, 1 );
	}

	if ( m_nCtrlID )
	{
		if ( m_nCtrlHeight == CONTROL_HEIGHT )
		{
			pDC->Draw3dRect( &rc, CoolInterface.m_crWindow, CoolInterface.m_crWindow );
			rc.DeflateRect( 1, 1 );
		}
		return;
	}

	if ( crBackground == CLR_NONE )
	{
		pDC->SetBkMode( TRANSPARENT );
	}
	else
	{
		pDC->SetBkMode( OPAQUE );
		pDC->SetBkColor( crBackground );
	}

	if ( m_sText.GetLength() )
	{
		if ( m_crText != 0xFFFFFFFF )
			pDC->SetTextColor( m_crText );
		else if ( ! m_bEnabled )
			pDC->SetTextColor( CoolInterface.m_crDisabled );
		else if ( ( bHot || bDown || m_bChecked ) && ( ! bMenuGray || ! bDown ) )
			pDC->SetTextColor( CoolInterface.m_crCmdTextSel );
		else
			pDC->SetTextColor( CoolInterface.m_crCmdText );

		rc.left += ( m_nImage >= 0 ) ? 20 : 1;
		int nY = ( rc.top + rc.bottom ) / 2 - pDC->GetTextExtent( m_sText ).cy / 2 - 1;
		
		if ( crBackground == CLR_NONE ) 
			pDC->ExtTextOut( rc.left + 2, nY, ETO_CLIPPED, &rc, m_sText, NULL );
		else
			pDC->ExtTextOut( rc.left + 2, nY, ETO_CLIPPED|ETO_OPAQUE, &rc, m_sText, NULL );

		rc.right = rc.left;
		rc.left -= ( m_nImage >= 0 ) ? 20 : 1;
	}

	if ( m_nImage >= 0 )
	{
		CPoint ptImage( rc.left + 3, ( rc.top + rc.bottom ) / 2 - 8 );

		if ( ! m_bEnabled )
		{
			ImageList_DrawEx( CoolInterface.m_pImages.GetSafeHandle(), m_nImage, pDC->GetSafeHdc(),
				ptImage.x, ptImage.y, 0, 0, crBackground, CoolInterface.m_crShadow, ILD_BLEND50 );
			pDC->ExcludeClipRect( ptImage.x, ptImage.y, ptImage.x + 16, ptImage.y + 16 );
		}
		else if ( m_bChecked )
		{
			ImageList_DrawEx( CoolInterface.m_pImages.GetSafeHandle(), m_nImage, pDC->GetSafeHdc(),
				ptImage.x, ptImage.y, 0, 0, crBackground, CLR_NONE, ILD_NORMAL );
			pDC->ExcludeClipRect( ptImage.x, ptImage.y, ptImage.x + 16, ptImage.y + 16 );
		}
		else if ( ( bHot && ! bDown ) || ( bDown && ! bHot ) )
		{
			ptImage.Offset( 1, 1 );
			pDC->SetTextColor( CoolInterface.m_crShadow );
			ImageList_DrawEx( CoolInterface.m_pImages.GetSafeHandle(), m_nImage, pDC->GetSafeHdc(),
				ptImage.x, ptImage.y, 0, 0, crBackground, CLR_NONE, ILD_MASK );

			ptImage.Offset( -2, -2 );

			if ( crBackground != CLR_NONE )
			{
				pDC->FillSolidRect( ptImage.x, ptImage.y, 18, 2, crBackground );
				pDC->FillSolidRect( ptImage.x, ptImage.y + 2, 2, 16, crBackground );
			}

			ImageList_DrawEx( CoolInterface.m_pImages.GetSafeHandle(), m_nImage, pDC->GetSafeHdc(),
				ptImage.x, ptImage.y, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL );

			pDC->ExcludeClipRect( ptImage.x, ptImage.y, ptImage.x + 18, ptImage.y + 18 );
		}
		else
		{
			ImageList_DrawEx( CoolInterface.m_pImages.GetSafeHandle(), m_nImage, pDC->GetSafeHdc(),
				ptImage.x, ptImage.y, 0, 0, crBackground, CoolInterface.m_crBackNormal,
				bDown ? ILD_NORMAL : ILD_BLEND25 );
			pDC->ExcludeClipRect( ptImage.x, ptImage.y, ptImage.x + 16, ptImage.y + 16 );
		}
	}
	
	if ( crBackground != CLR_NONE ) pDC->FillSolidRect( &rc, crBackground );
}
Exemplo n.º 22
0
void CAdvComboBox::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	if( m_nCurSel != -1 )
	{
		m_iter = m_list.begin();
		advance( m_iter, m_nCurSel );
		if( m_iter != m_list.end() )
		{
			m_strEdit = m_iter->strText;
		}
		if( m_bFirstPaint )
		{
			if( m_pEdit )
			{
				m_pEdit->SetWindowText( m_strEdit.c_str() );
				m_bFirstPaint = false;
				m_pEdit->EnableWindow( IsWindowEnabled() );
			}
		}
	}
	
	CRect rect;
	CRect rcText;

	GetClientRect(rect);
	rcText = rect;
	rect.left = rect.right - ::GetSystemMetrics(SM_CXHSCROLL);
	rcText.right = rect.left-1;

	m_rcDropButton = rect;
	GetClientRect(rect);

	BOOL bWndEnabled = IsWindowEnabled();

	COLORREF clrDisabledBkg = ::GetSysColor(COLOR_BTNFACE);
	COLORREF clrDisabledBorder = ::GetSysColor(COLOR_3DDKSHADOW);
	COLORREF clrDisabledText = ::GetSysColor(COLOR_GRAYTEXT);

	if( !bWndEnabled )
	{
		if( 1 ) // Draw disabled flat control with border? Change to '0'.
		{
			dc.FillSolidRect( rect, clrDisabledBkg );
		}
		else
		{
			CBrush brDisabled(clrDisabledBkg);
			CBrush* pOldBrush = dc.SelectObject(&brDisabled);
			CPen penDisabled( PS_SOLID, 0, clrDisabledBorder);
			CPen* pOldPen = dc.SelectObject(&penDisabled);
			dc.Rectangle(rect);
			dc.SelectObject(pOldBrush);
			dc.SelectObject(pOldPen);
		}
	}
	else
	{
		COLORREF clrEnabledBkg = ::GetSysColor(COLOR_WINDOW);
		dc.FillSolidRect( rect, clrEnabledBkg );
	}


	DWORD dwBtnStyle = 0;
	if( !bWndEnabled )
	{
		dwBtnStyle |= DFCS_INACTIVE;
	}
	dwBtnStyle |= m_bDropListVisible ? (DFCS_SCROLLDOWN|DFCS_PUSHED|DFCS_FLAT) : DFCS_SCROLLDOWN;


	BOOL bThemeActive = FALSE;
	HRESULT hr;

	bThemeActive = g_xpStyle.UseVisualStyles();

	HTHEME hTheme = NULL;
	if( bThemeActive )
		hTheme = g_xpStyle.OpenThemeData( m_hWnd, L"COMBOBOX" );

	// Theme drop btn style
	int nDropBtnThemeStyle = 0;
	if( m_bDropListVisible )
	{
		nDropBtnThemeStyle = CBXS_PRESSED;
	}
	else
	{
		nDropBtnThemeStyle = CBXS_NORMAL;
		if( m_bDropButtonHot )
			nDropBtnThemeStyle = CBXS_HOT;
		if( !bWndEnabled )
			nDropBtnThemeStyle = CBXS_DISABLED;
	}

#if 0  // -----------------------------------------------------------
	if( m_dwACBStyle & ACBS_FLAT )
	{
		if( bThemeActive )
		{
			hr = g_xpStyle.DrawThemeBackground( hTheme, dc.m_hDC, CP_DROPDOWNBUTTON, nDropBtnThemeStyle, &m_rcDropButton, NULL);
		}
		else
		{
			dc.DrawFrameControl(m_rcDropButton, DFC_SCROLL, dwBtnStyle );
		}
	}
	else
	if( m_dwACBStyle & ACBS_STANDARD )
#endif // -----------------------------------------------------------
	{
		if( bThemeActive )
		{
			COLORREF clrBorder;
			hr = g_xpStyle.GetThemeColor( hTheme, BP_PUSHBUTTON, bWndEnabled ? PBS_NORMAL : PBS_DISABLED, TMT_BORDERCOLOR, &clrBorder );
			if( FAILED( hr ) )
			{
				clrBorder = RGB(0,0,0);
			}
			CPen penBorder( PS_SOLID, 0, clrBorder );
			CPen* oldBorderPen = dc.SelectObject( &penBorder );
			dc.Rectangle( &rect );
			m_rcDropButton.DeflateRect(0,1,0,1);
			m_rcDropButton.left -= 1;
			m_rcDropButton.right -= 1;

			if( !bWndEnabled )
			{
				COLORREF clrDisabledLightBorder;
				COLORREF clrDisabledFill;
				hr = g_xpStyle.GetThemeColor( hTheme, BP_PUSHBUTTON, bWndEnabled ? PBS_NORMAL : PBS_DISABLED, TMT_FILLCOLOR, &clrDisabledLightBorder );
				if( FAILED( hr ) )
				{
					clrDisabledLightBorder = RGB(255,255,255);
				}
				hr = g_xpStyle.GetThemeColor( hTheme, WP_DIALOG, 0, TMT_FILLCOLOR, &clrDisabledFill );
				if( FAILED( hr ) )
				{
					clrDisabledFill = RGB(255,0,0);
				}
				CPen penDisBorder( PS_SOLID, 0, clrDisabledLightBorder );
				CBrush brFill( clrDisabledBkg );//clrDisabledFill );
				CRect rcl = rect;
				rcl.DeflateRect(1,1);
				rcl.right = m_rcDropButton.left;
				CBrush *oldBr = dc.SelectObject( &brFill );
				dc.SelectObject( &penDisBorder );
				dc.Rectangle( &rcl );
				dc.SelectObject( oldBr );
			}

			dc.SelectObject( &oldBorderPen );
			// Button
			hr = g_xpStyle.DrawThemeBackground( hTheme, dc.m_hDC, CP_DROPDOWNBUTTON, nDropBtnThemeStyle, &m_rcDropButton, NULL);
		}
		else
		{
			COLORREF clrTopLeft = ::GetSysColor(COLOR_3DSHADOW);
			COLORREF clrBottomRight = ::GetSysColor(COLOR_3DHILIGHT);
			dc.Draw3dRect( &rect, clrTopLeft, clrBottomRight );
			clrTopLeft = ::GetSysColor(COLOR_3DDKSHADOW);
			clrBottomRight = ::GetSysColor(COLOR_3DLIGHT);
			rect.DeflateRect(1,1);
			dc.Draw3dRect( &rect, clrTopLeft, clrBottomRight );
			m_rcDropButton.DeflateRect(0,2,0,2);
			m_rcDropButton.left -= 2;
			m_rcDropButton.right -= 2;
			// Button
			dc.DrawFrameControl(m_rcDropButton, DFC_SCROLL, dwBtnStyle );
		}

		//
		// Adjust rects
		rcText.DeflateRect(4,3,2,3);
	}

	if( bThemeActive )
		hr = g_xpStyle.CloseThemeData( hTheme );



	if( (GetStyle() & CBS_DROPDOWN) && (GetStyle() & CBS_SIMPLE) )  // == CBS_DROPDOWNLIST
	{
		//
		// Draw Text as selected
		COLORREF clrBackground;
		COLORREF clrOldBkColor;
		COLORREF clrOldTextColor;
		clrBackground = ::GetSysColor(COLOR_HIGHLIGHT);
		clrOldBkColor = dc.SetBkColor( clrBackground );
	//	clrOldTextColor = dc.SetTextColor( ::GetSysColor(COLOR_HIGHLIGHTTEXT) );
		int nOldBkMode = dc.SetBkMode( TRANSPARENT );
		CFont* pOldFont = dc.SelectObject( m_pFont );
		rcText.top -= 2;
		rcText.bottom += 2;
		rcText.left -= 2;
		rcText.right += 1;

		if( m_bHasFocus && !m_bDropListVisible )
		{
			dc.FillSolidRect( rcText, bWndEnabled ? clrBackground : clrDisabledBkg );
			clrOldTextColor = dc.SetTextColor( 
				bWndEnabled ? ::GetSysColor(COLOR_HIGHLIGHTTEXT) : clrDisabledText );
			dc.DrawText( m_strEdit.c_str(), &rcText, DT_SINGLELINE|DT_VCENTER);
		}
		else
		{
			//+++dc.FillSolidRect( rcText, 
			//+++	bWndEnabled ? ::GetSysColor(COLOR_HIGHLIGHTTEXT) : clrDisabledBkg );
			dc.FillSolidRect( rcText, 
				bWndEnabled ? ::GetSysColor(COLOR_WINDOW) : clrDisabledBkg );
			clrOldTextColor = dc.SetTextColor( 
				bWndEnabled ? ::GetSysColor(COLOR_BTNTEXT) : clrDisabledText );
			dc.DrawText( m_strEdit.c_str(), &rcText, DT_SINGLELINE|DT_VCENTER);
		}

		dc.SelectObject( pOldFont );
		dc.SetBkMode( nOldBkMode );
	}
	else
	{
		if( m_pEdit )
		{
			m_pEdit->SetFont( m_pFont );
		}
	}
	// Do not call CWnd::OnPaint() for painting messages
}
Exemplo n.º 23
0
LRESULT CRegionSelect::OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
	PAINTSTRUCT ps;
	BeginPaint(&ps);

	HDC dc = ps.hdc;

	int w = ps.rcPaint.right-ps.rcPaint.left;
	int h = ps.rcPaint.bottom-ps.rcPaint.top;

	if(m_bPictureChanged)
	{
		if(Down) return 0;
		RECT rc;
		GetClientRect(&rc);
		CRgn newRegion;
		newRegion.CreateRectRgn(0,0,rc.right,rc.bottom);
		SelectClipRgn(doubleDC, newRegion);
		BitBlt(doubleDC,ps.rcPaint.left,ps.rcPaint.top,w,h,memDC2,  ps.rcPaint.left,ps.rcPaint.top,SRCCOPY);
		newRegion.CombineRgn(m_SelectionRegion,RGN_DIFF);
		CBrush br;
		SelectClipRgn(doubleDC, newRegion);
		br.CreateSolidBrush(RGB(200,200,0));
		BLENDFUNCTION bf ;
		//настройки прозрачности
		bf.BlendOp = AC_SRC_OVER;
		bf.BlendFlags = 1;
		bf.SourceConstantAlpha = 40; // прозрачность 50% (0 - 255)
		bf.AlphaFormat = 0;///*0 */ /*AC_SRC_ALPHA*/0;
		
		if(RectCount) 
			if(AlphaBlend(doubleDC, ps.rcPaint.left, ps.rcPaint.top, w,h, alphaDC, ps.rcPaint.left, ps.rcPaint.top, w,h, bf)==FALSE)
			{
				//MessageBox(_T("Alphablend failed"));
			};
		newRegion.DeleteObject();
		newRegion.CreateRectRgn(0,0,rc.right,rc.bottom);
		SelectClipRgn(doubleDC, newRegion);
		RECT SelWndRect;
		if(hSelWnd)
		{
			CRgn WindowRgn = GetWindowVisibleRegion(hSelWnd);
			WindowRgn.OffsetRgn(topLeft);
			WindowRgn.GetRgnBox(&SelWndRect);
			CRect DrawingRect = SelWndRect;
			DrawingRect.DeflateRect(2, 2);
			SelectObject(doubleDC, pen);
			SetROP2(doubleDC, R2_NOTXORPEN);
			SelectClipRgn(doubleDC, 0);
			Rectangle(doubleDC, DrawingRect.left,DrawingRect.top, DrawingRect.right, DrawingRect.bottom);
		}
		m_bPictureChanged = false;
	}
	BitBlt(dc,ps.rcPaint.left,
		ps.rcPaint.top,w,h,doubleDC,ps.rcPaint.left,
		ps.rcPaint.top,SRCCOPY);

	EndPaint(&ps);
	m_bPainted = true;
	return 0;
}
Exemplo n.º 24
0
void CCoolBar::NcPaintGripper(CDC* pDC, CRect rcClient) {
    if (!HasGripper())
        return;
#ifndef _SCB_STYLE_FLAT
    CRect gripper = rcClient;
    CRect rcbtn = m_biHide.GetRect();
    BOOL bHorz = IsHorzDocked();

    gripper.DeflateRect(1, 1);
    if (bHorz) {
        // gripper at left
        gripper.left -= m_cyGripper;
        gripper.right = gripper.left + 3;
        gripper.top = rcbtn.bottom + 3;
    } else {
        // gripper at top
        gripper.top -= m_cyGripper;
        gripper.bottom = gripper.top + 3;
        gripper.right = rcbtn.left - 3;
    }

    pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
                    ::GetSysColor(COLOR_BTNSHADOW));

    gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3);

    pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
                    ::GetSysColor(COLOR_BTNSHADOW));

    m_biHide.Paint(pDC);

#else

    // compute the caption rectangle
    BOOL bHorz = IsHorzDocked();
    CRect rcGrip = rcClient;
    CRect rcBtn = m_biHide.GetRect();
    if (bHorz) {
        // right side gripper
        rcGrip.left -= m_cyGripper + 1;
        rcGrip.right = rcGrip.left + 11;
        rcGrip.top = rcBtn.bottom + 3;
    } else {
        // gripper at top
        rcGrip.top -= m_cyGripper + 1;
        rcGrip.bottom = rcGrip.top + 11;
        rcGrip.right = rcBtn.left - 3;
    }
    rcGrip.InflateRect(bHorz ? 1 : 0, bHorz ? 0 : 1);

    // draw the caption background
    //CBrush br;
    COLORREF clrCptn = m_bActive ?
                       ::GetSysColor(COLOR_ACTIVECAPTION) :
                       ::GetSysColor(COLOR_INACTIVECAPTION);

    // query gradient info (usually TRUE for Win98/Win2k)
    BOOL bGradient = FALSE;
    ::SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradient, 0);

    if (!bGradient)
        pDC->FillSolidRect(&rcGrip, clrCptn); // solid color
    else {
        // gradient from left to right or from bottom to top
        // get second gradient color (the right end)
        COLORREF clrCptnRight = m_bActive ?
                                ::GetSysColor(COLOR_GRADIENTACTIVECAPTION) :
                                ::GetSysColor(COLOR_GRADIENTINACTIVECAPTION);

        // this will make 2^6 = 64 fountain steps
        int nShift = 6;
        int nSteps = 1 << nShift;

        for (int i = 0; i < nSteps; i++) {
            // do a little alpha blending
            int nR = (GetRValue(clrCptn) * (nSteps - i) +
                      GetRValue(clrCptnRight) * i) >> nShift;
            int nG = (GetGValue(clrCptn) * (nSteps - i) +
                      GetGValue(clrCptnRight) * i) >> nShift;
            int nB = (GetBValue(clrCptn) * (nSteps - i) +
                      GetBValue(clrCptnRight) * i) >> nShift;

            COLORREF cr = RGB(nR, nG, nB);

            // then paint with the resulting color
            CRect r2 = rcGrip;
            if (bHorz) {
                r2.bottom = rcGrip.bottom -
                            ((i * rcGrip.Height()) >> nShift);
                r2.top = rcGrip.bottom -
                         (((i + 1) * rcGrip.Height()) >> nShift);
                if (r2.Height() > 0)
                    pDC->FillSolidRect(r2, cr);
            } else {
                r2.left = rcGrip.left +
                          ((i * rcGrip.Width()) >> nShift);
                r2.right = rcGrip.left +
                           (((i + 1) * rcGrip.Width()) >> nShift);
                if (r2.Width() > 0)
                    pDC->FillSolidRect(r2, cr);
            }
        }
    }
Exemplo n.º 25
0
void COXTreeHeader::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	if (m_UxTheme.IsUxThemeLoaded())
	{
		HTHEME hTheme = m_UxTheme.GetWindowTheme(m_hWnd);
		if (hTheme != NULL)
		{

			// Draw the item background
			int iState = HIS_NORMAL;
			if (lpDrawItemStruct->itemState == ODS_SELECTED)
				iState = HIS_PRESSED;
			else
			{
				POINT ptCursor;
				::GetCursorPos(&ptCursor);
				ScreenToClient(&ptCursor);
				CRect rectItem(lpDrawItemStruct->rcItem);
				if (rectItem.PtInRect(ptCursor))
					iState = HIS_HOT;
			}
			m_UxTheme.DrawThemeBackground(hTheme,
				lpDrawItemStruct->hDC,
				HP_HEADERITEM,
				iState,
				&lpDrawItemStruct->rcItem,
				NULL);

			BOOL bDrawArrow;
			if (m_nSortOrder!=0 && lpDrawItemStruct->itemID == (UINT)m_nSortCol)
				bDrawArrow = TRUE;
			else
				bDrawArrow = FALSE;


			// Get the column text and format	
			TCHAR buf[256];	
			HD_ITEM hditem;	
			hditem.mask = HDI_TEXT | HDI_FORMAT;	
			hditem.pszText = buf;
			hditem.cchTextMax = 255;	
			GetItem( lpDrawItemStruct->itemID, &hditem );

			RECT rectText = lpDrawItemStruct->rcItem;
			rectText.left += 9;
			rectText.right -= 9;

			// Determine format for drawing column label
			UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | 
				DT_VCENTER | DT_END_ELLIPSIS ;
			UINT uArrowFormat = DT_SINGLELINE | DT_VCENTER;
			if( hditem.fmt & HDF_CENTER)
			{
				uFormat |= DT_CENTER;
				uArrowFormat |= DT_RIGHT;
				if (bDrawArrow)
					rectText.right -= 12;
			}
			else if( hditem.fmt & HDF_RIGHT)
			{
				uFormat |= DT_RIGHT;
				uArrowFormat |= DT_LEFT;
				if (bDrawArrow)
					rectText.left += 12;
			}
			else
			{
				uFormat |= DT_LEFT;
				uArrowFormat |= DT_RIGHT;
				if (bDrawArrow)
					rectText.right -= 12;
			}

			m_UxTheme.DrawThemeText(hTheme,
				lpDrawItemStruct->hDC,
				HP_HEADERITEM,
				HIS_NORMAL,
				buf,
				-1,
				uFormat,
				0,
				&rectText);

			// Draw the Sort arrow	
			if (bDrawArrow)	
			{
				CDC dc;
				dc.Attach(lpDrawItemStruct->hDC);
				int nSavedDC = dc.SaveDC();
				CFont fontMarlett;
				fontMarlett.CreatePointFont(120, _T("Marlett"));
				dc.SelectObject(&fontMarlett);
				dc.SetBkMode(TRANSPARENT);
				dc.SetTextColor(RGB(128, 128, 128));

				CRect rectArrow = lpDrawItemStruct->rcItem;
				rectArrow.DeflateRect(5, 0, 5, 0);

				if (m_nSortOrder == 1)
					dc.DrawText(_T("5"), -1, &rectArrow, uArrowFormat);
				else
					dc.DrawText(_T("6"), -1, &rectArrow, uArrowFormat);

				// Restore dc	
				dc.RestoreDC(nSavedDC);
				// Detach the dc before returning	
				dc.Detach();
			}
			return;
		}
	}

	CDC dc;
	dc.Attach( lpDrawItemStruct->hDC );	
	// Get the column rect
	CRect rcLabel( lpDrawItemStruct->rcItem );	
	// Save DC
	int nSavedDC = dc.SaveDC();
	// Set clipping region to limit drawing within column	
	CRgn rgn;
	rgn.CreateRectRgnIndirect( &rcLabel );	
	dc.SelectObject( &rgn );
	rgn.DeleteObject(); 
	// Draw the background
	CBrush brush(::GetSysColor(COLOR_3DFACE));
	dc.FillRect(rcLabel,&brush);	
	// Labels are offset by a certain amount  
	// This offset is related to the width of a space character
	int offset = dc.GetTextExtent(_T(" "), 1 ).cx*2;
	// Get the column text and format	
	TCHAR buf[256];	
	HD_ITEM hditem;	
	hditem.mask = HDI_TEXT | HDI_FORMAT;	
	hditem.pszText = buf;
	hditem.cchTextMax = 255;	
	GetItem( lpDrawItemStruct->itemID, &hditem );
	// Determine format for drawing column label
	UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | 
		DT_VCENTER | DT_END_ELLIPSIS ;	
	if( hditem.fmt & HDF_CENTER)
		uFormat |= DT_CENTER;	
	else if( hditem.fmt & HDF_RIGHT)
		uFormat |= DT_RIGHT;
	else
		uFormat |= DT_LEFT;
	// Adjust the rect if the mouse button is pressed on it
	if( lpDrawItemStruct->itemState == ODS_SELECTED )	
	{		
		rcLabel.left++;
		rcLabel.top += 2;		
		rcLabel.right++;	
	}
	// Adjust the rect further if Sort arrow is to be displayed
	if( lpDrawItemStruct->itemID == (UINT)m_nSortCol )	
	{
		rcLabel.right -= 3 * offset;	
	}
	rcLabel.left += offset;
	rcLabel.right -= offset;	
	// Draw column label
	if( rcLabel.left < rcLabel.right )
		dc.DrawText(buf,-1,rcLabel, uFormat);

	// Draw the Sort arrow	
	if( m_nSortOrder!=0 && lpDrawItemStruct->itemID == (UINT)m_nSortCol )	
	{
		CRect rcIcon( lpDrawItemStruct->rcItem );
		// Set up pens to use for drawing the triangle
		CPen penLight(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
		CPen penShadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
		CPen *pOldPen = dc.SelectObject( &penLight );		
		if( m_nSortOrder==1 )		
		{
			// Draw triangle pointing upwards
			dc.MoveTo( rcIcon.right - 2*offset, offset-1);
			dc.LineTo( rcIcon.right - 3*offset/2, rcIcon.bottom - offset );
			dc.LineTo( rcIcon.right - 5*offset/2-2, rcIcon.bottom - offset );
			dc.MoveTo( rcIcon.right - 5*offset/2-1, rcIcon.bottom - offset-1 );
			dc.SelectObject( &penShadow );
			dc.LineTo( rcIcon.right - 2*offset, offset-2);		
		}
		else		
		{
			// Draw triangle pointing downwords
			dc.MoveTo( rcIcon.right - 3*offset/2, offset-1);
			dc.LineTo( rcIcon.right - 2*offset-1, rcIcon.bottom - offset + 1 );
			dc.MoveTo( rcIcon.right - 2*offset-1, rcIcon.bottom - offset );
			dc.SelectObject( &penShadow );
			dc.LineTo( rcIcon.right - 5*offset/2-1, offset -1 );
			dc.LineTo( rcIcon.right - 3*offset/2, offset -1);		
		}
		// Restore the pen
		dc.SelectObject( pOldPen );	
	}

	// Restore dc	
	dc.RestoreDC( nSavedDC );
	// Detach the dc before returning	
	dc.Detach();
}
Exemplo n.º 26
0
// AutoSizeControl ----------------------------------------------------------
void CCodeTipCtrl::AutoSizeControl()
{
   // Notify the parent window that the tooltip is about to be updated so it
   // can make any changes necessary...
   NotifyUpdate();

   // Watch out - the application could have destroyed the tooltip window
   // inside its CodeTipUpdate handler.
   if( !::IsWindow( GetSafeHwnd() ) )
      return;

   // Save original window area so we can tell if it changes...
   CRect rOld;
   GetWindowRect( &rOld );

   // Figure out how big a line of text is based on the current font
   int y = 17;
   HWND hEdit = m_pEdit->GetWindow();
   HFONT hFont = (HFONT)::SendMessage( hEdit, WM_GETFONT, 0, 0 );

   if( hFont )
   {
      LOGFONT lf = {0};
      HDC hdc = ::GetDC( hEdit );

      GetObject( hFont, sizeof(LOGFONT), &lf );
      y = -MulDiv( lf.lfHeight, GetDeviceCaps( hdc, LOGPIXELSY ), 72 );
      ::ReleaseDC( hEdit, hdc );
   }

   // Get the caret position
   POINT ptCaret = {0};

   ::GetCaretPos( &ptCaret );
   ::ClientToScreen( hEdit, &ptCaret );

   // Initially position tooltip below caret position.
   CRect rClient;
   rClient.top = ptCaret.y + y;
   rClient.bottom = rClient.top + 10;

   // If the caret position has moved toward the left edge of the screen,
   // we'll move the tooltip to the left as well.
   CRect rTmp;
   GetClientRect( &rTmp );
   ClientToScreen( &rTmp );
   rClient.left = ( ptCaret.x < rTmp.left ) ? ptCaret.x : rTmp.left;

   // Set the right side so that it does not expand past the visible area on
   // the screen.  When we calculate the client area, it should automatically
   // wrap at this point & expand the bottom of the rectangle as needed.
   //
   CRect rScreen;
   ::SystemParametersInfo( SPI_GETWORKAREA, 0, (LPVOID)&rScreen, 0 );
   rScreen.DeflateRect( 4, 4 );
   rClient.right = rScreen.right;

   // Calculate the client area needed for the text
   HDC hdc = GetDC();

   DrawTipText( hdc, rClient, TRUE );

   // Make sure we don't overflow the right edge of the screen.
   if( rClient.right > rScreen.right )
   {
      rClient.left = rScreen.right - rClient.Width();
      rClient.right = rScreen.right;
   }

   // If we overflow the bottom of the screen, move the tip up a line above
   // the caret instead.
   //
   if( rClient.bottom > rScreen.bottom )
   {
      int h = rClient.Height();
      rClient.bottom = ptCaret.y - y;
      rClient.top = rClient.bottom - h;

      // But watch out - we may we go off the top of the screen now.
      if( rClient.top < rScreen.top )
      {
         // Recalculate the window size using the full screen width, and
         // starting below the caret.
         rClient.top = ptCaret.y + y;
         rClient.left = rScreen.left;
         rClient.right = rScreen.right;

         DrawTipText( hdc, rClient, TRUE );
      }
   }

   // If the tip still goes off the bottom of the screen, we'll have one
   // last stab at placing it above the caret.  If that still doesn't help,
   // then tough noogies buddy - shorten your tooltip text!
   if( rClient.bottom > rScreen.bottom )
   {
      int h = rClient.Height();
      rClient.bottom = ptCaret.y - y;
      rClient.top = rClient.bottom - h;
   }

   ReleaseDC( hdc );

   // Convert client calculated area to screen area
   ::AdjustWindowRectEx( &rClient, GetWindowLong( GWL_STYLE ), FALSE,
      GetWindowLong( GWL_EXSTYLE ) );

   // Okay - one last thing to do before we update the tooltip position: If
   // the caret position is to the right of the tooltip's left edge, and the
   // tooltip doesn't expand all the way across the screen, we'll bump the
   // tip to the right as close to the caret position as possible without
   // going off the screen...
   //
   if( ptCaret.x > rClient.left && rClient.right < rScreen.right )
   {
      // How far do we need to move the tooltip window to align it with the
      // caret position?
      int deltaX = ptCaret.x - rClient.left;

      // Now, how far can we actually move the tooltip without overflowing
      // the right edge of the screen?
      if( rClient.right + deltaX > rScreen.right )
         deltaX = rScreen.right - rClient.right;

      // Bump the tooltip to the right!
      rClient.left += deltaX;
      rClient.right += deltaX;
   }

   // Update the window position / size - but only if it has changed
   if( rOld.left != rClient.left || rOld.right != rClient.right ||
      rOld.top != rClient.top || rOld.bottom != rClient.bottom )
   {
      if( IsWindowVisible( m_hWnd ) )
         MoveWindow( &rClient );
      else
      {
         SetWindowPos( m_hWnd, NULL, rClient.left, rClient.top,
            rClient.Width(), rClient.Height(), SWP_NOACTIVATE |
            SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOREDRAW );
      }
   }

   // Always refresh the window, in case the tip has changed but the window
   // size has not.
   InvalidateRect( NULL );
   UpdateWindow();
}
//*****************************************************************************************
void CBCGPColorButton::OnDraw (CDC* pDC, const CRect& rect, UINT uiState)
{
	ASSERT_VALID (pDC);

	if (m_pPalette == NULL)
	{
		RebuildPalette (NULL);
	}

	CPalette* pCurPalette = pDC->SelectPalette (m_pPalette, FALSE);
	pDC->RealizePalette();

	CSize sizeArrow = CBCGPMenuImages::Size ();

	CRect rectColor = rect;
	rectColor.right -= sizeArrow.cx + nImageHorzMargin;

	CRect rectArrow = rect;
	rectArrow.left = rectColor.right;

	COLORREF color = m_Color;
	if (color == (COLORREF) -1)	// Automatic
	{
		//---------------------------
		// Draw automatic text label:
		//---------------------------
		color = m_ColorAutomatic;
		
		if (!m_strAutoColorText.IsEmpty ())
		{
			rectColor.right = rectColor.left + rectColor.Height ();

			CRect rectText = rect;
			rectText.left = rectColor.right;
			rectText.right = rectArrow.left;

			CFont* pOldFont = SelectFont (pDC);
			ASSERT(pOldFont != NULL);

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

			UINT nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS;

			if (m_bOnGlass)
			{
				CBCGPVisualManager::GetInstance ()->DrawTextOnGlass (pDC, 
					m_strAutoColorText, rectText, nFormat, 0);
			}
			else
			{
				pDC->DrawText (m_strAutoColorText, rectText, nFormat);
			}

			pDC->SelectObject (pOldFont);
		}
	}

	//----------------
	// Draw color box:
	//----------------
	rectColor.DeflateRect (2, 2);

	if (m_bOnGlass)
	{
		CBCGPDrawManager dm (*pDC);
		dm.DrawRect (rectColor, (COLORREF)-1, globalData.clrBtnDkShadow);
	}
	else
	{
		pDC->Draw3dRect (rectColor, globalData.clrBtnHilite, globalData.clrBtnHilite);
		rectColor.DeflateRect (1, 1);
		pDC->Draw3dRect (rectColor, globalData.clrBtnDkShadow, globalData.clrBtnDkShadow);
	}

	rectColor.DeflateRect (1, 1);

	if (color != (COLORREF)-1 && (uiState & ODS_DISABLED) == 0)
	{
		if (globalData.m_nBitsPerPixel == 8) // 256 colors
		{
			ASSERT_VALID (m_pPalette);
			color =  PALETTEINDEX (m_pPalette->GetNearestPaletteIndex (color));
		}

		if (m_bOnGlass)
		{
			CBCGPDrawManager dm (*pDC);
			dm.DrawRect (rectColor, color, (COLORREF)-1);
		}
		else
		{
			CBrush br (color);
			pDC->FillRect (rectColor, &br);
		}
	}

	//----------------------
	// Draw drop-down arrow:
	//----------------------
	CRect rectArrowWinXP = rectArrow;
	rectArrowWinXP.DeflateRect (2, 2);

	if (!m_bWinXPTheme || !CBCGPVisualManager::GetInstance ()->DrawComboDropButtonWinXP (
									pDC, rectArrowWinXP,
									(uiState & ODS_DISABLED), m_bPushed,
									m_bHighlighted))
	{
		pDC->FillRect (rectArrow, &globalData.brBtnFace);

		CBCGPMenuImages::Draw (pDC, CBCGPMenuImages::IdArowDownLarge, rectArrow,
			(uiState & ODS_DISABLED) ? CBCGPMenuImages::ImageGray : CBCGPMenuImages::ImageBlack);

		pDC->Draw3dRect (rectArrow, globalData.clrBtnLight, globalData.clrBtnDkShadow);
		rectArrow.DeflateRect (1, 1);
		pDC->Draw3dRect (rectArrow, globalData.clrBtnHilite, globalData.clrBtnShadow);
	}

	if (pCurPalette != NULL)
	{
		pDC->SelectPalette (pCurPalette, FALSE);
	}
}
/////////////////////////////////////////////////////////////////////////////
// CCTabCtrlBar message handlers
// 
// *** K.Stowell
//##ModelId=4095FA7F0223
void CCTabCtrlBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
{
	CWnd *pWnd;

	if (IsFloating()) 
	{
//		m_ctrlMapX.MoveWindow(5,3,lpwndpos->cx-10,lpwndpos->cx-40);
	/*	m_tabctrl.MoveWindow(3,3+lpwndpos->cx-38, lpwndpos->cx-6, lpwndpos->cy-lpwndpos->cx+33);
		for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos)) 
		{
			pWnd=m_views.GetAt(pos)->pWnd;
			pWnd->MoveWindow(10, 10+lpwndpos->cx-38, lpwndpos->cx-22, lpwndpos->cy-10-(lpwndpos->cx-6)-2);
		}*/

		CRect pRect;
		GetClientRect(&pRect);
	    switch (m_nDockBarID)
		{
	    case AFX_IDW_DOCKBAR_TOP:
			{
				pRect.DeflateRect(3,3+18,3,0);
				break;
			}
		case AFX_IDW_DOCKBAR_BOTTOM:
			{
				pRect.DeflateRect(3,0+18,6,3);
				break;
			}
		case AFX_IDW_DOCKBAR_LEFT:
			{
				pRect.DeflateRect(3,3+18,0,3);
				break;
			}
		case AFX_IDW_DOCKBAR_RIGHT:
			{
				pRect.DeflateRect(0,3+18,3,3);
				break;
			}
		}
//		m_ctrlMapX.MoveWindow(pRect.left+2,pRect.top,pRect.Width()-4,pRect.Width()-34);
		//m_tabctrl.MoveWindow(pRect.left,pRect.top+pRect.Width()-32,pRect.Width(),pRect.Height()-pRect.Width()+33);
		m_tabctrl.MoveWindow(pRect);
		
		pRect.left+=6;
		pRect.right-=6;
		pRect.top+=5;//+pRect.Width()-20;
		pRect.bottom-=28;
		if (pRect.right-pRect.left>400)
		{
		
			pRect.right=pRect.left+400;

		
		}
		for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos)) 
		{
			pWnd=m_views.GetAt(pos)->pWnd;
			pWnd->MoveWindow(pRect);
		}


	}
	else
	{
		CRect pRect;
		GetClientRect(&pRect);
	    switch (m_nDockBarID)
		{
	    case AFX_IDW_DOCKBAR_TOP:
			{
				pRect.DeflateRect(3,3+18,3,0);
				break;
			}
		case AFX_IDW_DOCKBAR_BOTTOM:
			{
				pRect.DeflateRect(3,0+18,6,3);
				break;
			}
		case AFX_IDW_DOCKBAR_LEFT:
			{
				pRect.DeflateRect(3,3+18,0,3);
				break;
			}
		case AFX_IDW_DOCKBAR_RIGHT:
			{
				pRect.DeflateRect(0,3+18,3,3);
				break;
			}
		}
//		m_ctrlMapX.MoveWindow(pRect.left+2,pRect.top,pRect.Width()-4,pRect.Width()-34);
		//m_tabctrl.MoveWindow(pRect.left,pRect.top+pRect.Width()-32,pRect.Width(),pRect.Height()-pRect.Width()+33);
		m_tabctrl.MoveWindow(pRect);
		
		pRect.left+=6;
		pRect.right-=6;
		pRect.top+=20;//+pRect.Width()-20;
		pRect.bottom-=28;
		if (pRect.right-pRect.left>400)
		{
		
			pRect.right=pRect.left+400;

		
		}
		for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos)) 
		{
			pWnd=m_views.GetAt(pos)->pWnd;
			pWnd->MoveWindow(pRect);
		}

	}
	CCControlBar::OnWindowPosChanged(lpwndpos);
}
Exemplo n.º 29
0
void CChartCtrl::RefreshCtrl()
{
	CClientDC dc(this) ;  
	CRect ClientRect;
	GetClientRect(ClientRect);
	m_PlottingRect = ClientRect;		

	CBrush m_BrushBack;
	m_BrushBack.CreateSolidBrush(BackColor) ;

	if (!m_BackgroundDC.GetSafeHdc() )
	{
		CBitmap memBitmap;
		m_BackgroundDC.CreateCompatibleDC(&dc) ;
		memBitmap.CreateCompatibleBitmap(&dc, ClientRect.Width(),ClientRect.Height()) ;
		m_BackgroundDC.SelectObject(&memBitmap) ;
	}
    
	m_BackgroundDC.SetBkColor(BackColor);
	m_BackgroundDC.FillRect(ClientRect,&m_BrushBack);
	m_BackgroundDC.DrawEdge(ClientRect,EdgeType,BF_RECT);
	ClientRect.DeflateRect(3,3);

	CSize TitleSize = m_pTitles->GetSize(&m_BackgroundDC);
	CRect rcTitle;
	rcTitle = ClientRect;
	rcTitle.bottom = TitleSize.cy;

	ClientRect.top += TitleSize.cy;
	m_pTitles->SetRect(rcTitle);
	m_pTitles->Draw(&m_BackgroundDC);

	CSize LegendSize = m_pLegend->GetSize(&m_BackgroundDC);
	if ( (LegendSize.cx >= (ClientRect.right-ClientRect.left) - 6) 
		 || (LegendSize.cy >= (ClientRect.bottom-ClientRect.top)) )
	{}
	else
	{
		ClientRect.right -= LegendSize.cx + 6;
		int XPos = ClientRect.right + 1;
		int YPos = ((ClientRect.bottom-ClientRect.top)/2) - (LegendSize.cy/2);
		m_pLegend->SetPosition(XPos,YPos,&m_BackgroundDC);
		m_pLegend->Draw(&m_BackgroundDC);
	}


/*	size_t AxisCount = m_pAxisList.size();
	for (size_t j=0;j<AxisCount;j++)
		m_pAxisList[j]->PrepareAutoAxis();
	size_t SeriesCount = m_pSeriesList.size();
	for (size_t i=0;i<SeriesCount;i++)
	{
		CChartSerie* m_NewLine = (CChartSerie*)m_pSeriesList[i];
		m_NewLine->RefreshAutoAxes();
	}*/

	//Clip all the margins (axis) of the client rect
	size_t AxisCount = m_pAxisList.size();
	size_t SeriesCount = m_pSeriesList.size();
	for (size_t m=0;m<AxisCount;m++)
	{
		m_pAxisList[m]->CalculateTicksIncrement();
		m_pAxisList[m]->ClipMargin(ClientRect,m_PlottingRect,&m_BackgroundDC);
	}
	for (size_t n=0;n<AxisCount;n++)
	{
		m_pAxisList[n]->SetAxisSize(ClientRect,m_PlottingRect);
		m_pAxisList[n]->Draw(&m_BackgroundDC);
	}

	CPen SolidPen(PS_SOLID,0,m_BorderColor);
	CPen* pOldPen = m_BackgroundDC.SelectObject(&SolidPen);

	m_BackgroundDC.MoveTo(m_PlottingRect.left,m_PlottingRect.top);
	m_BackgroundDC.LineTo(m_PlottingRect.right,m_PlottingRect.top);
	m_BackgroundDC.LineTo(m_PlottingRect.right,m_PlottingRect.bottom);
	m_BackgroundDC.LineTo(m_PlottingRect.left,m_PlottingRect.bottom);
	m_BackgroundDC.LineTo(m_PlottingRect.left,m_PlottingRect.top);

	m_BackgroundDC.SelectObject(pOldPen);
	DeleteObject(SolidPen);

	for (size_t z=0;z<SeriesCount;z++)
	{
		CChartSerie* m_NewLine = (CChartSerie*)m_pSeriesList[z];
		m_NewLine->SetRect(m_PlottingRect);
		m_NewLine->DrawAll(&m_BackgroundDC);
	}

	Invalidate();
}
Exemplo n.º 30
0
void CBodyGridDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	if (!pDC) return;
//	int nSavedDC = dc.SaveDC();
	switch (nIDCtl)
	{

		case IDC_GRIDSTYLE:
		{
			LOGBRUSH lb;
			lb.lbStyle = BS_SOLID;
			lb.lbColor = RGB(100,100,100);
			CPen DotPen(PS_GEOMETRIC | PS_DOT, 1, &lb);
			CPen *pOldPen =  pDC->SelectObject(&DotPen);
			CBrush FillBrush(GetSysColor(COLOR_3DFACE));
			CBrush* pOldBrush = pDC->SelectObject(&FillBrush);
			CRect SRect ;
			GetDlgItem(IDC_GRIDSTYLE)->GetClientRect(&SRect);
			SRect.DeflateRect(2,2,2,2);
			pDC->Rectangle(&SRect);

			lb.lbStyle = BS_SOLID;
			lb.lbColor = m_Color;
			CPen CurvePen(PS_GEOMETRIC | m_Style, GetPenWidth(m_Width,false), &lb);

			pDC->SelectObject(&CurvePen);
			pDC->MoveTo(5,8);
			pDC->LineTo(SRect.right-5,8);
			pDC->SelectObject(pOldPen);
			pDC->SelectObject(pOldBrush);
			break;
		}

		case IDC_MINSTYLE:{
			LOGBRUSH lb;
			lb.lbStyle = BS_SOLID;
			lb.lbColor = RGB(100,100,100);
			CPen DotPen(PS_GEOMETRIC | PS_DOT, 1, &lb);
			CPen *pOldPen =  pDC->SelectObject(&DotPen);
			CBrush FillBrush(GetSysColor(COLOR_3DFACE));
			CBrush* pOldBrush = pDC->SelectObject(&FillBrush);
			CRect SRect ;
			GetDlgItem(IDC_MINSTYLE)->GetClientRect(&SRect);
			SRect.DeflateRect(2,2,2,2);
			pDC->Rectangle(&SRect);

			lb.lbStyle = BS_SOLID;
			lb.lbColor = m_MinColor;
			CPen CurvePen(PS_GEOMETRIC | m_MinStyle, GetPenWidth(m_MinWidth,false), &lb);

			pDC->SelectObject(&CurvePen);
			pDC->MoveTo(5,8);
			pDC->LineTo(SRect.right-5,8);
			pDC->SelectObject(pOldPen);
			pDC->SelectObject(pOldBrush);
			break;
		}


		case IDC_GRIDSTYLE2:{
			LOGBRUSH lb;
			lb.lbStyle = BS_SOLID;
			lb.lbColor = RGB(100,100,100);
			CPen DotPen(PS_GEOMETRIC | PS_DOT, 1, &lb);
			CPen *pOldPen =  pDC->SelectObject(&DotPen);
			CBrush FillBrush(GetSysColor(COLOR_3DFACE));
			CBrush* pOldBrush = pDC->SelectObject(&FillBrush);
			CRect SRect ;
			GetDlgItem(IDC_GRIDSTYLE2)->GetClientRect(&SRect);
			SRect.DeflateRect(2,2,2,2);
			pDC->Rectangle(&SRect);

			lb.lbStyle = BS_SOLID;
			lb.lbColor = m_Color2;
			CPen CurvePen(PS_GEOMETRIC | m_Style2, GetPenWidth(m_Width2,false), &lb);

			pDC->SelectObject(&CurvePen);
			pDC->MoveTo(5,8);
			pDC->LineTo(SRect.right-5,8);
			pDC->SelectObject(pOldPen);
			pDC->SelectObject(pOldBrush);
			break;
		}

		case IDC_MINSTYLE2:{
			LOGBRUSH lb;
			lb.lbStyle = BS_SOLID;
			lb.lbColor = RGB(100,100,100);
			CPen DotPen(PS_GEOMETRIC | PS_DOT, 1, &lb);
			CPen *pOldPen =  pDC->SelectObject(&DotPen);
			CBrush FillBrush(GetSysColor(COLOR_3DFACE));
			CBrush* pOldBrush = pDC->SelectObject(&FillBrush);
			CRect SRect ;
			GetDlgItem(IDC_MINSTYLE2)->GetClientRect(&SRect);
			SRect.DeflateRect(2,2,2,2);
			pDC->Rectangle(&SRect);

			lb.lbStyle = BS_SOLID;
			lb.lbColor = m_MinColor2;
			CPen CurvePen(PS_GEOMETRIC | m_MinStyle2, GetPenWidth(m_MinWidth2,false), &lb);

			pDC->SelectObject(&CurvePen);
			pDC->MoveTo(5,8);
			pDC->LineTo(SRect.right-5,8);
			pDC->SelectObject(pOldPen);
			pDC->SelectObject(pOldBrush);
			break;
		}

	}
}