Beispiel #1
0
TEMPLATE void CDialogMinTrayBtn<BASE>::MinTrayBtnDraw()
{
    if (!MinTrayBtnIsVisible())
       return;

    CDC *pDC= GetWindowDC();
    if (!pDC)
       return; // panic!

    if (IsWindowsClassicStyle())
    {
        CBrush black(GetSysColor(COLOR_BTNTEXT));
        CBrush gray(GetSysColor(COLOR_GRAYTEXT));
        CBrush gray2(GetSysColor(COLOR_BTNHILIGHT));

        // button
        if (m_bMinTrayBtnUp)
           pDC->DrawFrameControl(MinTrayBtnGetRect(), DFC_BUTTON, DFCS_BUTTONPUSH);
        else
           pDC->DrawFrameControl(MinTrayBtnGetRect(), DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED);

        // dot
        CRect btn = MinTrayBtnGetRect();
        btn.DeflateRect(2,2);
        UINT caption = MinTrayBtnGetSize().cy + (CAPTION_BUTTONSPACE * 2);
        UINT pixratio = (caption >= 14) ? ((caption >= 20) ? 2 + ((caption - 20) / 8) : 2) : 1;
        UINT pixratio2 = (caption >= 12) ? 1 + (caption - 12) / 8: 0;
        UINT dotwidth = (1 + pixratio * 3) >> 1;
        UINT dotheight = pixratio;
        CRect dot(CPoint(0,0), CPoint(dotwidth, dotheight));
        CSize spc((1 + pixratio2 * 3) >> 1, pixratio2);
        dot -= dot.Size();
        dot += btn.BottomRight();
        dot -= spc;
        if (!m_bMinTrayBtnUp)
           dot += CPoint(1,1);
        if (m_bMinTrayBtnEnabled)
        {
           pDC->FillRect(dot, &black);
        }
        else
        {
           pDC->FillRect(dot + CPoint(1,1), &gray2);
           pDC->FillRect(dot, &gray);
        }
    }
	else
	{
Beispiel #2
0
void TimelineWidget::paintEvent(QPaintEvent* event)
{
	if (similar(mStart,mStop))
		return;
	QWidget::paintEvent(event);

	QPainter painter(this);
//  QPen pointPen, pointLinePen;
	painter.setRenderHint(QPainter::Antialiasing);
	painter.setPen(Qt::NoPen);

	QColor gray0(240, 240, 240);
	QColor gray01(220, 220, 220);
	QColor gray1(200, 200, 200);
	QColor gray2(170, 170, 170); // darker
	QColor gray3(150, 150, 150); // even darker
	QColor gray4(100, 100, 100); // even darker
	QColor highlight(110, 214, 255); // color around highlighted circle in qslider on KDE.

	// Fill with white background color and grey plot area background color
	QBrush brush(Qt::SolidPattern); // = painter.brush();
	brush.setColor(gray2);
	painter.setBrush(brush);

	painter.drawRoundedRect(this->mFullArea, 4, 4);
//	brush.setColor(gray01);
	brush.setColor(gray1);
	painter.setBrush(brush);
	painter.drawRoundedRect(this->mPlotArea, 4, 4);

	int margin = 1;

	// draw noncompacted interval
	for (unsigned i = 0; i < mNoncompactedIntervals.size(); ++i)
	{
		int start_p = this->mapTime2PlotX(mNoncompactedIntervals[i].mStartTime);
		int stop_p = this->mapTime2PlotX(mNoncompactedIntervals[i].mEndTime);
		QColor color = gray01;
		painter.fillRect(QRect(start_p, mPlotArea.top(), stop_p - start_p, mPlotArea.height()), color);
	}

	// draw all continous events
	for (unsigned i = 0; i < mEvents.size(); ++i)
	{
		if (!mContinousEvents.contains(mEvents[i].mGroup))
			continue;
		int start_p = this->mapTime2PlotX(mEvents[i].mStartTime);
		int stop_p = this->mapTime2PlotX(mEvents[i].mEndTime);
		int level = std::distance(mContinousEvents.begin(),
						std::find(mContinousEvents.begin(), mContinousEvents.end(), mEvents[i].mGroup));
		int level_max = mContinousEvents.size();
		int thisHeight = (mPlotArea.height()) / level_max - margin * (level_max - 1) / level_max;
		int thisTop = mPlotArea.top() + level * thisHeight + level * margin;

//		QColor color = mEventColors[level % mEventColors.size()];
		QColor color = mEvents[i].mColor;

		painter.fillRect(QRect(start_p, thisTop, stop_p - start_p, thisHeight), color);
	}

	// draw all singular events
	for (unsigned i = 0; i < mEvents.size(); ++i)
	{
		if (mContinousEvents.contains(mEvents[i].mGroup))
			continue;

		int start_p = this->mapTime2PlotX(mEvents[i].mStartTime);
//		int stop_p = this->mapTime2PlotX(mEvents[i].mEndTime);

		int glyphWidth = 3;
		QRect rect(start_p - glyphWidth / 2, mPlotArea.top(), glyphWidth, mPlotArea.height());

		brush.setColor(QColor(50, 50, 50));
		painter.setBrush(brush);
		painter.drawRoundedRect(rect, 2, 2);

//		painter.fillRect(rect, gray4);
		if (rect.width() > 2 && rect.height() > 2)
		{
			rect.adjust(1, 1, -1, -1);
			painter.fillRect(rect, gray2);
		}
	}

	int offset_p = this->mapTime2PlotX(mPos);
	QPolygonF glyph;
	int z = 5;
	int h = mPlotArea.height();
	glyph.push_back(QPointF(-z, 0));
	glyph.push_back(QPointF(z, 0));
	glyph.push_back(QPointF(z, 0.7 * h));
	glyph.push_back(QPointF(0, h));
	glyph.push_back(QPointF(-z, 0.7 * h));
	glyph.translate(offset_p, 0);
	if (this->hasFocus() || mCloseToGlyph)
		painter.setPen(highlight);
	else
		painter.setPen(gray4);
//  QBrush brush(Qt::SolidPattern);// = painter.brush();

	QRadialGradient radialGrad(QPointF(offset_p, h / 3), 2 * h / 3);
	radialGrad.setColorAt(0, gray0);
//  radialGrad.setColorAt(0.5, Qt::blue);
	radialGrad.setColorAt(1, gray2);

	brush = QBrush(radialGrad);
//  brush.setColor(gray0);
	painter.setBrush(brush);
	painter.drawPolygon(glyph);
}