示例#1
0
void GEllipse::draw(CDC* dc)
{
	CPen pen(this->getPattern(), this->getThick(), this->getLineColor());
	dc->SelectObject(&pen);
	CBrush brush;
	brush.CreateHatchBrush(this->getFillPattern(), this->getFillColor());	
	
	dc->SelectObject(&brush);
	// 처음에 색이 NULL 이면 투명으로
	if (this->getFillColor() == NULL)
		dc->SelectStockObject(NULL_BRUSH);
			
	// 원 그리기는 여기서부터
	dc->MoveTo(getStartX(), getStartY());
	dc->Ellipse(this->getStartX(), this->getStartY(), GetEnd().x, GetEnd().y);
	if (this->getSelected() == TRUE){
		CPen pen2(PS_SOLID, 0, RGB(0, 0, 0));
		dc->SelectObject(&pen2);
		CBrush brush2(RGB(255, 255, 255));
		dc->SelectObject(&brush2);
		m_selectedRect[0] = new CRect(this->getStartX() - 5, this->getStartY() - 5, this->getStartX() + 5, this->getStartY() + 5);
		m_selectedRect[1] = new CRect(this->getEndX() - 5, this->getStartY() - 5, this->getEndX() + 5, this->getStartY() + 5);
		m_selectedRect[2] = new CRect(this->getStartX() - 5, this->getEndY() - 5, this->getStartX() + 5, this->getEndY() + 5);
		m_selectedRect[3] = new CRect(this->getEndX() - 5, this->getEndY() - 5, this->getEndX() + 5, this->getEndY() + 5); // 메모리 누수의 위험 있음. 수정바람!
		dc->Rectangle(m_selectedRect[0]);
		dc->Rectangle(m_selectedRect[1]);
		dc->Rectangle(m_selectedRect[2]);
		dc->Rectangle(m_selectedRect[3]);
	}
}
示例#2
0
void TTransRemain::FillDest(	TImage<unsigned char>		&image,
								TPoint2D<int>				&upCentre, 
								TPoint2D<int>				&downCentre,
								HDC							&memHDC,
								const size_t				radius)
{	
	CBrush	bush;
	bush.CreateHatchBrush(HS_CROSS, RGB(255,255,255));
	
	CRgn upRgn;
	upRgn.CreateEllipticRgn(	upCentre.x()- radius, upCentre.y()-radius, 
								upCentre.x()+ radius, upCentre.y()+radius);	
	FillRgn(memHDC , upRgn, bush);
	CRgn downRgn;
	downRgn.CreateEllipticRgn(	downCentre.x()-radius, downCentre.y()-radius,
								downCentre.x()+radius, downCentre.y()+radius);
	FillRgn(memHDC,downRgn, bush);
	CRgn midRgn;
	POINT	midRect[4];
	midRect[0].x = upCentre.x()-radius;
	midRect[0].y = upCentre.y();
	midRect[1].x = downCentre.x()-radius;
	midRect[1].y = downCentre.y();
	midRect[2].x = downCentre.x()+radius;
	midRect[2].y = downCentre.y();
	midRect[3].x = upCentre.x()+radius;
	midRect[3].y = upCentre.y();	
	
	midRgn.CreatePolygonRgn(midRect, 4, ALTERNATE);
	FillRgn(memHDC, midRgn, bush);	
}
示例#3
0
// CColoredButton message handlers
void CColoredButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
  EnableToolTips( TRUE);
  CDC *pDC = GetDC();
  m_rectButton = lpDrawItemStruct->rcItem;
  m_rectButton.top+=2;
  m_rectButton.bottom-=2;
  m_dx = (m_rectButton.right-m_rectButton.left)/6;
  m_dy = (m_rectButton.top-m_rectButton.bottom)/2;
  
  if( m_bMixedColor && IsWindowEnabled())
  {
    CBrush brush;
    brush.CreateHatchBrush(HS_BDIAGONAL, CLRF_CLR( RGBToColor(100,100,100)));
    pDC->FillRect( &m_rectButton, &brush);
  }
  else
  {
    ColorToComponents();
    UBYTE ubR, ubG, ubB;
    UBYTE ubH, ubS, ubV, ubA;
    ubH = m_ubComponents[0][0];
    ubS = m_ubComponents[0][1];
    ubV = m_ubComponents[0][2];
    ubA = m_ubComponents[0][3];
    ubR = m_ubComponents[1][0];
    ubG = m_ubComponents[1][1];
    ubB = m_ubComponents[1][2];

  #define FILL_RECT( col, x, y, w, h) {\
      RECT rectToFill;\
      rectToFill.left = m_rectButton.left+m_dx*x;\
      if( w<0) rectToFill.right = m_rectButton.right-2;\
      else rectToFill.right = m_rectButton.left+rectToFill.left+m_dx*w;\
      rectToFill.top = m_rectButton.top-m_dy*y;\
      rectToFill.bottom = m_rectButton.top+rectToFill.top-m_dy*h;\
      COLORREF clrfColor = CLRF_CLR( col);\
      if( !IsWindowEnabled()) clrfColor = CLRF_CLR( 0xBBBBBBBB);\
      pDC->FillSolidRect( &rectToFill, clrfColor);\
      pDC->DrawEdge( &rectToFill, EDGE_SUNKEN, BF_RECT);}

    FILL_RECT( HSVToColor( ubH, 255, 255), 0, 0, 1, 1);
    FILL_RECT( HSVToColor( ubH, ubS, 255), 1, 0, 1, 1);
    FILL_RECT( HSVToColor( ubH, 0, ubV), 2, 0, 1, 1);
    FILL_RECT( RGBToColor( ubA, ubA, ubA), 3, 0, 1, 2);
    FILL_RECT( RGBToColor( ubR, 0, 0), 0, 1, 1, 1);
    FILL_RECT( RGBToColor( 0, ubG, 0), 1, 1, 1, 1);
    FILL_RECT( RGBToColor( 0, 0, ubB), 2, 1, 1, 1);
    FILL_RECT( m_colColor, 4, 0, 2, 2);
  }

  pDC->DrawEdge( &lpDrawItemStruct->rcItem, EDGE_BUMP, BF_RECT);
  ReleaseDC( pDC);
}
示例#4
0
int CChartSurfaceSerie::DrawLegend(CDC* pDC, CPoint UpperLeft, int BitmapWidth) const
{
	if (m_strSerieName == _T(""))
		return 0;

	//Draw Text
	int TextHeigh = pDC->GetTextExtent(m_strSerieName.c_str()).cy;
	pDC->ExtTextOut(UpperLeft.x+BitmapWidth+6,UpperLeft.y+1,ETO_CLIPPED,NULL,m_strSerieName.c_str(),NULL);

	// Draw the bitmap
	CBrush NewBrush;
	if (m_FillStyle == fsSolid)
		NewBrush.CreateSolidBrush(m_ObjectColor);
	else
	{
		int nIndex = 0;
		switch (m_FillStyle)
		{
		case fsHatchDownDiag:
			nIndex = HS_FDIAGONAL;
			break;
		case fsHatchUpDiag:
			nIndex = HS_BDIAGONAL;
			break;
		case fsHatchCross:
			nIndex = HS_CROSS;
			break;
		case fsHatchDiagCross:
			nIndex = HS_DIAGCROSS;
			break;
		case fsHatchHorizontal:
			nIndex = HS_HORIZONTAL;
			break;
		case fsHatchVertical:
			nIndex = HS_VERTICAL;
			break;
		}
		NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
	}

	CBrush* pOldBrush = pDC->SelectObject(&NewBrush);

	pDC->Rectangle(UpperLeft.x+2,UpperLeft.y+2,UpperLeft.x+17,UpperLeft.y+17);

	pDC->SelectObject(pOldBrush);
	DeleteObject(NewBrush);

	return 15;
}
示例#5
0
void CChartSurfaceSerie::DrawLegend(CDC* pDC, const CRect& rectBitmap) const
{
	if (m_strSerieName== _T(""))
		return;

	// Draw the bitmap
	CBrush NewBrush;
	if (m_FillStyle == fsSolid)
		NewBrush.CreateSolidBrush(m_ObjectColor);
	else
	{
		int nIndex = 0;
		switch (m_FillStyle)
		{
		case fsHatchDownDiag:
			nIndex = HS_FDIAGONAL;
			break;
		case fsHatchUpDiag:
			nIndex = HS_BDIAGONAL;
			break;
		case fsHatchCross:
			nIndex = HS_CROSS;
			break;
		case fsHatchDiagCross:
			nIndex = HS_DIAGCROSS;
			break;
		case fsHatchHorizontal:
			nIndex = HS_HORIZONTAL;
			break;
		case fsHatchVertical:
			nIndex = HS_VERTICAL;
			break;
		}
		NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
	}

	CBrush* pOldBrush = pDC->SelectObject(&NewBrush);

	pDC->Rectangle(rectBitmap);

	pDC->SelectObject(pOldBrush);
	DeleteObject(NewBrush);
}
示例#6
0
void CEGPaneBar::OnInvertTracker(const CRect& rc)
{
	CFrameWnd* pParentFrame = GetParentFrame ();
	CDC* pDC = pParentFrame->GetDC();
	CRect rect(rc);
    ClientToScreen(rect);
	pParentFrame->ScreenToClient(rect);

	CBrush br;
//	br.CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
//	br.CreateSolidBrush( GetSysColor( COLOR_APPWORKSPACE ) );
	br.CreateHatchBrush( HS_DIAGCROSS, GetSysColor( COLOR_APPWORKSPACE ) );

	HBRUSH hOldBrush = NULL;
	hOldBrush = (HBRUSH)SelectObject(pDC->m_hDC, br.m_hObject);
	pDC->PatBlt( rect.left, rect.top, rect.Width(), rect.Height(), DSTINVERT );
	if (hOldBrush != NULL) SelectObject(pDC->m_hDC, hOldBrush);
	ReleaseDC(pDC);

}
示例#7
0
void CSurfaceView::OnDraw(CDC* pDC) 
{
//	return;
	// TODO: Add your specialized code here and/or call the base class
//	if(!CGeneral::RaftArray.size())	return;
	if(CGeneral::step == 0) return;
	CGeneral::is_draw_finished = false;

	clock_t startd, find;
	double	duration = 0;
	startd = clock();
	//yellow, cremovi
	static 	COLORREF colors[255*255*255];
	for(int r=0; r<255 ; r++)	{
		for(int g=0; g<255 ; g++)	{
			for(int b=0; b<255 ; b++)	{
				colors[r+g+b]= RGB( 255-r, 255-g, 255-b);
			}
		}
	}


	static 	COLORREF col[16] = { RGB( 255, 0, 0 ), RGB( 0, 255, 0 ), //krasnii-0, zelyonii-1
		RGB( 0, 0, 255), RGB( 0, 255, 255 ), //sinii-2, goluboiCian-3
		RGB( 255, 0, 255), RGB( 255, 255, 0 ), //malinovii-4, jyoltii-5
		RGB( 192, 192, 192), RGB( 80, 0, 80 ), //serii-6, t-malinovii-7
		RGB( 255, 255, 255), RGB( 80, 80, 0 ), //serii-8, t-jyoltii-9, 
		RGB( 80, 80, 0 ), RGB( 0, 0, 80 ), //4yornii-10, tyomn. golub - 11 
		RGB( 250, 166, 70 ), RGB( 207, 10, 243 ), //orange-12, tyomn. fioletovii - 13 
		RGB( 128, 128, 0 ), RGB( 0, 0, 0 )}; // seri 15

	GetClientRect(m_ClientRect );
	int oldBkMode = pDC->SetBkMode(TRANSPARENT);
	
	static int key = 1;

	DrawSize = (m_ClientRect.Width( ) < m_ClientRect.Height( ) )
		? m_ClientRect.Width( ) : m_ClientRect.Height( ) ;
	if(DrawSize > GRID_SIZE)  DrawSize = GRID_SIZE;
	else
	{	
		minZoom = (GRID_SIZE-1)/DrawSize + 1 ;
		if(m_PartGrid < minZoom)
		{
			m_PartGrid = minZoom;
		}
	}
	DrawSize = GRID_SIZE/m_PartGrid;
	m_OptionDlg->SetZoom(m_PartGrid, GRID_SIZE/m_PartGrid,num);
	int xp = (m_PartGridNum - 1)%m_PartGrid ;
	int yp = (m_PartGridNum - 1) / m_PartGrid ;
	X = 0 + DrawSize * xp;
	Y = 0 + DrawSize * yp;
	X1 = X + DrawSize; 
	Y1 = Y + DrawSize;


//-----------------------------------------------------------------		
	CDC * myDc;
	CDC memdc;
	CBitmap bmp, *poldbmp;
	isMemDc = IsMemDc && !( CGeneral::DrawRaftIndexes 
		|| CGeneral::DrawRecIndexes
		|| CGeneral::DrawSigMolInd || CGeneral::DrawSigMolNames
		|| CGeneral::DrawRecNames);

	if(isMemDc)
	{
		// Create a compatible memory DC
		memdc.CreateCompatibleDC( pDC);
		bmp.CreateCompatibleBitmap (pDC, m_ClientRect.Height(), m_ClientRect.Height()); 
		//bmp.CreateCompatibleBitmap (pDC, DrawSize, DrawSize); 
		// Select the new bitmap object into the memory device context. 
		poldbmp = memdc.SelectObject( &bmp );

		memdc.BitBlt( 0,0,m_ClientRect.Height(), m_ClientRect.Height(),&memdc, 0, 0, WHITENESS );  
		myDc = &memdc;
	}
	else myDc = pDC;
	myDc->SetMapMode(MM_ISOTROPIC);
	SetWindowExtEx(*myDc,DrawSize,DrawSize,NULL);
	SetViewportExtEx(*myDc,m_ClientRect.right, -m_ClientRect.bottom,NULL);
	SetViewportOrgEx(*myDc,0,m_ClientRect.bottom,NULL);	
//-----------------------------------------------------------------		





	double sd = sqrt(DrawSize /27.) ;

	if( CGeneral::DrawSigMol ){

		double sd_sm = sd-1;
		if(sd_sm < 1) sd_sm = 1; //   ?????????????????

		CBrush br;
		br.CreateSolidBrush(col[1]);

		for(int in=0; in<GRID_SIZE ; in++)
		{
			for(int in1=0; in1<GRID_SIZE ; in1++)
			{
				CBrush br1;
				double IFN_prot_conc = CGeneral::grid.m_Grid[in1][in].array[SM];
				if(IFN_prot_conc == 0){
					continue;
				}
				int normalized_IFN_prot_conc = floor(IFN_prot_conc);
				br1.CreateSolidBrush(colors[normalized_IFN_prot_conc]);
				CBrush* pSMBr = myDc->SelectObject( &br1 );

	//			myDc->Rectangle(in - X, in1 -Y,	in + sd_sm -X, in1 + sd_sm - Y); 
				CRect rect(in - X, in1 -Y, in + sd_sm -X, in1 + sd_sm - Y);
				myDc->FillRect(&rect ,&br1); 

				if(CGeneral::DrawSigMolNames)
				{
					char buf[30] = "IFNprot: ";
					char buf5[10];
					itoa(IFN_prot_conc,buf5,10);
					strncat(buf, buf5, 10);//add coma
					myDc->TextOut(in - X, in1 -Y, buf, strlen(buf));
				}	

			}
		}

	}



	/////////////////// begin drawing rafts //////////////////////////////////
	if( CGeneral::DrawRafts )
	{
		CBrush gray_hatch_br, red_br, grey_br;
		gray_hatch_br.CreateHatchBrush(HS_BDIAGONAL, col[15]);
		grey_br.CreateSolidBrush(col[15]);
		red_br.CreateSolidBrush(col[1]);


		CBrush* pOldBr = myDc->SelectObject( &gray_hatch_br );

		std::vector<CCell>::iterator raft_iter;
		raft_iter = CGeneral::CellArray.begin();
		CCell * p_Raft = raft_iter;
		for(; raft_iter  != CGeneral::CellArray.end(); raft_iter++)
		{
			p_Raft = raft_iter;



			double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
//			double normalized_rigI_rna_conc = rigI_rna_conc/CGeneral::RIGI_rna_maxLevel;
			double IFN_prot_conc = p_Raft->GetIFN_prot_conc();
//			double normalized_IFN_prot_conc = IFN_prot_conc/CGeneral::IFN_prot_maxLevel;

			if( p_Raft->IsActivated() )
			{
				CBrush br;
 				double RIGI_rna_conc = p_Raft->GetRIGI_rna_conc();
				int val=0;
				if(CGeneral::DrawAgs)
					double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
				else
					double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();


				if( !p_Raft->IsInfected() )//not infected
				{
					br.CreateHatchBrush(HS_BDIAGONAL, RGB( 128, 128, 128 ));
					CBrush* pSMBr = myDc->SelectObject( &br );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x  -X, p_Raft->Location.y - Y); 

				} 	           
				else// infected
				{
					if( CGeneral::step != 1)
					{
						CBrush* pSMBr = myDc->SelectObject( &red_br );
						myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
									p_Raft->Location.x  -X, p_Raft->Location.y  - Y); 
					}
					if(p_Raft->m_blinking_counter == p_Raft->m_blinking_const)
					{
						p_Raft->m_blinking_counter = 0;
						p_Raft->m_justChangedStatus = !p_Raft->m_justChangedStatus;
					}
					else{p_Raft->m_blinking_counter++;}

					br.CreateSolidBrush(RGB( 128, 128, 128 ));
					CBrush* pSMBr = myDc->SelectObject( &br );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X, p_Raft->Location.y - Y); 
					if(p_Raft->m_blinking_counter == p_Raft->m_blinking_const)
					{
						p_Raft->m_blinking_counter = 0;
						p_Raft->m_justChangedStatus = !p_Raft->m_justChangedStatus;
					}
					else{p_Raft->m_blinking_counter++;}
				}

			} // if	                 
			else // not activated
			{
				CBrush brt,brt1;
				int val_msg;
				int val_prot;
				if(!CGeneral::DrawAgs) {//DDX58
//					if(CGeneral::DrawAgIndexes)//msg
						val_msg = p_Raft->GetRIGI_rna_conc();
//					else //prot
						val_prot = p_Raft->GetRIGI_prot_conc();
				}
				else {//IFNB1
//					if(CGeneral::DrawAgIndexes)//IFNB1
						val_msg = p_Raft->GetIFN_rna_conc();
//					else   //prot
						val_prot = p_Raft->GetIFN_prot_conc();
				}

				if( p_Raft->IsInfected() )//NOT UNFECTED		
				{
					brt.CreateSolidBrush(colors[val_prot]);
					CBrush* pSMBr = myDc->SelectObject( &brt );
					myDc->Ellipse(p_Raft->Location.x - X-1, p_Raft->Location.y -Y-1,
								p_Raft->Location.x -X+sd+1, p_Raft->Location.y  - Y+sd+1); 

					brt1.CreateSolidBrush(colors[val_msg]);
					pSMBr = myDc->SelectObject( &brt1 );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X+sd, p_Raft->Location.y  - Y+sd); 

/*					myDc->SetTextColor(col[0]); 
					char buf[30] = "*";
					myDc->TextOut(p_Raft->Location.x - X+1, p_Raft->Location.y -Y+1, 
						buf, strlen(buf));
						*/

				} // if	  
				else//not infected
				{	
//					brt.CreateSolidBrush(colors[col[2]]);
					brt.CreateHatchBrush(HS_BDIAGONAL, colors[val_prot]);
					CBrush* pSMBr = myDc->SelectObject( &brt );
					myDc->Ellipse(p_Raft->Location.x - X-1, p_Raft->Location.y -Y-1,
								p_Raft->Location.x -X+sd+1, p_Raft->Location.y  - Y+sd+1); 

					brt1.CreateHatchBrush(HS_FDIAGONAL, colors[val_prot]);
					pSMBr = myDc->SelectObject( &brt1 );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X+sd, p_Raft->Location.y  - Y+sd); 
				}
				
			}
			myDc->SetTextColor(col[0]); 
			int boundTypeIR = p_Raft->Get_boundTypeIR();
			if(boundTypeIR)	{
				char buf1[3] = "|";
				char buf2[3] = "--";
				char buf3[3]="";
				char buf[30] = "";
				char buf5[10];
				if((boundTypeIR%2)){
					strncat(buf3, buf1, 3);//add coma					
				}else{
					strncat(buf3, buf2, 3);//add coma					
				}
				myDc->TextOut(p_Raft->Location.x - X+1, p_Raft->Location.y -Y+1, 
					buf3, strlen(buf3));
			}
			myDc->SetTextColor(RGB(0,0,0)); 

			if( !p_Raft->IsInfected() ) {//not infected
			

			} 	           
			else {// infected
			
			}

			/*

			double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
			double normalized_rigI_rna_conc = rigI_rna_conc/CGeneral::RIGI_rna_maxLevel;
			double IFN_rna_conc = p_Raft->GetIFN_rna_conc();
			double normalized_IFN_rna_conc = IFN_rna_conc/CGeneral::IFN_rna_maxLevel;

			int sd_rna = sd+3;
			int val;
			if(CGeneral::DrawAgs)
				val = 255 - normalized_rigI_rna_conc * 255;
			else
				val = 255 - normalized_IFN_rna_conc * 255;
			CBrush br_rna;
			br_rna.CreateSolidBrush(RGB( val, val, val ));
			CBrush* pSMBr = myDc->SelectObject( &br_rna );
//			myDc->Ellipse(p_Raft->m_shape.Centroid().x - X, p_Raft->m_shape.Centroid().y -Y,
//				p_Raft->m_shape.Centroid().x + sd_rna -X, p_Raft->m_shape.Centroid().y + sd_rna - Y); 

*/



			if(CGeneral::DrawRaftIndexes)
			{
				char buf[30]="";
				char buf5[10]="";
				if(!CGeneral::DrawAgs){
//					if(CGeneral::DrawAgIndexes)	{
						strncat(buf, "DDX58: ", 10);//add coma
						itoa(p_Raft->GetRIGI_rna_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
//					else{
						strncat(buf, ", RIGI: ", 10);//add coma
						itoa(p_Raft->GetRIGI_prot_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
				}
				else{
//					if(CGeneral::DrawAgIndexes)	{
						strncat(buf, "IFNB:", 10);//add coma
//						buf = "IFNB: ";
						itoa(p_Raft->GetIFN_rna_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
//					else{
/*						strncat(buf, ", IFNb:", 10);//add coma
						itoa(p_Raft->GetIFN_prot_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));*/
//					}

				}
			}

		}
		myDc->SelectObject( pOldBr);
		num++;
		myDc->SetBkMode(oldBkMode);
	}
//------------------------ end drawing rafts ---------------------------//

	
	if(isMemDc)
	{
		pDC->StretchBlt( 0,0,m_ClientRect.Height( ) ,m_ClientRect.Height( ),&memdc, 0, 0,
			DrawSize, DrawSize, SRCCOPY); 
		//pDC->BitBlt( 0,0,DrawSize, DrawSize,&memdc, 0, 0, SRCCOPY ); 
		bmp.DeleteObject();
		memdc.DeleteDC();
	}
	pDC->SetBkMode(oldBkMode);

	CGeneral::is_draw_finished = true;
	if(stepGl == 10 || stepGl == 1000 || stepGl == 10000
		|| stepGl == 100000 || stepGl == 300000 || stepGl == 2000000)
	{
		find = clock();
		duration = (double)(find - startd) / CLOCKS_PER_SEC;	
//		CGeneral::out << "\n Draw duration " << duration << " step " << stepGl << endl;
	}
}
示例#8
0
void CChartSurfaceSerie::DrawAll(CDC* pDC)
{
	size_t count = m_vPoints.size();
	CPoint* pPoints = new CPoint[count+2];

	CBrush NewBrush;
	if (m_FillStyle == fsSolid)
		NewBrush.CreateSolidBrush(m_ObjectColor);
	else
	{
		int nIndex = 0;
		switch (m_FillStyle)
		{
		case fsHatchDownDiag:
			nIndex = HS_FDIAGONAL;
			break;
		case fsHatchUpDiag:
			nIndex = HS_BDIAGONAL;
			break;
		case fsHatchCross:
			nIndex = HS_CROSS;
			break;
		case fsHatchDiagCross:
			nIndex = HS_DIAGCROSS;
			break;
		case fsHatchHorizontal:
			nIndex = HS_HORIZONTAL;
			break;
		case fsHatchVertical:
			nIndex = HS_VERTICAL;
			break;
		}
		NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
	}

	CBrush* pOldBrush = pDC->SelectObject(&NewBrush);

	for (size_t i=0; i<count; i++)
	{
		ValueToScreen(m_vPoints[i].X,m_vPoints[i].Y,pPoints[i+1]);
	}

	if (m_bHorizontal)
	{
		pPoints[0].x = pPoints[1].x;
		pPoints[count+1].x = pPoints[count].x;

		float Position = m_pHorizontalAxis->GetPosition()/100.00;
		int AxisPos = m_ObjectRect.top + (int)(Position * (m_ObjectRect.bottom-m_ObjectRect.top));

		pPoints[0].y = AxisPos;
		pPoints[count+1].y = AxisPos;
	}
	else
	{
		pPoints[0].y = pPoints[1].y;
		pPoints[count+1].y = pPoints[count].y;

		float Position = m_pVerticalAxis->GetPosition()/100.00;
		int AxisPos = m_ObjectRect.left + (int)(Position * (m_ObjectRect.right-m_ObjectRect.left));

		pPoints[0].x = AxisPos;
		pPoints[count+1].x = AxisPos;
	}

	pDC->SetBkMode(TRANSPARENT);
	//To have lines limited in the drawing rectangle :
	pDC->IntersectClipRect(m_ObjectRect);

	pDC->Polygon(pPoints,count+2);
	pDC->SelectClipRgn(NULL);
	pDC->SelectObject(pOldBrush);
	DeleteObject(NewBrush);

	delete[] pPoints;
}
示例#9
0
void CChartSurfaceSerie::DrawAll(CDC* pDC)
{
	int iFirst=0, iLast=0;
	GetVisiblePoints(iFirst,iLast);

	if (iFirst>0)
		iFirst--;
	if (iLast<(int)GetPointsCount())
		iLast++;
	int iCount = iLast - iFirst;
	CPoint* pPoints = new CPoint[iCount+2];

	CBrush NewBrush;
	if (m_FillStyle == fsSolid)
		NewBrush.CreateSolidBrush(m_ObjectColor);
	else
	{
		int nIndex = 0;
		switch (m_FillStyle)
		{
		case fsHatchDownDiag:
			nIndex = HS_FDIAGONAL;
			break;
		case fsHatchUpDiag:
			nIndex = HS_BDIAGONAL;
			break;
		case fsHatchCross:
			nIndex = HS_CROSS;
			break;
		case fsHatchDiagCross:
			nIndex = HS_DIAGCROSS;
			break;
		case fsHatchHorizontal:
			nIndex = HS_HORIZONTAL;
			break;
		case fsHatchVertical:
			nIndex = HS_VERTICAL;
			break;
		}
		NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
	}

	CBrush* pOldBrush = pDC->SelectObject(&NewBrush);

	for (int i=iFirst; i<iLast; i++)
	{
		ValueToScreen(m_vPoints[i].X,m_vPoints[i].Y,pPoints[i-iFirst+1]);
	}

	if (m_bHorizontal)
	{
		pPoints[0].x = pPoints[1].x;
		pPoints[iCount+1].x = pPoints[iCount].x;

		double Position = m_pHorizontalAxis->GetPosition()/100.00;
		int AxisPos = m_ObjectRect.top + (int)(Position * (m_ObjectRect.bottom-m_ObjectRect.top));

		pPoints[0].y = AxisPos;
		pPoints[iCount+1].y = AxisPos;
	}
	else
	{
		pPoints[0].y = pPoints[1].y;
		pPoints[iCount+1].y = pPoints[iCount].y;

		double Position = m_pVerticalAxis->GetPosition()/100.00;
		int AxisPos = m_ObjectRect.left + (int)(Position * (m_ObjectRect.right-m_ObjectRect.left));

		pPoints[0].x = AxisPos;
		pPoints[iCount+1].x = AxisPos;
	}

	pDC->SetBkMode(TRANSPARENT);
	//To have lines limited in the drawing rectangle :
	CRect TempClipRect(m_ObjectRect);
	TempClipRect.DeflateRect(1,1);
	pDC->SetBkMode(TRANSPARENT);
	pDC->IntersectClipRect(TempClipRect);

	pDC->Polygon(pPoints,iCount+2);
	pDC->SelectClipRgn(NULL);
	pDC->SelectObject(pOldBrush);
	DeleteObject(NewBrush);

	delete[] pPoints;
}
示例#10
0
void CGraphView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	// Do not call CView::OnPaint() for painting messages

    static DWORD dwColor[9]={RGB(0,0,0),         //black
                             RGB(255,0,0),       //red
                             RGB(0,255,0),       //green
                             RGB(0,0,255),       //blue
                             RGB(255,255,0),     //yellow
                             RGB(255,0,255),     //magenta
                             RGB(0,255,255),     //cyan
                             RGB(127,127,127),   //gray
                             RGB(255,255,255)};  //white

    POINT polylpts[4],polygpts[5];
    int xcoord;

    CBrush newbrush;
    CBrush* oldbrush;
    CPen newpen;
    CPen* oldpen;  
  
    // draws and fills a circle
    newpen.CreatePen(PS_SOLID,2,dwColor[3]);
    oldpen=dc.SelectObject(&newpen);
    newbrush.CreateSolidBrush(dwColor[3]);
    oldbrush=dc.SelectObject(&newbrush);
    dc.Ellipse(400,20,650,270);
    dc.TextOut(500,150,"circle",6);    
    dc.SelectObject(oldbrush);
    newbrush.DeleteObject( );
    dc.SelectObject(oldpen);
    newpen.DeleteObject( );

    // draws and fills an ellipse
    newpen.CreatePen(PS_SOLID,2,dwColor[1]);
    oldpen=dc.SelectObject(&newpen);
    newbrush.CreateSolidBrush(dwColor[1]);
    oldbrush=dc.SelectObject(&newbrush);
    dc.Ellipse(325,300,425,250);
    dc.TextOut(260,265,"ellipse",7); 
    dc.SelectObject(oldbrush);
    newbrush.DeleteObject( );
    dc.SelectObject(oldpen);
    newpen.DeleteObject( );

    // draws several pixels
    for(xcoord=500;xcoord<600;xcoord+=5)
      dc.SetPixel(xcoord,400,0L);
    dc.TextOut(540,410,"pixels",6);

    // draws a wide diagonal line
    newpen.CreatePen(PS_SOLID,10,dwColor[0]);
    oldpen=dc.SelectObject(&newpen);
    dc.MoveTo(20,20);
    dc.LineTo(100,100);
    dc.TextOut(60,20,"<- diagonal line",16);  
    dc.SelectObject(oldpen);
    newpen.DeleteObject( );

    // draws an arc
    newpen.CreatePen(PS_DASH,1,dwColor[3]);
    oldpen=dc.SelectObject(&newpen);
    dc.Arc(25,125,175,225,175,225,100,125);
    dc.TextOut(50,150,"small arc ->",12);   
    dc.SelectObject(oldpen);
    newpen.DeleteObject( );

    // draws a wide chord
    newpen.CreatePen(PS_SOLID,10,dwColor[2]);
    oldpen=dc.SelectObject(&newpen);
    dc.Chord(125,125,275,225,275,225,200,125);
    dc.TextOut(280,150,"<- chord",8);
    dc.SelectObject(oldpen);
    newpen.DeleteObject( );

    // draws a pie slice and fills
    newpen.CreatePen(PS_SOLID,2,dwColor[0]);
    oldpen=dc.SelectObject(&newpen);
    newbrush.CreateSolidBrush(dwColor[2]);
    oldbrush=dc.SelectObject(&newbrush);
    dc.Pie(200,0,300,100,200,50,250,100);
    dc.TextOut(260,80,"<- pie wedge",12);
    dc.SelectObject(oldbrush);
    newbrush.DeleteObject( );
    dc.SelectObject(oldpen);
    newpen.DeleteObject( );

    // draws a rectangle and fills
    newbrush.CreateSolidBrush(dwColor[7]);
    oldbrush=dc.SelectObject(&newbrush);
    dc.Rectangle(25,350,150,425);
    dc.TextOut(50,440,"rectangle",9);
    dc.SelectObject(oldbrush);
    newbrush.DeleteObject( );
  
    // draws a rounded rectangle and fills
    newbrush.CreateHatchBrush(HS_CROSS,dwColor[3]);
    oldbrush=dc.SelectObject(&newbrush);
    dc.RoundRect(400,320,550,360,20,20);
    dc.TextOut(410,300,"rounded rectangle",17);
    dc.SelectObject(oldbrush);
    newbrush.DeleteObject( );

   // draws a wide polygon and fills
    newpen.CreatePen(PS_SOLID,5,dwColor[6]);
    oldpen=dc.SelectObject(&newpen);
    newbrush.CreateHatchBrush(HS_FDIAGONAL,dwColor[4]);
    oldbrush=dc.SelectObject(&newbrush);
    polygpts[0].x=40;
    polygpts[0].y=200;
    polygpts[1].x=100;
    polygpts[1].y=270;
    polygpts[2].x=80;
    polygpts[2].y=290;
    polygpts[3].x=20;
    polygpts[3].y=220;
    polygpts[4].x=40;
    polygpts[4].y=200;
    dc.Polygon(polygpts,5);
    dc.TextOut(80,230,"<- polygon",10);
    dc.SelectObject(oldbrush);
    newbrush.DeleteObject( );
    dc.SelectObject(oldpen);
    newpen.DeleteObject( );

    // draws several wide lines with polyline
    newpen.CreatePen(PS_SOLID,4,dwColor[5]);
    oldpen=dc.SelectObject(&newpen);
    polylpts[0].x=210;
    polylpts[0].y=330;
    polylpts[1].x=210;
    polylpts[1].y=400;
    polylpts[2].x=250;
    polylpts[2].y=400;
    polylpts[3].x=210;
    polylpts[3].y=330;
    dc.Polyline(polylpts,4);
    dc.TextOut(250,350,"polyline",8);  
    dc.SelectObject(oldpen);
    newpen.DeleteObject( );
	
}
示例#11
0
文件: mltwin.cpp 项目: ryoon/eCos
void ecMemoryLayoutWindow::DrawRegion (wxDC& dc, int uRegion, int uUnitCount, int uPixelsPerUnit, std::list <mem_region>::iterator region)
{
#if 0
    BOOL bDrawFocusRect = FALSE;
    CRect rectAddress;
    CString strAddress;
    
    // setup the drawing objects
    
    CBrush brshUnusedSection;
    if (!brshUnusedSection.CreateHatchBrush (HS_BDIAGONAL, RGB (128, 128, 128)))
        return;
    
    CBrush brshUsedSection;
    if (!brshUsedSection.CreateSolidBrush (GetSysColor (COLOR_WINDOW)))
        return;
    
    CBrush brshInitialSectionBar;
    if (!brshInitialSectionBar.CreateSolidBrush (GetSysColor (COLOR_INACTIVECAPTION)))
        return;
    
    CBrush brshFixedSectionBar;
    if (!brshFixedSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
        return;
    
    CBrush brshFinalSectionBar;
    if (!brshFinalSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
        return;
    
    CPen penBorder;
    if (!penBorder.CreatePen (PS_SOLID, 1, GetSysColor (COLOR_WINDOWTEXT)))
        return;
    
    CPen penSelected;
    if (!penSelected.CreatePen (PS_SOLID, 2, GetSysColor (COLOR_WINDOWTEXT)))
        return;
    
    // select the border pen object
    
    CPen * pOldPen = pDC->SelectObject (&penBorder);
    
    // calculate the region rectangle
    
    REGIONRECT srRegion;
    srRegion.Rect.SetRect (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + uUnitCount * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + 1);
    srRegion.Region = region;
    listRegionRect.AddTail (srRegion);
    
    // draw the region
    
    CPoint pointOrigin (srRegion.Rect.left, srRegion.Rect.top);
    pDC->LPtoDP (&pointOrigin);
    pointOrigin.x %= 8;
    pointOrigin.y %= 8;
    pDC->SetBrushOrg (pointOrigin);
    CBrush * pOldBrush = pDC->SelectObject (&brshUnusedSection);
    pDC->Rectangle (srRegion.Rect);
    /*
    pDC->MoveTo (srRegion.Rect.left, srRegion.Rect.bottom - 1); // draw tick
    pDC->LineTo (srRegion.Rect.left, srRegion.Rect.bottom + TICK_HEIGHT); // draw tick
    */
    if (region == m_riSelectedRegion)
    {
        bDrawFocusRect = TRUE;
        m_rectSelectedItem = srRegion.Rect;
    }
    
    // draw the region label
    
    CRect rectRegionLabel (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion - EXTERNAL_TEXT_BORDER - 20, m_uViewWidth - HORIZ_BORDER /*HORIZ_BORDER + uUnitCount * uPixelsPerUnit + 1*/, VERT_BORDER + REGION_SPACING * uRegion - EXTERNAL_TEXT_BORDER);
    CString strRegionLabel;
    strRegionLabel.Format (_T("%s (%08X-%08X)%s"), CString(region->name.c_str ()), region->address, region->address + region->size - 1, ((region->type == read_only) ? _T(" read only") : _T("")));
    pDC->DrawText (strRegionLabel, -1, rectRegionLabel, DT_BOTTOM | DT_SINGLELINE);
    
    // draw the start address of the region
    /*
    rectAddress.SetRect (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + ADDRESS_TEXT_SPACE * UNITS_PER_SECTION * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
    strAddress.Format (ADDRESS_FORMAT, region->address);
    pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
    */
    // draw the end address of the region
    /*
    rectAddress.SetRect (HORIZ_BORDER + (uUnitCount - ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + (uUnitCount + ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
    strAddress.Format (ADDRESS_FORMAT, region->address + region->size);
    pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
    */
    // draw the sections within the region
    
    UINT uSectionUnitCount = 0;
    CRect rectBar;
    SECTIONRECT srSection;
    for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
    {
        if (section_view->section != NULL) // the section is used
        {
            // draw the section
            
            pDC->SelectObject (brshUsedSection);
            srSection.Rect.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION) * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + 1);
            srSection.SectionView = section_view;
            listSectionRect.AddTail (srSection);
            pDC->Rectangle (srSection.Rect);
            if (section_view == m_sviSelectedSectionView)
            {
                bDrawFocusRect = TRUE;
                m_rectSelectedItem = srSection.Rect;
            }
            
            // draw text within the section
            
            CString strSection, strSectionLine;
            
            if ((section_view->section_location != initial_location) && (section_view->section->alignment > 1))
            {
                strSectionLine.Format (_T("align %lX\n"), section_view->section->alignment);
                strSection += strSectionLine;
            }
            
            if (section_view->section->size > 0)
            {
                strSectionLine.Format (_T("size %lX\n"), section_view->section->size);
                strSection += strSectionLine;
            }
            
            if (section_view->section_location == final_location)
            {
                strSectionLine.Format (_T("relocated\n"));
                strSection += strSectionLine;
            }
            
            pDC->DrawText (strSection, -1, srSection.Rect - (LPCRECT) CRect (EXTERNAL_TEXT_BORDER, EXTERNAL_TEXT_BORDER + BAR_HEIGHT, EXTERNAL_TEXT_BORDER, EXTERNAL_TEXT_BORDER), DT_LEFT);
            
            // select caption bar colour according to type of section
            
            if (section_view->section_location == initial_location)
            {
                pDC->SetTextColor (GetSysColor (COLOR_INACTIVECAPTIONTEXT));
                pDC->SelectObject (&brshInitialSectionBar);
            }
            else
            {
                pDC->SetTextColor (GetSysColor (COLOR_CAPTIONTEXT));
                pDC->SelectObject (&brshFinalSectionBar);
            }
            
            // draw the caption bar
            
            rectBar.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION) * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + BAR_HEIGHT + 1);
            pDC->Rectangle (rectBar);
            
            // draw the section name within the caption bar
            
            CString strName(section_view->section->name.c_str ());
            CRect *pRect=NULL;
            m_arstrTooltipRects.Lookup(strName,(void *&)pRect);
            UINT format;
            if(pDC->GetTextExtent(strName).cx>rectBar.Width()-2*EXTERNAL_TEXT_BORDER){
                format=DT_LEFT;
                if(pRect){
                    pRect->CopyRect(rectBar);
                } else {
                    pRect=new CRect;
                    m_arstrTooltipRects.SetAt(strName,pRect);
                }
                // Replace final three characters of name with an elipsis
                int nLength=1+max(1,strName.GetLength()-3);
                do {
                    --nLength;
                    strName=strName.Left(nLength)+_T("...");
                } while(nLength>1 && pDC->GetTextExtent(strName).cx>rectBar.Width()-2*EXTERNAL_TEXT_BORDER);
                
                rectBar.left+=EXTERNAL_TEXT_BORDER;
                rectBar.right-=EXTERNAL_TEXT_BORDER;
            } else {
                format=DT_CENTER;
                if (pRect) {
                    m_arstrTooltipRects.RemoveKey(strName);
                }
            }
            
            pDC->DrawText (strName, -1, rectBar, format | DT_VCENTER | DT_SINGLELINE);
            pDC->SetTextColor (GetSysColor (COLOR_WINDOWTEXT));
            
            // find the mem_section item describing the current section_view item
            
            list <mem_section>::iterator MemorySection = section_view->section;
            
            // draw the section address if appropriate
            
            if ((section_view->section_location == initial_location))
            {
                if (MemorySection->initial_location->anchor == absolute)
                {
                    pDC->MoveTo (srSection.Rect.left, srSection.Rect.bottom - 1); // draw tick
                    pDC->LineTo (srSection.Rect.left, srSection.Rect.bottom + TICK_HEIGHT); // draw tick
                    rectAddress.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, (int) (HORIZ_BORDER + (uSectionUnitCount + ADDRESS_TEXT_SPACE * UNITS_PER_SECTION) * uPixelsPerUnit), VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
                    strAddress.Format (ADDRESS_FORMAT, MemorySection->initial_location->address);
                    pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
                    
                    /*
                    if (MemorySection->size > 0) // the end address can be calculated
                    {
                    rectAddress.SetRect (HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION - ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION + ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
                    strAddress.Format (ADDRESS_FORMAT, MemorySection->initial_location->address + MemorySection->size);
                    pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
                    }
                    */
                }
            }
            
            else if ((section_view->section_location == final_location) || (section_view->section_location == fixed_location))
            {
                if (MemorySection->final_location->anchor == absolute)
                {
                    pDC->MoveTo (srSection.Rect.left, srSection.Rect.bottom - 1); // draw tick
                    pDC->LineTo (srSection.Rect.left, srSection.Rect.bottom + TICK_HEIGHT); // draw tick
                    rectAddress.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, (int) (HORIZ_BORDER + (uSectionUnitCount + ADDRESS_TEXT_SPACE * UNITS_PER_SECTION) * uPixelsPerUnit), VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
                    strAddress.Format (ADDRESS_FORMAT, MemorySection->final_location->address);
                    pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
                    
                    /*
                    if (MemorySection->size > 0) // the end address can be calculated
                    {
                    rectAddress.SetRect (HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION - ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION + ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
                    strAddress.Format (ADDRESS_FORMAT, MemorySection->final_location->address + MemorySection->size);
                    pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
                    }
                    */
                }
            }
            
            uSectionUnitCount += UNITS_PER_SECTION;
    }
    else
    {
        uSectionUnitCount++; // unused sections occupy a single unit
    }
  }
  
  // draw the focus rectangle around the selected object (if any)
  
  if (bDrawFocusRect)
      pDC->DrawFocusRect (m_rectSelectedItem + CRect (1, 1, 1, 1));
  
  // restore previous drawing objects
  
  pDC->SelectObject (pOldBrush);
  pDC->SelectObject (pOldPen);
#endif
}
示例#12
0
void CImconView::OnDraw(CDC* pDC)
{
	CImconDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: add draw code for native data here
  if (pDC->IsPrinting())
    {  // Print image
     pDC->SetMapMode(MM_TWIPS);
     pDoc->m_Dib.Stretch(pDC->m_hDC, pDoc->m_hPal,
                         pDoc->m_uLeftMargin, - (int) pDoc->m_uTopMargin,
                         pDoc->m_uHorzPrintSize, - (int) pDoc->m_uVertPrintSize);
    }
   else
    {  // Draw image on screen
     // Draw background
     RECT Rect;
     CBrush Brush;
     Brush.CreateHatchBrush(HS_BDIAGONAL, RGB(192, 192, 192));
     GetClientRect(&Rect);
     Rect.right  = max(Rect.right,  (int) pDoc->m_uWidth);
     Rect.bottom = max(Rect.bottom, (int) pDoc->m_uHeight);
     CPoint ptScrollPos = GetScrollPosition();
     pDC->SetBrushOrg(-ptScrollPos.x, -ptScrollPos.y);
     CRgn rgnImage;
     CRgn rgnWindow;
     rgnImage.CreateRectRgn(0, 0, pDoc->m_uWidth, pDoc->m_uHeight);
     rgnWindow.CreateRectRgnIndirect(&Rect);
     rgnWindow.CombineRgn(&rgnWindow, &rgnImage, RGN_DIFF);
     pDC->FillRgn(&rgnWindow, &Brush);
//     pDC->FillRect(&Rect, &Brush);

     // Draw image
     HPALETTE hPal;
     CPalette *pOldPal = NULL;
     if (m_bActive)
       hPal = pDoc->m_hPal;
      else
       {
        hPal = NULL;
        CPalette *pPal = CPalette::FromHandle(pDoc->m_hPal);
        pOldPal = pDC->SelectPalette(pPal, TRUE);
        pDC->RealizePalette();
       }

     RECT rcClientArea;
     GetClientRect(&rcClientArea);
     if (m_bScaleToWindow)
       if (m_bUseDib)
         pDoc->m_Dib.Stretch(pDC->m_hDC, hPal, 0, 0,
                             rcClientArea.right - rcClientArea.left,
                             rcClientArea.bottom - rcClientArea.top);
        else
         pDoc->m_Ddb.Stretch(pDC->m_hDC, hPal, 0, 0,
                             rcClientArea.right - rcClientArea.left,
                             rcClientArea.bottom - rcClientArea.top);
      else
       if (m_bUseDib)
         pDoc->m_Dib.Draw(pDC->m_hDC, hPal, 0, 0);
        else
         pDoc->m_Ddb.Draw(pDC->m_hDC, hPal, 0, 0);

     if (pOldPal)
       pDC->SelectPalette(pOldPal, FALSE);

     // Draw selection
     if (m_bSelection)
       {
        LPRECT lpRect = &m_rectSelection;
        pDC->PatBlt(lpRect->left, lpRect->top,
                    lpRect->right - lpRect->left, 1,
                    DSTINVERT);
        pDC->PatBlt(lpRect->left, lpRect->bottom,
                    1, -(lpRect->bottom - lpRect->top),
                    DSTINVERT);
        pDC->PatBlt(lpRect->right - 1, lpRect->top,
                    1, lpRect->bottom - lpRect->top,
                    DSTINVERT);
        pDC->PatBlt(lpRect->right, lpRect->bottom - 1,
                    -(lpRect->right - lpRect->left), 1,
                    DSTINVERT);
       }
    }
}