Example #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;
}
Example #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);
}
Example #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 );
    }
}
Example #4
0
QPixmap HostListItem::generateGradient( int type )
{
  QPixmap temp;
  
  if( type == PixRight )
    temp = QPixmap( locate( "data", "amarok/images/nmm-gradient-right.png" ) );
  else // PixLeft
    temp = QPixmap( locate( "data", "amarok/images/nmm-gradient-left.png" ) );
  const QBitmap mask( temp.createHeuristicMask() );

  KPixmap result = QPixmap( 113, 24 );
  if( type == PixRight)
    KPixmapEffect::gradient( result, listView()->colorGroup().background(), listView()->colorGroup().highlight(), KPixmapEffect::HorizontalGradient );
  else
    KPixmapEffect::gradient( result, listView()->colorGroup().highlight(), listView()->colorGroup().background(), KPixmapEffect::HorizontalGradient );

  result.setMask( mask);
  return result;
}
Example #5
0
void BGMonitorArrangement::setPixmap( const KPixmap & pm )
{
    for (unsigned screen = 0; screen < m_pBGMonitor.size(); ++screen)
    {
        QRect position = m_pBGMonitor[screen]->previewPosition();
        
        QPixmap monitorPixmap( position.size(), pm.depth() );
        copyBlt( &monitorPixmap, 0, 0, &pm, position.x(), position.y(), position.width(), position.height() );
        m_pBGMonitor[screen]->monitor()->setPixmap(monitorPixmap);
    }
}
Example #6
0
void KMDITitleLabel::kwm_gradientFill(KPixmap &pm, QColor ca, QColor cb,
       bool upDown) {
   if(upDown == FALSE && QColor::numBitPlanes() >= 15) { 
    int w = pm.width();
    int h = pm.height();
    
    int c_red_a = ca.red() << 16;
    int c_green_a = ca.green() << 16;
    int c_blue_a = ca.blue() << 16;

    int c_red_b = cb.red() << 16;
    int c_green_b = cb.green() << 16;
    int c_blue_b = cb.blue() << 16;
    
    int d_red = (c_red_b - c_red_a) / w;
    int d_green = (c_green_b - c_green_a) / w;
    int d_blue = (c_blue_b - c_blue_a) / w;

    QImage img(w, h, 32);
    uchar *p = img.scanLine(0);

    int r = c_red_a, g = c_green_a, b = c_blue_a;
    for(int x = 0; x < w; x++) {
      *p++ = r >> 16;
      *p++ = g >> 16;
      *p++ = b >> 16;
      p++;
      
      r += d_red;
      g += d_green;
      b += d_blue;
    }

    uchar *src = img.scanLine(0);
    for(int y = 1; y < h; y++)
      memcpy(img.scanLine(y), src, 4*w);

    pm.convertFromImage(img);
  } else
Example #7
0
WndIcon::WndIcon(unsigned int icon_num, unsigned int icon_std_width, unsigned int status_height, int xineramaScreen, const KPixmap &pix,
                 const QString &text, Position icon_position, bool statusAtTop, bool iconsJumping)
    : QHBox(0, "wndSplash", WStyle_Customize | WX11BypassWM)
    , mStatusText(text)
    , mIconPos(icon_position)
    , mXineramaScreen(xineramaScreen)
    , mPosX(0)
    , mPosY(0)
    , mGroundX(0)
    , mGroundY(0)
    , mVelocity(8.0)
    , mInitialVelocity(8.0)
    , mGravity(0.8)
    , mIconNum(icon_num)
    , mStatusHeight(status_height)
    , mIconSize(icon_std_width)
    , mStatusAtTop(statusAtTop)
    , mStopJump(false)
    , mIconJumping(iconsJumping)
{
    setFrameStyle(QFrame::NoFrame);

    QLabel *w = new QLabel(this);
    w->setFixedSize(pix.width(), pix.height());
    w->setPixmap(pix);
    if(pix.mask())
    {
        setMask(*pix.mask());
        w->setMask(*pix.mask());
    }

    resize(pix.width(), pix.height());

    // Set initial position of icon, and ground.
    QPoint p = determinePosition();
    mGroundX = mPosX = p.x();
    mGroundY = mPosY = p.y();
    move(p + kapp->desktop()->screenGeometry(mXineramaScreen).topLeft());

    if(mIconJumping)
    {
        QTimer *t = new QTimer(this);
        connect(t, SIGNAL(timeout()), SLOT(slotJump()));
        t->start(50, false);
    }
}
Example #8
0
// 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;
}
Example #9
0
const KPixmap &SUSE2Handler::buttonPixmap(ButtonIcon type, int size, ButtonStatus status)
{
    if (m_pixmaps[status][type]) {
        if (status != Shadow && m_pixmaps[status][type]->size() == QSize(size, size))
            return *m_pixmaps[status][type];
        else if (status == Shadow && m_pixmaps[status][type]->size() == QSize(size+4, size+4))
            return *m_pixmaps[status][type];
    }

    // no matching pixmap found, create a new one...

    delete m_pixmaps[status][type];
    m_pixmaps[status][type] = 0;

    QColor aDecoFgDark = alphaBlendColors(getColor(TitleGradientTo, true), Qt::black, 50);
    QColor aDecoFgLight = alphaBlendColors(getColor(TitleGradientTo, true), Qt::white, 50);
    QColor iDecoFgDark = alphaBlendColors(getColor(TitleGradientTo, false), Qt::black, 50);
    QColor iDecoFgLight = alphaBlendColors(getColor(TitleGradientTo, false), Qt::white, 50);

    if (m_customIconColors && !m_useTitleProps) {
        aDecoFgDark = m_aFgColor;
        aDecoFgLight = m_aBgColor;
        iDecoFgDark = m_iFgColor;
        iDecoFgLight = m_iBgColor;
    }

    KPixmap icon = IconEngine::icon(type, size);
    QImage img = icon.convertToImage();

    KPixmap *pixmap;
    QImage tmpImage;
    ShadowEngine se;
    QPainter painter;
    KPixmap tmpShadow;
    switch (status) {
        case ActiveUp:
            if (m_useTitleProps)
                tmpImage = recolorImage(&img, getColor(TitleFont, true));
            else
                tmpImage = recolorImage(&img, aDecoFgDark);

            pixmap = new KPixmap(tmpImage);
            break;
        case ActiveDown:
            if (m_useTitleProps)
                tmpImage = recolorImage(&img, getColor(TitleFont, true));
            else
                tmpImage = recolorImage(&img, aDecoFgLight);

            pixmap = new KPixmap(tmpImage);
            break;
        case InactiveUp:
            if (m_useTitleProps)
                tmpImage = recolorImage(&img, getColor(TitleFont, false));
            else
                tmpImage = recolorImage(&img, iDecoFgDark);

            pixmap = new KPixmap(tmpImage);
            break;
        case InactiveDown:
            if (m_useTitleProps)
                tmpImage = recolorImage(&img, getColor(TitleFont, false));
            else
                tmpImage = recolorImage(&img, iDecoFgLight);

            pixmap = new KPixmap(tmpImage);
            break;
        case Shadow:
            // prepare shadow
            tmpShadow = QPixmap(icon.width()+4, icon.height()+4);
            tmpShadow.fill(QColor(0,0,0));
            tmpShadow.setMask(tmpShadow.createHeuristicMask(true));
            painter.begin(&tmpShadow);
            painter.setPen(white);
            painter.drawPixmap(0,0, icon);
            painter.end();
            tmpImage = se.makeShadow(tmpShadow, QColor(0, 0, 0));
            pixmap = new KPixmap(tmpImage);
            break;
        default:
            pixmap = new KPixmap();
    }

    m_pixmaps[status][type] = pixmap;
    return *pixmap;
}
Example #10
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);
}