// Display the line on the screen!
void CDrawLine::Paint(CContext &dc,paint_options options)
{
	if (m_use_default_style)
	{
		switch (xtype)
		{
		case xWire:
			dc.SelectPen( PS_SOLID,1, m_pDesign->GetOptions()->GetUserColor().Get( CUserColor::WIRE ), options );
			break;
		case xBus:
			dc.SelectPen( PS_SOLID,5, m_pDesign->GetOptions()->GetUserColor().Get( CUserColor::BUS ), options );
			break;
		default:
			dc.SelectPen(m_pDesign->GetOptions()->GetStyle(m_style), options);
			break;
		}
	}
	else
	{
		dc.SelectPen(m_pDesign->GetOptions()->GetStyle(m_style), options);
	}

  dc.SetROP2(R2_COPYPEN);

  dc.MoveTo(m_point_a);

  if (!m_segment) {
	  switch (g_EditToolBar.m_DrawLineEdit.mode) {
		case 1: dc.LineTo(CDPoint(m_point_b.x,m_point_a.y));
			break;
		case 2:	dc.LineTo(CDPoint(m_point_a.x,m_point_b.y));
			break;
	  }
  }
  dc.LineTo(m_point_b);

  if (is_stuck)
  {
	  // Draw a nice circle to show the stickness...
	  dc.PaintConnectPoint( m_point_b );

	  // Do we need a junction
	  if (is_junction)
	  {
	    int js=JUNCTION_SIZE;
		CDPoint br,tl;
		br=CDPoint(m_point_b.x+js+1,m_point_b.y+js+1);
		tl=CDPoint(m_point_b.x-js,m_point_b.y-js);

		dc.SetROP2(R2_COPYPEN);

		dc.SelectPen(PS_SOLID,1,m_pDesign->GetOptions()->GetUserColor().Get( CUserColor::JUNCTION) );
		dc.SelectBrush(m_pDesign->GetOptions()->GetUserColor().Get( CUserColor::JUNCTION));
  	    dc.Ellipse(CDRect(tl.x,tl.y,br.x,br.y));
	  }
  }

}
Beispiel #2
0
void CDrawBlockRotate::Paint(CContext &dc, paint_options options)
{
	// Draw marquee
	dc.SelectBrush();
	if (m_point_a.x < m_point_b.x)
	{
		dc.SelectPen(PS_MARQUEE, 1, cBLOCK);
	}
	else
	{
		// Other marquee pen for right to left selection
		dc.SelectPen(PS_MARQUEE2, 1, cBLOCK);
	}

	dc.SetROP2(R2_COPYPEN);
	dc.Rectangle(theArea);
}
void CDrawLine::PaintHandles( CContext &dc )
{
	dc.SelectBrush(cBLACK);
	dc.SelectPen(PS_SOLID,0,cBLACK);

	CDRect r1(m_point_a.x-2,m_point_a.y-2,m_point_a.x+2,m_point_a.y+2);
	CDRect r2(m_point_b.x-2,m_point_b.y-2,m_point_b.x+2,m_point_b.y+2);
	dc.Rectangle(r1);
	dc.Rectangle(r2);
}
Beispiel #4
0
// Display the power item on the screen!
void CDrawPower::Paint(CContext &dc, paint_options options)
{
	int spacing;
	CDPoint pa, pb, pc, pd, pos = m_point_a;

	CalcLayout();

	dc.SelectFont(*m_pDesign->GetOptions()->GetFont(fPIN), 2);
	dc.SetROP2(R2_COPYPEN);
	dc.SetTextColor(m_pDesign->GetOptions()->GetUserColor().Get(CUserColor::POWER));

	if (which != 0) spacing = POWER_SIZE * 2 + POWER_SIZE / 4;
	else spacing = POWER_SIZE + POWER_SIZE / 4;

	// Find out which way round the power object goes
	switch (dir)
	{
		case 0: // Top
			pa = CDPoint(pos.x, pos.y - POWER_SIZE);
			pb = CDPoint(pos.x - POWER_SIZE / 2, pos.y - POWER_SIZE);
			pc = CDPoint(pos.x + POWER_SIZE / 2 + 1, pos.y - POWER_SIZE);
			pd = CDPoint(pos.x, pos.y - POWER_SIZE * 2);
			break;
		case 1: // Bottom
			pa = CDPoint(pos.x, pos.y + POWER_SIZE);
			pb = CDPoint(pos.x - POWER_SIZE / 2, pos.y + POWER_SIZE);
			pc = CDPoint(pos.x + POWER_SIZE / 2 + 1, pos.y + POWER_SIZE);
			pd = CDPoint(pos.x, pos.y + POWER_SIZE * 2);
			break;
		case 2: // Left
			pa = CDPoint(pos.x - POWER_SIZE, pos.y);
			pb = CDPoint(pos.x - POWER_SIZE, pos.y - POWER_SIZE / 2);
			pc = CDPoint(pos.x - POWER_SIZE, pos.y + POWER_SIZE / 2 + 1);
			pd = CDPoint(pos.x - POWER_SIZE * 2, pos.y);
			break;
		case 3: // Right
			pa = CDPoint(pos.x + POWER_SIZE, pos.y);
			pb = CDPoint(pos.x + POWER_SIZE, pos.y - POWER_SIZE / 2);
			pc = CDPoint(pos.x + POWER_SIZE, pos.y + POWER_SIZE / 2 + 1);
			pd = CDPoint(pos.x + POWER_SIZE * 2, pos.y);
			break;
	}

	dc.TextOut(str, TextPos, options);

	switch (options)
	{
		case draw_selected:
		case draw_selectable:
			dc.SelectPen(PS_SOLID, 1, cSELECT);
			break;
		default:
			dc.SelectPen(PS_SOLID, 1, cLINE);
	}

	dc.SelectBrush();

	// Draw the main line of the power item
	switch (which)
	{
		case 0: // Draw the Bar
			dc.MoveTo(pb);
			dc.LineTo(pc);
			break;
		case 1: // Draw the Circle
			dc.Ellipse(CDRect(pb.x - (pa.x - pd.x), pb.y - (pa.y - pd.y), pc.x, pc.y));
			break;
		case 2: // Draw the Wave
			// The PolyBezier function is not implemented in MFC!
			// So this hack has to be used....
		{
			CDPoint pts[4];
			pts[0] = CDPoint(pb.x + (pd.x - pa.x) / 2, pb.y + (pd.y - pa.y) / 2);
			pts[1] = CDPoint(pd.x + (pb.x - pa.x) / 2, pd.y + (pb.y - pa.y) / 2);
			pts[2] = CDPoint(pa.x + (pc.x - pa.x) / 2, pa.y + (pc.y - pa.y) / 2);
			pts[3] = CDPoint(pc.x - (pa.x - pd.x) / 2, pc.y - (pa.y - pd.y) / 2);
			dc.PolyBezier(pts, 4);
		}
			break;
		case 3: // Draw the Arrow
			dc.MoveTo(pb);
			dc.LineTo(pc);
			dc.MoveTo(pb);
			dc.LineTo(pd);
			dc.LineTo(pc);
			break;
		case 4: // Draw the Earth
			dc.MoveTo(pb);
			dc.LineTo(pc);
			dc.MoveTo(CDPoint(pb.x - (pb.x - pd.x) / 2, pb.y - (pb.y - pd.y) / 2));
			dc.LineTo(CDPoint(pc.x - (pc.x - pd.x) / 2, pc.y - (pc.y - pd.y) / 2));
			dc.MoveTo(CDPoint(pd.x - (pb.x - pa.x) / 4, pd.y - (pb.y - pa.y) / 4));
			dc.LineTo(CDPoint(pd.x + (pb.x - pa.x) / 4, pd.y + (pb.y - pa.y) / 4));
			break;
	}

	// Draw the bits that all power items have in comman
	dc.MoveTo(pos);
	dc.LineTo(pa);

	if (is_stuck)
	{
		// Draw a nice circle to show the stickness...
		dc.PaintConnectPoint(m_point_b);

		// Do we need a junction
		if (is_junction)
		{
			int js = JUNCTION_SIZE;
			CDPoint br, tl;
			br = CDPoint(m_point_b.x + js, m_point_b.y + js);
			tl = CDPoint(m_point_b.x - js, m_point_b.y - js);

			dc.SetROP2(R2_COPYPEN);

			dc.SelectPen(PS_SOLID, 1, m_pDesign->GetOptions()->GetUserColor().Get(CUserColor::JUNCTION));
			dc.SelectBrush(m_pDesign->GetOptions()->GetUserColor().Get(CUserColor::JUNCTION));
			dc.Ellipse1(CDRect(tl.x, tl.y, br.x, br.y));
		}
	}

}