Beispiel #1
0
BOOL CListCtrlEx::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	CRect rect;
	CListCtrlEx::GetClientRect(rect);
	
	POINT mypoint;  
	
	CBrush brush0(m_colRow1);
	CBrush brush1(m_colRow2);
	
	int chunk_height=GetCountPerPage();
	pDC->FillRect(&rect,&brush1);
	
	for (int i=0;i<=chunk_height;i++)
	{
		GetItemPosition(i,&mypoint);
		rect.top=mypoint.y ;
		GetItemPosition(i+1,&mypoint);
		rect.bottom =mypoint.y;
		pDC->FillRect(&rect,i %2 ? &brush1 : &brush0);
		
	}
	brush0.DeleteObject();
	brush1.DeleteObject();
	
	//return FALSE;
	return CListCtrl::OnEraseBkgnd(pDC);
}
void CFreqDial::drawDial()
{
	wxMemoryDC dc;
	dc.SelectObject(*m_bitmap);

#if defined(__WXMSW__)
	int major, minor;
	::wxGetOsVersion(&major, &minor);

	wxColour bgColour;
	if (major >= 6)
		bgColour = wxColour(0xF0, 0xF0, 0xF0);		// Windows Vista and newer
	else if (major == 5 && minor >= 1)
		bgColour = wxColour(0xEC, 0xE9, 0xD8);		// Windows XP
	else
		bgColour = wxColour(0xD4, 0xD0, 0xC8);		// Windows 2000 and earlier
#elif defined(__WXGTK__)
	wxColour bgColour(0xF0, 0xF1, 0xF2);
	// wxColour bgColour(0xED, 0xE9, 0xE3);
#elif defined(__WXMAC__)
	wxColour bgColour(0xF0, 0xF0, 0xF0);
#else
#error "Unknown platform"
#endif

	wxBrush brush0(bgColour);
	wxPen pen0(bgColour);

	dc.SetPen(pen0);
	dc.SetBrush(brush0);
	dc.DrawRectangle(0, 0, m_width, m_height);

	int middleX = m_width / 2;
	int middleY = m_height / 2;

	dc.SetBrush(*wxLIGHT_GREY_BRUSH);
	wxPen pen1(*wxBLACK, 2, wxSOLID);
	dc.SetPen(pen1);
	dc.DrawCircle(middleX, middleY, (m_width - 2) / 2);

	int x = m_width / 2 - int(double(m_width / 2 - 25) * ::sin(m_angle * (M_PI / 180.0)) + 0.5);
	int y = m_height / 2 + int(double(m_height / 2 - 25) * ::cos(m_angle * (M_PI / 180.0)) + 0.5);

	dc.SetBrush(*wxBLACK_BRUSH);
	wxPen pen2(*wxWHITE, 2, wxSOLID);
	dc.SetPen(pen2);
	dc.DrawCircle(x, y, 20);

	dc.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);
}
void ActivityProgressBar::update_indicator()
{
	_progressBarImageDelta+=0.5;

	float chunkLength = 2;

	if(_progressBarImageDelta >= (chunkLength*2 + 1))
		_progressBarImageDelta = 0.f;

	// draw on _pbIndicator
	QRect bounds = contentsRect();
	bounds = bounds.adjusted(2, 8, -2, -8);

	// safe delete _pbInidicato
	if(_pbIndicator)
		delete _pbIndicator;

	QRect rc = bounds.adjusted(0, 0, 0, 0);

	_pbIndicator = new QImage(rc.size(), QImage::Format_ARGB8565_Premultiplied);
	_pbIndicator->fill(Qt::transparent);
	QPainter p(_pbIndicator);

	p.setCompositionMode(QPainter::CompositionMode_Source);
	p.setRenderHint(QPainter::SmoothPixmapTransform, true);
	p.setRenderHint(QPainter::HighQualityAntialiasing, true);

	QColor chunkColor = QColor::fromRgb(255,150,100),
		backgroundColor = Qt::darkGray;

	QBrush brush0(Qt::SolidPattern);
	brush0.setColor(backgroundColor);
	p.fillRect(0,0,_pbIndicator->width(), _pbIndicator->height(), brush0);

	QBrush brush(Qt::SolidPattern);
	brush.setColor(chunkColor);
	p.setBrush(brush);

	QPen pen(chunkColor);
	p.setPen(pen);
	for (qreal iX = -chunkLength*3 + _progressBarImageDelta; iX < _pbIndicator->width(); iX++)
	{
		//p.drawEllipse(iX, (_pbIndicator->height()-chunkLength)/2, chunkLength, chunkLength);
		p.drawRoundedRect(iX, 0, chunkLength, _pbIndicator->height()-1, 2, 2);
		iX += (chunkLength*2 + 1);
	}

	p.end();
}
BOOL CClonePairListCtrl::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default

  CRect rect;
  CClonePairListCtrl::GetClientRect(rect);


  POINT mypoint;  
  
  CBrush brush0(m_colRow1);
  CBrush brush1(m_colRow2);


 
 int chunk_height=GetCountPerPage();
 //pDC->FillRect(&rect,&brush1);

 int top = 0;
 int bottom = 0;
 GetItemPosition(0,&mypoint);
 top = mypoint.y;
 GetItemPosition(1,&mypoint);
 bottom = mypoint.y;
 int height = bottom - top;
 for (int i=0;i<=chunk_height;i++)
 {
		
	//GetItemPosition(i,&mypoint);
	rect.top=top; //mypoint.y ;
	//GetItemPosition(i+1,&mypoint);
	rect.bottom = bottom; //mypoint.y;
	pDC->FillRect(&rect,i %2 ? &brush1 : &brush0);

	top = bottom;
	bottom +=height;

 }

  brush0.DeleteObject();
  brush1.DeleteObject();

  return FALSE;
}
Beispiel #5
0
void CVolumeDial::drawDial()
{
	wxMemoryDC dc;
	dc.SelectObject(*m_bitmap);

#if defined(__WXMSW__)
	int major, minor;
	::wxGetOsVersion(&major, &minor);

	wxColour bgColour;
	if (major >= 6)
		bgColour = wxColour(0xF0, 0xF0, 0xF0);		// Windows Vista and newer
	else if (major == 5 && minor >= 1)
		bgColour = wxColour(0xEC, 0xE9, 0xD8);		// Windows XP
	else
		bgColour = wxColour(0xD4, 0xD0, 0xC8);		// Windows 2000 and earlier
#elif defined(__WXGTK__)
	wxColour bgColour(0xF0, 0xF1, 0xF2);
	// wxColour bgColour(0xED, 0xE9, 0xE3);
#elif defined(__WXMAC__)
	wxColour bgColour(0xE8, 0xE8, 0xE8);
#else
#error "Unknown platform"
#endif

	wxBrush brush0(bgColour);
	wxPen pen0(bgColour);

	dc.SetPen(pen0);
	dc.SetBrush(brush0);
	dc.DrawRectangle(0, 0, m_width, m_height);

	if (IsEnabled()) {
		dc.SetBrush(*wxLIGHT_GREY_BRUSH);
		dc.SetPen(wxPen(*wxBLACK, 2, wxSOLID));
	} else {
		dc.SetBrush(brush0);
		dc.SetPen(wxPen(*wxLIGHT_GREY, 2, wxSOLID));
	}

	dc.DrawEllipse(1, 1, m_width - 2, m_height - 2);

	double incr = 270.0 / double(m_max - m_min); 

	double angle = (double(m_value - m_min) * incr + 45.0) * (M_PI / 180.0);

	double xFrac = ::sin(angle);
	double yFrac = ::cos(angle);

	int startX = m_width / 2 - int(double(m_width / 2 - 10) * xFrac + 0.5);
	int startY = m_height / 2 + int(double(m_height / 2 - 10) * yFrac + 0.5);

	int endX = m_width / 2 - int(double(m_width / 2 - 20) * xFrac + 0.5);
	int endY = m_height / 2 + int(double(m_height / 2 - 20) * yFrac + 0.5);

	if (IsEnabled())
		dc.SetPen(wxPen(*wxBLACK, 5, wxSOLID));
	else
		dc.SetPen(wxPen(*wxLIGHT_GREY, 2, wxSOLID));

	dc.DrawLine(startX, startY, endX, endY);	

	dc.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);
}
Beispiel #6
0
void CColorTree::OnPaint()
{
	CTreeCtrl::OnPaint();
	CPaintDC dc(this); // device context for painting
	HTREEITEM hItem;
	CImageList *List;
			List = GetImageList(0);

	
	hItem = GetFirstVisibleItem();
	CRect rec, recText;

	 CBrush brush0(m_colRow1);
	CBrush brush1(m_colRow2);

	int i;
	i = 0;
	CDC * pDC;
	pDC = GetDC();
	CFont Font;
	Font.CreateFontW(15,0,0,0,FW_NORMAL, FALSE, FALSE,FALSE,RUSSIAN_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_MODERN|DEFAULT_PITCH,_T("TestFont"));
	pDC->SelectObject(Font);
	while(hItem!=NULL)
	{
		GetItemRect(hItem,rec,FALSE);
		GetItemRect(hItem,recText,TRUE);
		//
		if(i % 2 == 0)
			{
				pDC->FillRect(rec,&brush0);
				pDC->SetBkColor(m_colRow1);
			}
		else
			{
				pDC->SetBkColor(m_colRow2);
				pDC->FillRect(rec,&brush1);
			}
		CString sName;
		sName = GetItemText(hItem);
		if(sName.Find(_T("\n"))>-1)
		{
			sName =  sName.Left(sName.Find(_T("\n")));
		}
		if(sName.Find(_T("\t"))>-1)
			{
				CString sVal;
				sVal = sName.Left(sName.Find(_T("\t")));
				pDC->TextOutW(recText.left-20 ,rec.top,sVal,sVal.GetLength());
				
				sVal = sName.Right(sName.GetLength()-1-sVal.GetLength());
				pDC->TextOutW(rec.left + (rec.right - rec.left)/2,rec.top,sVal,sVal.GetLength());
			}
		else
			pDC->TextOutW(recText.left - 20,rec.top,sName,sName.GetLength());


		if(GetItemState(hItem, TVIS_EXPANDED)& TVIS_EXPANDED)
		{
			if(List!=NULL)
			{
				CPoint xy; 		
				xy =  recText.TopLeft();
				xy.x = xy.x - 40;
				List->Draw(pDC,1,xy,ILD_NORMAL);
			}
		}
		else
		{
			if(List!=NULL)
			{
				CPoint xy; 		
				xy =  recText.TopLeft();
				xy.x = xy.x - 40;
				if(GetChildItem(hItem)!=NULL)
					List->Draw(pDC,0, xy,ILD_NORMAL);
				else
					List->Draw(pDC,2, xy,ILD_NORMAL);
			}
		}

		hItem = GetNextVisibleItem(hItem);
		i++;
	}
}