コード例 #1
0
void KniftyClient::create_pixmaps()
{
    if(pixmaps_created)
        return;

    QColor titleBorder3 = KniftyHandler::useTitleColor() ?
                          options()->colorGroup(KDecoration::ColorTitleBar, true).background()
                          : widget()->colorGroup().background();
    KPixmap tempPixmap;
    tempPixmap.resize(1, s_titleHeight );
    KPixmapEffect::gradient(tempPixmap,
                            hsvRelative(titleBorder3, 0, 0, 30),
                            hsvRelative(titleBorder3, 0, 0, -10),
                            KPixmapEffect::VerticalGradient);
    aTitleBarTile = new QPixmap(1, s_titleHeight );
    QPainter painter;
    painter.begin(aTitleBarTile);
    painter.drawPixmap(0, 0, tempPixmap);
    painter.end();

    titleBorder3 = KniftyHandler::useTitleColor() ?
                   options()->colorGroup(KDecoration::ColorTitleBar, false).background()
                   : widget()->colorGroup().background();
    tempPixmap.resize(1, s_titleHeight );
    KPixmapEffect::gradient(tempPixmap,
                            hsvRelative(titleBorder3, 0, 0, 5),
                            hsvRelative(titleBorder3, 0, 0, -10),
                            KPixmapEffect::VerticalGradient);
    iTitleBarTile = new QPixmap(1, s_titleHeight );
    painter.begin(iTitleBarTile);
    painter.drawPixmap(0, 0, tempPixmap);
    painter.end();

    pixmaps_created = true;
}
コード例 #2
0
void KWMThemeClient::drawTitle(QPainter &dest)
{
    QRect titleRect = titlebar->geometry();
    QRect r(0, 0, titleRect.width(), titleRect.height());
    QPixmap buffer;

    if(buffer.width() == r.width())
        return;

    buffer.resize(r.size());
    QPainter p;
    p.begin(&buffer);

    if(titleSunken){
        qDrawShadeRect(&p, r, options()->colorGroup(KDecorationOptions::ColorFrame, isActive()),
                       true, 1, 0);
        r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
    }
    
    KPixmap *fill = isActive() ? aTitlePix : iTitlePix;
    if(fill)
        p.drawTiledPixmap(r, *fill);
    else if(titleGradient){
        fill = isActive() ? aGradient : iGradient;
        if(fill->width() != r.width()){
            fill->resize(r.width(), 20);
            KPixmapEffect::gradient(*fill,
                                    options()->color(KDecorationOptions::ColorTitleBar, isActive()),
                                    options()->color(KDecorationOptions::ColorTitleBlend, isActive()),
                                    grType);
        }
        p.drawTiledPixmap(r, *fill);
    }
    else{
        p.fillRect(r, options()->colorGroup(KDecorationOptions::ColorTitleBar, isActive()).
                   brush(QColorGroup::Button));
    }
    p.setFont(options()->font(isActive()));
    p.setPen(options()->color(KDecorationOptions::ColorFont, isActive()));
    // Add left & right margin
    r.setLeft(r.left()+5);
    r.setRight(r.right()-5);
    p.drawText(r, titleAlign, caption());
    p.end();

    dest.drawPixmap(titleRect.x(), titleRect.y(), buffer);
}
コード例 #3
0
void KasLoadItem::paint( QPainter *p )
{
    double val = valuesOne.last();
    double maxValue = 1.0;
    double scaleVal = QMAX( val, valuesFive.last() );

    if ( scaleVal >= maxValue )
	maxValue = 2.0;
    if ( scaleVal >= maxValue )
	maxValue = 5.0;
    if ( scaleVal >= maxValue )
	maxValue = 10.0;
    if ( scaleVal >= maxValue )
	maxValue = 20.0;
    if ( scaleVal >= maxValue )
	maxValue = 50.0;
    if ( scaleVal >= maxValue )
	maxValue = 100.0;

    double dh = extent()-16;
    dh = dh / maxValue;

    int h = (int) floor( dh * val );
    int w = extent()-4;
    h = (h > 0) ? h : 1;
    w = (w > 0) ? w : 1;

    KasItem::paint( p );

    QColor light = kasbar()->colorGroup().highlight();
    QColor dark = light.dark();

    KPixmap pix;
    pix.resize( w, h );
    KPixmapEffect::gradient( pix, light, dark, KPixmapEffect::DiagonalGradient );
    p->drawPixmap( 2, extent()-2-h, pix );

    p->setPen( kasbar()->colorGroup().mid() );
    for ( double pos = 0.2 ; pos < 1.0 ; pos += 0.2 ) {
	int ypos = (int) floor((extent()-2) - (dh*maxValue*pos));
	p->drawLine( 2, ypos, extent()-3, ypos );
    }
}
コード例 #4
0
ファイル: quartz.cpp プロジェクト: serghei/kde3-kdebase
// Quartz Paint magic goes here.
void QuartzClient::paintEvent(QPaintEvent *)
{
    // Never paint if the pixmaps have not been created
    if(!quartz_initialized)
        return;

    const bool maxFull = (maximizeMode() == MaximizeFull) && !options()->moveResizeMaximizedWindows();

    QColorGroup g;
    QPainter p(widget());

    // Obtain widget bounds.
    QRect r(widget()->rect());
    int x = r.x();
    int y = r.y();
    int x2 = r.width() - 1;
    int y2 = r.height() - 1;
    int w = r.width();
    int h = r.height();

    // Draw part of the frame that is the title color

    if(coloredFrame)
        g = options()->colorGroup(ColorTitleBar, isActive());
    else
        g = options()->colorGroup(ColorFrame, isActive());

    // Draw outer highlights and lowlights
    p.setPen(g.light().light(120));
    p.drawLine(x, y, x2 - 1, y);
    p.drawLine(x, y + 1, x, y2 - 1);
    p.setPen(g.dark().light(120));
    p.drawLine(x2, y, x2, y2);
    p.drawLine(x, y2, x2, y2);

    // Fill out the border edges
    QColor frameColor;
    if(coloredFrame)
        frameColor = g.background().light(130);
    else
        frameColor = g.background();
    if(borderSize > 2)
    {
        p.fillRect(x + 1, y + 1, w - 2, borderSize - 2, frameColor); // top
        if(!maxFull)
        {
            p.fillRect(x + 1, y + h - (borderSize - 1), w - 2, borderSize - 2, frameColor);                             // bottom
            p.fillRect(x + 1, y + borderSize - 1, borderSize - 1, h - 2 * (borderSize - 1), frameColor);                // left
            p.fillRect(x + w - (borderSize), y + borderSize - 1, borderSize - 1, h - 2 * (borderSize - 1), frameColor); // right
        }
    }

    // Draw a frame around the wrapped widget.
    p.setPen(g.background());
    if(maxFull)
    {
        p.drawLine(x + 1, y + titleHeight + (borderSize - 1), w - 2, y + titleHeight + (borderSize - 1));
    }
    else
    {
        p.drawRect(x + (borderSize - 1), y + titleHeight + (borderSize - 1), w - 2 * (borderSize - 1), h - titleHeight - 2 * (borderSize - 1));
    }

    // Drawing this extra line removes non-drawn areas when shaded
    p.drawLine(x + borderSize, y2 - borderSize, x2 - borderSize, y2 - borderSize);

    // Highlight top corner
    p.setPen(g.light().light(160));
    p.drawPoint(x, y);
    p.setPen(g.light().light(140));
    p.drawPoint(x + 1, y);
    p.drawPoint(x, y + 1);

    // Draw the title bar.
    // ===================
    int r_x, r_y, r_x2, r_y2;
    widget()->rect().coords(&r_x, &r_y, &r_x2, &r_y2);
    const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
    const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
    const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
    const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
    const int ttlHeight = layoutMetric(LM_TitleHeight);
    const int titleEdgeBottomBottom = r_y + titleEdgeTop + ttlHeight + titleEdgeBottom - 1;
    r = QRect(r_x + titleEdgeLeft + buttonsLeftWidth(), r_y + titleEdgeTop,
              r_x2 - titleEdgeRight - buttonsRightWidth() - (r_x + titleEdgeLeft + buttonsLeftWidth()), titleEdgeBottomBottom - (r_y + titleEdgeTop));

    // Obtain titlebar blend colours
    QColor c1 = options()->color(ColorTitleBar, isActive()).light(130);
    QColor c2 = options()->color(ColorTitleBlend, isActive());

    // Create a disposable pixmap buffer for the titlebar
    KPixmap *titleBuffer = new KPixmap;
    titleBuffer->resize(maxFull ? w - 2 : (w - 2 * (borderSize - 1)), titleHeight);

    QPainter p2(titleBuffer, this);

    // subtract titleBlocks pixmap width and some
    int rightoffset = r.x() + r.width() - titleBlocks->width() - borderSize;

    p2.fillRect(0, 0, w, r.height(), c1);
    p2.fillRect(rightoffset, 0, maxFull ? w - rightoffset : w - rightoffset - 2 * (borderSize - 1), r.height(), c2);

    // 8 bit displays will be a bit dithered, but they still look ok.
    if(isActive())
        p2.drawPixmap(rightoffset, 0, *titleBlocks);
    else
        p2.drawPixmap(rightoffset, 0, *ititleBlocks);

    // Draw the title text on the pixmap, and with a smaller font
    // for toolwindows than the default.
    QFont fnt;
    if(largeButtons)
    {
        fnt = options()->font(true, false); // font not small
    }
    else
    {
        fnt = options()->font(true, true); // font small
        fnt.setWeight(QFont::Normal);      // and disable bold
    }
    p2.setFont(fnt);

    p2.setPen(options()->color(ColorFont, isActive()));
    p2.drawText(r.x() + 4 - borderSize, 0, r.width() - 3, r.height(), AlignLeft | AlignVCenter, caption());
    p2.end();

    p.drawPixmap(maxFull ? 1 : borderSize - 1, borderSize - 1, *titleBuffer);

    delete titleBuffer;
}
コード例 #5
0
void EstateDetails::paintEvent(QPaintEvent *)
{
	if (m_recreateQuartz)
	{
/*
		if (m_quartzBlocks)
		{
			delete m_quartzBlocks;
			m_quartzBlocks = 0;
		}

		if (m_estate->color().isValid())
		{
			m_quartzBlocks = new KPixmap();

			if (m_orientation == North || m_orientation == South)
				m_quartzBlocks->resize(25, m_titleHeight-2);
			else
				m_quartzBlocks->resize(25, m_titleWidth-2);

			drawQuartzBlocks(m_quartzBlocks, *m_quartzBlocks, m_estate->color().light(60), m_estate->color());
			m_quartzBlocks = rotatePixmap(m_quartzBlocks);
		}
*/
		m_recreateQuartz = false;
		b_recreate = true;
	}

	if (b_recreate)
	{
		delete m_pixmap;
		m_pixmap = new QPixmap(width(), height());

		QColor greenHouse(0, 255, 0);
		QColor redHotel(255, 51, 51);
		QPainter painter;
		painter.begin(m_pixmap, this);

		painter.setPen(Qt::black);

		painter.setBrush(m_estate ? m_estate->bgColor() : Qt::white);
		painter.drawRect(rect());

/*
		// Paint icon only when it exists and fits
		if (icon!=0 && width() > icon->width() && height() > icon->height())
			painter.drawPixmap( (width() - icon->width())/2, (height() - icon->height())/2, *icon);
*/

		if (m_estate)
		{
			int titleHeight = 50;
			QColor titleColor = (m_estate->color().isValid() ? m_estate->color() : m_estate->bgColor().light(80));

			KPixmap* quartzBuffer = new KPixmap;
			quartzBuffer->resize(25, (height()/4)-2);

			QPainter quartzPainter;
			quartzPainter.begin(quartzBuffer, this);

			painter.setBrush(titleColor);
			painter.drawRect(0, 0, width(), titleHeight);

			if (m_quartzBlocks)
			{
				quartzPainter.drawPixmap(0, 0, *m_quartzBlocks);
				painter.drawPixmap(1, 1, *quartzBuffer);
			}

			if (m_estate->houses() > 0)
			{
				int titleWidth = width() / 5;

				if (m_estate->houses() == 5)
				{
					// Hotel
					painter.setBrush(redHotel);
					painter.drawRect(2, 2, titleWidth-4, titleHeight-4);
				}
				else
				{
					// Houses
					painter.setBrush(greenHouse);
						int h = titleHeight-4, w = titleWidth-4;
						for ( unsigned int i=0 ; i < m_estate->houses() ; i++ )
						painter.drawRect(2+(i*(w+2)), 2, w, h);
				}
			}

			quartzPainter.end();
			delete quartzBuffer;

			// TODO: steal blur code from kicker/taskbar/taskcontainer.cpp

			// Estate name
			painter.setPen(Qt::white);
			int fontSize = KGlobalSettings::generalFont().pointSize();
			if (fontSize == -1)
				fontSize = KGlobalSettings::generalFont().pixelSize();

			painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize * 2, QFont::Bold));
			painter.drawText(KDialog::marginHint(), KDialog::marginHint(), width()-KDialog::marginHint(), titleHeight, Qt::AlignJustify, m_estate->name());

			painter.setPen(Qt::black);

			int xText = 0;

			// Estate group
			if (m_estate->estateGroup())
			{
				xText = titleHeight - fontSize - KDialog::marginHint();
				painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize, QFont::Bold));
				painter.drawText(5, xText, width()-10, titleHeight, Qt::AlignRight, m_estate->estateGroup()->name().upper());
			}

			xText = titleHeight + fontSize + 5;
			painter.setFont(QFont(KGlobalSettings::generalFont().family(), fontSize, QFont::Normal));
		}
		b_recreate = false;

	}
	bitBlt(this, 0, 0, m_pixmap);
}