void QWSDefaultDecoration::paint(QPainter *painter, const QWidget *widget)
{
#ifndef QT_NO_STYLE
    QStyle &style = QApplication::style();
#endif

    int titleWidth = getTitleWidth(widget);
    int titleHeight = getTitleHeight(widget);

    QRect rect(widget->rect());

    // Border rect
    QRect br( rect.left() - BORDER_WIDTH,
                rect.top() - BORDER_WIDTH - titleHeight,
                rect.width() + 2 * BORDER_WIDTH,
                rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight );

    // title bar rect
    QRect tr;

    {
        tr = QRect( titleHeight, -titleHeight,  titleWidth, titleHeight - 1);
    }

    QRegion oldClip = painter->clipRegion();
    painter->setClipRegion( oldClip - QRegion( tr ) );	// reduce flicker

#ifndef QT_NO_PALETTE
    // const QColorGroup &cg = QApplication::palette().active();
    const QColorGroup &cg = widget->palette().active();

#if !defined(QT_NO_STYLE)
    style.drawPanel(painter, br.x(), br.y(), br.width(),
		    br.height() - 4, cg, FALSE, 2,
		    &cg.brush(QColorGroup::Background));
#elif !defined(QT_NO_DRAWUTIL)
    qDrawWinPanel(painter, br.x(), br.y(), br.width(),
		  br.height() - 4, cg, FALSE,
		  &cg.brush(QColorGroup::Background));
#endif

    painter->setClipRegion( oldClip );

    if (titleWidth > 0) {
	QBrush titleBrush;
	QPen   titlePen;
	int    titleLeft = titleHeight + 4;

	if (widget == qApp->activeWindow()) {
	    titleBrush = cg.brush(QColorGroup::Highlight);
	    titlePen   = cg.color(QColorGroup::HighlightedText);
	} else {
	    titleBrush = cg.brush(QColorGroup::Background);
	    titlePen   = cg.color(QColorGroup::Text);
	}

#define CLAMP(x, y)	    ( ((x) > (y)) ? (y) : (x) )

	{

#if !defined(QT_NO_STYLE)
	    style.drawPanel(painter, tr.x(), tr.y(), tr.width(), tr.height(),
			    cg, TRUE, 1, &titleBrush);
#elif !defined(QT_NO_DRAWUTIL)
	    qDrawWinPanel(painter, tr.x(), tr.y(), tr.width(), tr.height(),
			    cg, TRUE, &titleBrush);
#endif

	    painter->setPen(titlePen);
	    painter->setFont(widget->font());
	    painter->drawText( titleLeft, -titleHeight,
			    titleWidth-5, titleHeight - 1,
			    QPainter::AlignVCenter, widget->caption());
	    return;
	}

	painter->setPen(titlePen);
	painter->setFont(widget->font());
	painter->drawText( titleLeft, -titleHeight,
	 		rect.width() - titleHeight - 10, titleHeight-1,
			QPainter::AlignVCenter, widget->caption());
    }

#endif //QT_NO_PALETTE

}
void QWSWindowsDecoration::paint(QPainter *painter, const QWidget *widget)
{
    int titleWidth = getTitleWidth(widget);
    int titleHeight = getTitleHeight(widget);

    QRect rect(widget->rect());

    // Border rect
    QRect br( rect.left() - BORDER_WIDTH,
                rect.top() - BORDER_WIDTH - titleHeight,
                rect.width() + 2 * BORDER_WIDTH,
                rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight );

    // title bar rect
    QRect tr( 0, -titleHeight,  titleWidth - 1, titleHeight - 1);

    QRegion oldClip = painter->clipRegion();
    painter->setClipRegion( oldClip - QRegion( tr ) );	// reduce flicker

#ifndef QT_NO_PALETTE
    const QColorGroup &cg = QApplication::palette().active();
//    const QColorGroup &cg = widget->palette().active();

#if !defined(QT_NO_DRAWUTIL)
    qDrawWinPanel(painter, br.x(), br.y(), br.width(),
		  br.height() - 4, cg, FALSE,
		  &cg.brush(QColorGroup::Background));
#endif

    painter->setClipRegion( oldClip );

    if (titleWidth > 0) {
	QBrush titleBrush;
	QPen   titlePen;
	int    titleLeft = titleHeight + 4;

	if (widget == qApp->activeWindow()) {
	    titleBrush = cg.brush(QColorGroup::Highlight);
	    titlePen   = cg.color(QColorGroup::HighlightedText);
	} else {
	    titleBrush = cg.brush(QColorGroup::Background);
	    titlePen   = cg.color(QColorGroup::Text);
	}

#define CLAMP(x, y)	    ( ((x) > (y)) ? (y) : (x) )

	int x = tr.x();
	QColor c1 = titleBrush.color();
	QColor c2 = titleBrush.color();
	
	if (widget == qApp->activeWindow()) {
	    c1 = QColor( 0x10, 0x20, 0x90 ); // '98 Blue
	    // c2 = QColor( 0x50, 0x60, 0xD0 );
	    c2 = QColor( 0x70, 0x70, 0x70 );
	    // c1 = QColor( 0xBA, 0xC4, 0x05 ); // Trolltech Green
	    // c1 = QColor( 0xAA, 0xB4, 0x00 ); // Trolltech Green
	    // c2 = QColor( 0x20, 0x20, 0x20 );
	} else {
	    c1 = QColor( 0x20, 0x30, 0x50 );
	    // c2 = QColor( 0x60, 0x70, 0x90 );
	    // c2 = QColor( 0x40, 0x40, 0x40 );
	    c2 = QColor( 0x70, 0x70, 0x70 );
	    titlePen = QPen( QColor( 0x90, 0x90, 0x90 ) );
	}
	
	int r = c1.red();
	int g = c1.green();
	int b = c1.blue();
	for (int i = 0; i < 100; i++) {
	    int dr = r + (c2.red() * i) / 100;
	    int dg = g + (c2.green() * i) / 100;
	    int db = b + (c2.blue() * i) / 100;
	    x = tr.x() + (tr.width() * i) / 100;
	    int x2 = tr.x() + (tr.width() * (i + 1)) / 100;
	    QBrush tbr = QBrush( QColor( CLAMP(dr,255), CLAMP(dg,255), CLAMP(db,255) ) );
	    painter->fillRect( x, tr.y(), x2 - x, tr.height(), tbr);
	}
	
#ifndef QT_NO_WIDGET_TOPEXTRA
	painter->setPen(titlePen);
	painter->setFont(widget->font());
	painter->drawText( titleLeft, -titleHeight,
	 		rect.width() - titleHeight - 10, titleHeight-1,
			QPainter::AlignVCenter, widget->caption());
#endif
    }

#endif //QT_NO_PALETTE

}