예제 #1
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);
    }
}
예제 #2
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
예제 #3
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;
}